Declaration of smiOCTETS And SnmpStrToContext

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I'm trying to implements snmp stuff into my App and I have problems with
SnmpStrToContext to do his job.

I Declared :
[DllImport("Wsnmp32")]
private static extern IntPtr SnmpStrToContext(
IntPtr session,
ref psmiOCTETS ptrsmiOCTETS);

with
struct psmiOCTETS
{
public long len;
public IntPtr ptr;
}

or
[DllImport("Wsnmp32")]
private static extern IntPtr SnmpStrToContext(
IntPtr session,
ref tabCsmiOCTETS smiOCTETS);

with
struct tabCsmiOCTETS
{
public long len;
public char[] ptr;
}

But nothing, I always have an SNMPAPI_CONTEXT_INVALID Error.

I use "public" or "public\0" string as context.

Thanks for help.
 
Cedric,

The declaration for your smiOCTETS structure is incorrect. The len
field should be of type int. A long in .NET is 64 bits, not 32.

Also, you should not use the second declaration of the structure with
the character array. Arrays in structures that are referenced can not be
marshaled correctly, and require manual marshaling.

Hope this helps.
 

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

Back
Top