Re: Problem with DllImport

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hello!

I load an external library written in Delphi (I don't have any source
code of this lib). I do it in this way:

[System.Runtime.InteropServices.DllImport("myLib.dll",
EntryPoint="externalMethod")]
public static extern bool userExist(string userName, string password);

Just a quick note: your trouble can be caused by Delphi's string types.
Depending on which Delphi version was used to build the DLL, the Delphi
strings can be different from what C# (.NET) expects. The safest thing is to
use PChars in Delphi code when interoperability is expected.

But when I close the program I get 2 errors.
1. "Unknown exception code (0x0eedfade) occurred at 0x7c81eb33."
2. "Runtime error 217 at 00009DF8"

Have you tried to call the DLL from a Delphi host application? Does the
error occur then? Either the DllImport signature is incorrect (like Nicholas
already suggested) or the Delphi DLL is incorrectly programmed. For example,
and object is freed twice upon shutdown, or used after it has been freed.

If you have the source code for the Delphi DLL, double-check to see how it
should be used (see again Nicholas' reply) or there are bugs in the DLL
code.

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
janij@xxxxxxxxxxxxxxxxxxxxxx
http://www.saunalahti.fi/janij/


.



Relevant Pages

  • Re: DLL with string params callable via D4 and VB
    ... > I have a DLL written in D6 that uses ShortStrings as parameters. ... I can't get beyond Delphi to ... > Is there any guidance you could give in regards to passing string ... written in order to be used by EXCEL 97 VBA. ...
    (borland.public.delphi.language.objectpascal)
  • Re: Using function with PChar data type
    ... the author of DLL just ... short STRING into a HUGE string. ... those string type into C like pointer strings. ... I tried to figure out why I could not get basic delphi pascal DLL to ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Using function with PChar data type
    ... DELPHI DLL I was using was just copying to a null terminated string ... But I was leery with the initializing and not allocating space for it. ... I was able to finally get the Delphi DLL to import and marshall correctly. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How do I add a record to an MS Acess DB using Delphi and ADO? Newbie
    ... sSql, sCnStr: string; ... > Delphi and ADO within a DLL I wrote in Delphi 7. ... > Right now the DLL is working and I can pass a string to it and it pops ...
    (borland.public.delphi.database.ado)
  • Re: How do I add a record to an MS Acess DB using Delphi and ADO? Newbie
    ... sSql, sCnStr: string; ... > Delphi and ADO within a DLL I wrote in Delphi 7. ... > Right now the DLL is working and I can pass a string to it and it pops ...
    (alt.comp.lang.borland-delphi)