VB.NET SNMP example

G

Guest

I am looking a VB.NET example on how to reference the SNMP API information.
I am unable to add references to SNMPAPI.LIB or SNMPAPI.DLL.

My goal is to write a 100% VB.NET example (no C or C# code) of some simple
snmp commands. All examples I can find are written in C or C#. There is an
extensive snmp.h file, but I cannot find the equivalent for VB or figure out
how to manually create the equivalent in VB

All I need is a starting point. For example - successfull compilation with
all references resolved to call the SnmpMgrOpen function
 
G

Guest

My question is not really about SNMP as it is about properly referencing an
object. For example, if I have the following VB code

Dim lpMgrSession As Long
Dim lpAgentAddress As String
Dim lpAgentCommunity As String
Dim nTimeOut As Long
Dim nRetries As Long
lpMgrSession = SnmpMgrOpen(lpAgentAddress, lpAgentCommunity,
nTimeOut, nRetries)

I get the following error when I try to run

Name 'SnmpMgrOpen' is not declared.

The documentation indicates that the function is in MGMTAPI.DLL. My
challenge is that I have been unable to add this DLL as a reference. If I go
to Project/add reference and attempt to add under any of the tabs - .NET,
COM, or Projects, I get an error stating "This is not a valid assembly of COM
component"

What do I need to do in order to get VB.NET to understand how to call this
function?
 
N

Nick Malik [Microsoft]

You said that you found references for how to do this in C#, right? C# is
just managed code, just like VB.Net. The reference mechanism works exactly
the same way. Follow the directions you found for C# for adding a
reference.

It is best not to try to jump from C to VB.Net. That's not so easy to do.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 
G

Guest

The c code I want to emulate is very simple:

#include <snmp.h>
#include <mgmtapi.h>

I can't include the .h files in VB and I cannot figure out out to properly
reference the fucntion call that is in a specific library. I know this
shoudl be something simple, but I can't figure it out.
 
N

Nick Malik [Microsoft]

Your original post said: " All examples I can find are written in C or C#.
"

I would suggest that you refer to an example written in C#.
The include that you mention below is from C, not C#. These are
dramatically different languages.
They are NOT interchangable.

Once again, I suggest that you use the C# examples to start with.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

VB.NET SNMO example 1
Snmp support in C#? 1
SNMP 1
snmp trap 1
SNMP 5
Printer status and monitoring (WMI , SNMP) 3
snmp in c# 5
Microsoft: Get rid of VB.NET -- now ! 43

Top