|
-
Jan 5th, 2008, 12:39 AM
#1
Thread Starter
Interweb adm/o/distrator
[RESOLVED] [2.0] Calling function from Delphi DLL
I get the message "A reference to <path> could not be added. Please make sure the file is accessible, and that it is a valid assembly or COM component" any ideas what could be the problem? And how can i get it working via P/Invoke?
Last edited by Paul M; Jan 5th, 2008 at 01:37 AM.
Reason: Change title to be more relevant!
-
Jan 5th, 2008, 12:44 AM
#2
Re: [2.0] Add reference to Delphi DLL
Is this DLL a .NET assembly or a COM component? If it's neither then you can't add a reference to it, as the error message suggests. I'm not quite sure why you're asking about PInvoke. If you know you need to access its methods via PInvoke then why are you trying to add a reference to it? If it's not a .NET assembly or a COM component then you invoke its methods exactly the same way you do any other: using the DllImport attribute on a static method declaration.
-
Jan 5th, 2008, 12:51 AM
#3
Thread Starter
Interweb adm/o/distrator
Re: [2.0] Add reference to Delphi DLL
Unable to load DLL 'Encrypter.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Thats what i get now, after having manually registered the DLL and declaring it. Must it be placed in the System or System32 folder?
<edit>
I placed it in the System32 folder and i don't get that error anymore. No i get the following...
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Last edited by Paul M; Jan 5th, 2008 at 01:00 AM.
-
Jan 5th, 2008, 01:21 AM
#4
Thread Starter
Interweb adm/o/distrator
Re: [2.0] Add reference to Delphi DLL
Could it be that the String type of .NET is not equivalent to that of Delphi's?
-
Jan 5th, 2008, 02:42 PM
#5
Re: [2.0] Calling function from Delphi DLL
Show us the function signature (from the Delphi code) and the DllImport line from the C# code.
-
Jan 5th, 2008, 07:29 PM
#6
Thread Starter
Interweb adm/o/distrator
Re: [2.0] Calling function from Delphi DLL
Code:
function EncryptDoc(Password, FilePath, LaunchFile, OutputFile : WideString) : LongBool; stdcall;
Thats the definition of the function in the Delphi DLL and below is the DllImport from C#...
Code:
[DllImport("Encrypter.dll")]
static extern bool EncryptDoc(string PassWord, string FilePath, string LaunchFile, string OutputFile);
<Edit>
It uses Delphi WideString type which is equivalent to the .NET string type (System.String or BSTR), and Delphi LongBool which is equivalent to .NET Boolean.
Last edited by Paul M; Jan 5th, 2008 at 07:32 PM.
-
Jan 5th, 2008, 08:27 PM
#7
Re: [2.0] Calling function from Delphi DLL
Does the ": WideString" in the parameter list imply that all four parameters are that type?
-
Jan 5th, 2008, 09:15 PM
#8
Thread Starter
Interweb adm/o/distrator
Re: [2.0] Calling function from Delphi DLL
Yes they are all WideString's
-
Jan 6th, 2008, 12:00 AM
#9
Re: [2.0] Calling function from Delphi DLL
I can honestly say that I can't see any obvious issue there.
-
Jan 6th, 2008, 12:03 AM
#10
Thread Starter
Interweb adm/o/distrator
Re: [2.0] Calling function from Delphi DLL

There is a screen shot of what i am getting but its totally got me stumped
-
Jan 6th, 2008, 12:31 AM
#11
Thread Starter
Interweb adm/o/distrator
Re: [2.0] Calling function from Delphi DLL
Should the WideString's be PChar's instead, anybody know?
-
Jan 6th, 2008, 02:31 AM
#12
Thread Starter
Interweb adm/o/distrator
Re: [2.0] Calling function from Delphi DLL
 Originally Posted by Paul M
Should the WideString's be PChar's instead, anybody know?
That fixed it 
Just as i fixed it Australia got 2 wickets in a row !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|