i am getting that error with the Event() method.
Don't know whether if i have used the CreateEvent function well as it is the
1st time i used it moreover i am net to C#.
If anyone can point me out the error it would be great.
TIA
public class Class
{
public struct SECURITY_ATTRIBUTES{
public long nLength;
public long IpSecurityDescriptor;
public long bInheritHandle;
public SECURITY_ATTRIBUTES(long nLength,long
IpSecurityDescriptor,long bInheritHandle){
this.nLength = nLength;
this.bInheritHandle = bInheritHandle;
this.IpSecurityDescriptor =
IpSecurityDescriptor;
}
}
[DllImport("kernel32")]
public static extern long CreateEvent
(SECURITY_ATTRIBUTES lpEventAttributes,bool bManualReset,bool
bInitialState,string lpName);
public void Event(){
SECURITY_ATTRIBUTES Sd = new SECURITY_ATTRIBUTES();
Sd.nLength = Marshal.SizeOf(Sd);
Sd.bInheritHandle = 0;
Sd.IpSecurityDescriptor = 0;
long Test = CreateEvent(Sd,true,false,"Test");
}
} 1 1986
Hi,
"Merlynx" <no****@home.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... i am getting that error with the Event() method. Don't know whether if i have used the CreateEvent function well as it is
the 1st time i used it moreover i am net to C#. If anyone can point me out the error it would be great. TIA
public class Class {
prepend [StructLayout(LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES{ public long nLength; public long IpSecurityDescriptor; public long bInheritHandle; public SECURITY_ATTRIBUTES(long nLength,long IpSecurityDescriptor,long bInheritHandle){ this.nLength = nLength; this.bInheritHandle = bInheritHandle; this.IpSecurityDescriptor = IpSecurityDescriptor; } }
[DllImport("kernel32")] public static extern long CreateEvent (SECURITY_ATTRIBUTES lpEventAttributes,bool bManualReset,bool bInitialState,string lpName);
CreateEvent expects a pointer to a struct, a struct is a value type, so you
must use the ref keyword.
A handle has a platform dependend size, like IntPtr does.
public static extern IntPtr CreateEvent( ref SECURITY_ATTRIBUTES
lpEventAttributes, bool bManualReset, bool bInitialState, string lpName );
Keep in mind that net supports events, see AutoResetEvent and
ManualResetEvent classes...
HTH
greetings
public void Event(){ SECURITY_ATTRIBUTES Sd = new SECURITY_ATTRIBUTES(); Sd.nLength = Marshal.SizeOf(Sd); Sd.bInheritHandle = 0; Sd.IpSecurityDescriptor = 0; long Test = CreateEvent(Sd,true,false,"Test"); } }
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rafael |
last post by:
Hi, I hope I can find some help for this problem
IDE: Visual Studio.NET 2003 Developer Editio
Language: C#
Problem: "An unhandled exception of type 'System.NullReferenceException' occurred in...
|
by: Professor Frink |
last post by:
First off, I apologize if this gets long. I'm simply trying to give you all
enough information to help me out. I'm writing (almost finished, actually),
my first VB.Net application. It's a forms...
|
by: cristiank |
last post by:
hi everybody,
I need to clear something out,
does anybody have ever encountered such an exception until now :
"Un unhandled exception of type System.NullReferenceException occurred in...
|
by: juli |
last post by:
Hello!
I keep getting this error:
An unhandled exception of type 'System.NullReferenceException' occurred
Additional information: Object reference not set to an instance of an object.
I am...
|
by: Craig831 |
last post by:
First off, I apologize if this gets long. I'm simply trying to give you all
enough information to help me out. I'm writing (almost finished, actually),
my first VB.Net application. It's a forms...
| |
by: Chuck Hartman |
last post by:
I have a Windows service that requests web pages from a site using an
HttpWebRequest object. When I try to request a page from an ASP.NET 2 site,
I get a WebException with message "The remote...
|
by: mike |
last post by:
My program is crashing, but it doesn't crash on a single line of code. Below is what the output tab displays. I have no idea where to start inorder to debug this problem. Is there any suggesstions...
|
by: Supra |
last post by:
i got error problem..........
An unhandled exception of type 'System.NullReferenceException' occurred
in system.windows.forms.dll
Additional information: Object reference not set to an instance of...
|
by: statlerw |
last post by:
I have successfully implemented drag and drop in my application to
allow the reordering of columns by dragging and dropping them in the
same datagridvire (Net 2.0).
If i take it relatively...
|
by: Pedro Dinis |
last post by:
i have this class library that connects to the database(see appconfig below)
compiling 0 errors but when its running i amhaving this error
An unhandled exception of type...
|
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,...
| |
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,...
|
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...
|
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: 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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |