473,545 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Declaration of smiOCTETS And SnmpStrToContex t

Hello,

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

I Declared :
[DllImport("Wsnm p32")]
private static extern IntPtr SnmpStrToContex t(
IntPtr session,
ref psmiOCTETS ptrsmiOCTETS);

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

or
[DllImport("Wsnm p32")]
private static extern IntPtr SnmpStrToContex t(
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 1986
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.co m

"Cedric" <Ce****@discuss ions.microsoft. com> wrote in message
news:0C******** *************** ***********@mic rosoft.com...
Hello,

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

I Declared :
[DllImport("Wsnm p32")]
private static extern IntPtr SnmpStrToContex t(
IntPtr session,
ref psmiOCTETS ptrsmiOCTETS);

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

or
[DllImport("Wsnm p32")]
private static extern IntPtr SnmpStrToContex t(
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
6423
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 C. It can cause very ugly errors,like this: epsilon=0 S=0 while epsilon<10: S=S+epsilon
10
2634
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 | don't, I need to know. Flames welcome.
8
2450
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> Point; is not only a declaration, but also a definition. The ISO/IEC 14882:2003(E) standard states in section 3.1 clause 2 that
10
20836
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 setting aside storage for an object, defining/declaring a struct, parts of a function, referencing an external variable in another module. ...
9
1493
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: | { declaration-list<opt> statement-list<opt> }
25
2777
by: venky | last post by:
Hi main() { int x; /* it declaration or defination??*/ }
4
6096
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
8867
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 *defined* "x"'s value to be 10, isn't above statement a
2
2586
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
7453
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7390
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7802
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7410
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5958
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4940
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3436
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1865
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.