Creating Components Dynamically
When using Visual Studio .NET, the Agent and Manager components can also be added as a reference. In this case there are a few extra steps you must take, namely:
- You must instantiate your own event handlers.
- You must create and add a licenses.licx file to the project.
Use the following steps to add the Agent and Manager components as a reference within Visual Studio .NET:
- Start Visual Studio .NET.
- From the File menu, choose New, then choose Project.
- From the resulting dialog box, choose either Visual C# Projects or Visual Basic Projects then choose Windows Application. Specify a name and a location for the project, then click OK.
- Now add the Agent or Manager component as a reference. To do this right-click the References folder in the Solution Explorer and choose Add Reference. If the Solution Explorer is not visible, navigate to the View menu and choose Solution Explorer.
The following dialog will appear.
- Select Dart.PowerSNMP.dll and click OK.
- Now you must add a licenses.licx file to the project. (See the topic "Creating A Licenses.licx File" for more information).
- Now make a quick application to test. Drag a button onto the form and insert the following code:
[C#]
using Dart.PowerSNMP;
private void button1_Click(object sender, System.EventArgs e)
{
Manager manager1 = new Manager();
// Create a GetRequest message
GetMessage req = new GetMessage();
// Add an intrinsic MibObject (to get the system description)
req.Variables.Add(new Variable(new Dart.PowerSNMP.MibObject.sysDescr()));
// Send a broadcast request to default port 161 and collect all responses
ResponseMessage[] responses = manager1.GetResponses(req);
foreach (ResponseMessage response in responses)
// Add the system description into listBox1
listBox1.Items.Add(response.Variables[0].Value);
}
- Navigate to the Debug menu and choose Start. The application will compile and execute. Click the button and you should see a list of network agents in the listbox.
- Note: This example shows usage without events. For most applications you will have to create your own event handlers. To do this, see the "Using Events" topic.
In This Section
- Overview
- This topic provides an overview for using PowerSNMP for .NET.
- Placing Components on a Form
- This topic demonstrates how to create and use the components using Visual Studio .NET.
- Creating Components Dynamically
- This topic demonstrates how to add a component as a reference using Visual Studio .NET.
- Synchronous vs. Asynchronous Use
- This topic discusses the benefits and uses for synchronous and asynchronous methods.
- Using Events
- This topic discusses how to use events with the component, both using Visual Studio .NET and in other environments.
- Using Components without Visual Studio
- This topic discusses using the components in an environment other than Visual Studio.
- Parsing MIB Files
- This topic discusses the classes generated when parsing MIB files.
- Namespace and Class Hierarchy
- This topic discusses the namespace and class hierarchy under Dart.PowerSNMP.
blockPowerSNMP Using Menu
Send comments on this topic.
Documentation version 1.2.0.0.
© 2008 Dart Communications. All rights reserved.