471,627 Members | 1,284 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Declaration of smiOCTETS And SnmpStrToContext

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.

Dec 15 '05 #1
1 1918
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Cedric" <Ce****@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
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.

Dec 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

83 posts views Thread by Alexander Zatvornitskiy | last post: by
10 posts views Thread by Christopher Benson-Manica | last post: by
8 posts views Thread by newmans | last post: by
10 posts views Thread by Kobu | last post: by
25 posts views Thread by venky | last post: by
2 posts views Thread by Alan | last post: by
1 post views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.