473,396 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 1980
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

83
by: Alexander Zatvornitskiy | last post by:
Hello All! I'am novice in python, and I find one very bad thing (from my point of view) in language. There is no keyword or syntax to declare variable, like 'var' in Pascal, or special syntax in...
10
by: Christopher Benson-Manica | last post by:
Why can't I use a class destructor in a using declaration: using MyClass::~MyClass; ? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org ...
8
by: newmans | last post by:
Perhaps one of the experts can straighten me out on this point... In Bjarne Stroustrup's book 'The C++ Programming Language' 3rd Edition, section 4.9, indicates that typedef complex<short>...
10
by: Kobu | last post by:
My question is about the use and meaning of the terms "declaration" and "definition" as it pertains to the C language. I've read sources that mix the two up when talking about such things as...
9
by: Michael Mair | last post by:
Hello, in C89 (at least in the last public draft), "3.6.2 Compound statement, or block", we have ,--- | Syntax | | compound-statement: | { ...
25
by: venky | last post by:
Hi main() { int x; /* it declaration or defination??*/ }
4
by: nospam_timur | last post by:
Let's say I have two files, myfile.h and myfile.c: myfile.h: int myfunction(int x); myfile.c: #include "myfile.h"
9
by: Jess | last post by:
Hello, I was told that if I declare a static class constant like this: class A{ static const int x = 10; }; then the above statement is a declaration rather than a definition. As I've...
2
by: Alan | last post by:
Does a template class declaration, like template <class T> have to come immediately prior to the declaration of the function, e.g., T do_something (T something) { . . . } that uses it?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.