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?
Printable View
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?
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.
Thats what i get now, after having manually registered the DLL and declaring it. Must it be placed in the System or System32 folder?Quote:
Unable to load DLL 'Encrypter.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
<edit>
I placed it in the System32 folder and i don't get that error anymore. No i get the following...
Quote:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Could it be that the String type of .NET is not equivalent to that of Delphi's?
Show us the function signature (from the Delphi code) and the DllImport line from the C# code.
Thats the definition of the function in the Delphi DLL and below is the DllImport from C#...Code:function EncryptDoc(Password, FilePath, LaunchFile, OutputFile : WideString) : LongBool; stdcall;
<Edit>Code:[DllImport("Encrypter.dll")]
static extern bool EncryptDoc(string PassWord, string FilePath, string LaunchFile, string OutputFile);
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.
Does the ": WideString" in the parameter list imply that all four parameters are that type?
Yes they are all WideString's
I can honestly say that I can't see any obvious issue there.
http://aycu08.webshots.com/image/406...4772505_fs.jpg
There is a screen shot of what i am getting but its totally got me stumped :(
Should the WideString's be PChar's instead, anybody know?
That fixed it :DQuote:
Originally Posted by Paul M
Just as i fixed it Australia got 2 wickets in a row :D!