Re: dll import
From: Dale Preston (dalepres_at_nospam.nospam)
Date: 03/26/05
- Next message: Sam Carleton: "how to work with 3rd party SDK"
- Previous message: Dale Preston: "Re: Enterprise Services"
- In reply to: Jason: "dll import"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 25 Mar 2005 18:57:30 -0600
You should be able to easily determine what is null when it should not be by
testing for null before using your objects. What has your debugging told
you, if anything?
Dale Preston
"Jason" <Jason@discussions.microsoft.com> wrote in message
news:53610F64-0E5F-4718-8930-BFF8E91976DF@microsoft.com...
> I have created a dll from a C++ class using .Net and have imported it into
my
> C# applications (one webservice, one standalone app). It works fine for a
> while, but will eventually fail to produce the error
> "System.NullReferenceException: Object reference not set to an instance of
an
> object" when calling a method from the dll. In the case of the
webservice,
> after it fails once it continues to fail until I reboot. My searches have
> been unsuccessful in finding a solution. I am using XP Pro with IIS 5.1
for
> the webservice.
>
> The only suggestion I have found through search is to check the
permissions,
> which I have done, but I could probably use some more detailed
instructions
> on how to do this.
>
> Any suggestions on how I might fix this problem?
>
>
>
> The code:
>
> DLL call that produces the error:
> IntPtr pMSG = MSG_Class.CreateMSGClass();
>
> and also:
> byte[] Message = new byte[MSG_Class.GetBufferSize(pMSG)];
> MSG_Class.GetBuffer(pMSG , Message); // this fails occasionally
>
>
> import:
> DLL Import class:
> [DllImport("MSG_1.dll")]
> public static extern IntPtr CreateMSGClass ();
>
> [DllImport("MSG_1.dll",CallingConvention=CallingConvention.ThisCall)]
> public static extern void GetBuffer( IntPtr instance, byte [] bufferOut );
>
>
> C++ (from which the dll was created):
> CreateMSGClass:
> return new MSGClass();
>
> void MSG_Class::GetBuffer(char * BufferOut) {
> memcpy(BufferOut, TheBuffer, sizeof(TheBuffer);
> }
>
>
>
>
- Next message: Sam Carleton: "how to work with 3rd party SDK"
- Previous message: Dale Preston: "Re: Enterprise Services"
- In reply to: Jason: "dll import"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|