Re: dll import

From: Dale Preston (dalepres_at_nospam.nospam)
Date: 03/26/05


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);
> }
>
>
>
>



Relevant Pages

  • Re: dll import
    ... > C# applications (one webservice, ... > object" when calling a method from the dll. ... > after it fails once it continues to fail until I reboot. ... > public static extern IntPtr CreateMSGClass; ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • dll import
    ... I have created a dll from a C++ class using .Net and have imported it into my ... C# applications (one webservice, one standalone app). ... after it fails once it continues to fail until I reboot. ... IntPtr pMSG = MSG_Class.CreateMSGClass; ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • dll import
    ... I have created a dll from a C++ class using .Net and have imported it into my ... C# applications (one webservice, one standalone app). ... after it fails once it continues to fail until I reboot. ... IntPtr pMSG = MSG_Class.CreateMSGClass; ...
    (microsoft.public.dotnet.languages.csharp)
  • DLL problem
    ... I am developing a webservice that uses a third party dll. ... I added the dll as a reference in the offline part and the ... string dir = System.Environment.CurrentDirectory; ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: "CreateToolhelp32Snapshot" problem
    ... It is not possible to document all legitimate reasons for the module ... On current operating systems it will fail for the ... processes and don't find a certain DLL in any of them, ... >> snapshot won't work for a system process and will fail with strange ...
    (microsoft.public.win32.programmer.kernel)