MIB-to-C# Compilation

By Lex Li

This page shows you information about the MIB-to-C# compilation feature, which is currently experimental.

In this article:


#SNMP Library has a sample project that can work as a test agent. The agent can be manually extended to support more mangement objects, but it is possible to compile MIB documents to C# classes so as to simplify the process.

Evaluation Steps

Generating C# Source files

To test it out with #SNMP MIB Compiler Pro, make sure that the menu item “Generate C# source files from MIB documents” is checked on the tool bar. Then C# source files will be generated when MIB documents are compiled, and saved to a child folder called modules in the folder that contains Compiler.exe.

To test out the same with SharpSnmpPro.Mib assembly,

  1. Clone the extensions assembly from GitHub .
  2. Replace the project reference to SharpSnmpPro.Mib with a NuGet package reference to SharpSnmpPro.Mib.
  3. Use ObjectTree.GenerateSourceFiles(string outputFolder) method to generate C# source files.

Extending Test Agent

Once the source files are generated (in modules foldler for example), a C# project called Objects.csproj can be found in the same folder.

Open snmpd.csproj in #SNMP Library source code, and add a reference to this new project, and the generated management objects can be added to the agent for testing.


There is no official support to use either the test agent or the generated C# classes for production usage.

MIB-to-C# compilation only generates new classes (or overwrites existing classes). Currently no plan to support in-place upgrade.