Quantcast
Channel: LabWindows/CVI topics
Viewing all articles
Browse latest Browse all 5339

access dictionary objects from C# dll in CVI

$
0
0

I am try to use a C# snmp dll in CVI. I have things working but I am at a loss as how to get the data out from the "snmp.Get" function since the result is a .net dictionary type. What do I do with the "dict" variable in my CVI code?

 

The C# code sample is:

string host ="localhost";string community ="public";
SimpleSnmp snmp =new SimpleSnmp(host, community);if(!snmp.Valid){
	Console.WriteLine("SNMP agent host name/ip address is invalid.");return;}
Dictionary<Oid,AsnType> result = snmp.Get(SnmpVersion.Ver1, newstring[]{".1.3.6.1.2.1.1.1.0"});if(result ==null){
	Console.WriteLine("No results received.");return;}foreach(KeyValuePair kvp in result){
	Console.WriteLine("{0}: {1} {2}", kvp.Key.ToString(), 
                          SnmpConstants.GetTypeName(kvp.Value.Type), 
                          kvp.Value.ToString());}

 

 My sample code is:

 

 

  char *oid[] = {{"1.3.6.1.2.1.1.1.0"}};

  System_Collections_Generic_Dictionary_T2 dict;

 

  status = Initialize_SnmpSharpNet();

  status = SnmpSharpNet_SimpleSnmp__Create_2 (&hSnmp,"localhost", "public", 0);

  status = SnmpSharpNet_SimpleSnmp_Get_1 (hSnmp, 0x0, oid, 1, &dict, 0);


Viewing all articles
Browse latest Browse all 5339

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>