Dart Home | PowerSNMP for ActiveX | Custom Development | Reply | PowerSNMP for ActiveX Topics | Forums |
Author | Forum: PowerSNMP for ActiveX Topic: Port from C++ studio 6 to VB.net |
mtulloch From: laval, QC Canada Posts: 2 Member Since: 07/31/06 |
posted July 31, 2006 4:37 PM I have code written Visual C++ 6 to send SNMP traps. It includes loading the licence, this code still works. BOOL OpenTrap() { BOOL rv=TRUE; int nLocalPort; TCHAR *szAppSection="Trap Info"; HRESULT hr; BSTR LicKey; IClassFactory2 *pIUnknown = NULL; IUnknown *pOuter = NULL; LicKey = SysAllocString( L"1550-2-5073-xxxxx:xxxxx:Primas Group" ); hr = CoGetClassObject( __uuidof(Agent),CLSCTX_INPROC_SERVER,NULL,IID_IClassFactory2,reinterpret_cast<void**>(&pIUnknown) ); if(!FAILED( hr ) ) pIUnknown->CreateInstanceLic( pOuter,NULL,__uuidof(IAgent),LicKey,reinterpret_cast<void**> (&aptr2) ); SysFreeString( LicKey ); nLocalPort=GetPrivateProfileInt(szAppSection,"Local Port",164,INIFILE); // hr=aptr2.CreateInstance(CLSID_Agent); // if(hr != S_OK) // return; if(hr == S_OK) { try { hr=aptr2->Open(nLocalPort,""); } catch(...) { rv=FALSE; aptr2=NULL; SendNumberMessage(0); } } else { MessageBox(NULL,"Unable to load SNMP control!","Fatal Error",MB_OK); rv=FALSE; } return rv; } I rewrote in VB.net. It compiles and runs but the send trap operations fails because it can't find the runntime licence Dim Agent As New DartSnmp.Agent Dim varBind As New DartSnmp.SnmpVariable Dim Trap As New DartSnmp.SnmpTrap Agent.Open(SNMPManagerPort) Agent.TrapManagers.Clear() Agent.TrapManagers.Add(SNMPManagerAddress, 0) Agent.Message.Reset() Agent.Message.Type = DartSnmp.TypeConstants.snmpTrap1 If linkUp Then Agent.Message.GenericTrap = DartSnmp.TrapConstants.snmpLinkUp Else Agent.Message.GenericTrap = DartSnmp.TrapConstants.snmpLinkDown End If Agent.Message.Community = "public" varBind.Oid = "1.3.6.1.2.1.1.1.0" varBind.Name = "Subject" varBind.Type = DartSnmp.VariableTypeConstants.snmpOctetString varBind.Value = Subject Agent.Message.Variables.Add(varBind) varBind.Oid = "1.3.6.1.2.1.1.1.1" varBind.Name = "Message" varBind.Type = DartSnmp.VariableTypeConstants.snmpOctetString varBind.Value = Message Agent.Message.Variables.Add(varBind) Agent.Send() I added a reference to the DartSNMP2.dll Cheers Mark |
Raj From: Rome, NY, USA Posts: 389 Member Since: 02/01/06 |
posted August 1, 2006 11:41 AM Hi Mark, Before we begin, are you using a trial version of the product, and if not, which licensed version of the product do you have running? Have you tried creating and adding a licenses.licx file in your project? -Raj |
mtulloch From: laval, QC Canada Posts: 2 Member Since: 07/31/06 |
posted August 9, 2006 4:02 PM We have a licenced version the dll dartSnmp2.dll has the version 2.8.0.6. I did try creating a .lic file I didn't succeed. The other method I tried was making the legacy C code into a COM object and including it in my VB.net service. This works on my development box. But on my test machine (Win2000 Server) it crashes after the CoGetClassObject. The dartSMNP2.dll is registered and I added catches but the service still crashes Cheers Mark |
Raj From: Rome, NY, USA Posts: 389 Member Since: 02/01/06 |
posted August 10, 2006 3:06 PM Please refer the help file section: "NET/COM Interop" You may search for "Interop" in the help file, to locate articles that would be helpful in such a scenario. I hope this addresses your issue. Let me know if you have further questions. Regards, Raj |
Reply | PowerSNMP for ActiveX Topics | Forums |
This site is powered by PowerTCP WebServer for ActiveX |