DllImport from C#  
Author Message
like_antani





PostPosted: Visual C# Language, DllImport from C# Top

Hi All,

I have finished my hard job of porting a VC6 project to VC8 but now I have a problem in using functions from C#. This is the declaration:

[DllImport("Test.dll", CallingConvention = CallingConvention.Cdecl)]

public static extern int MyFunction(...........);

but when I use MyFunction I have following error:

System.DllNotFoundException : Unable to load DLL Test.dll': Routine di inizializzazione della libreria di collegamento dinamico (DLL) non riuscita. (Exception from HRESULT: 0x8007045A)

Thanx in advance for your time!

Marcello



Visual C#4  
 
 
littleguru





PostPosted: Visual C# Language, DllImport from C# Top

The italian message is saying that the DLL could not be loaded. This HRESULT usually occurs if the DLL is defect.

 
 
like_antani





PostPosted: Visual C# Language, DllImport from C# Top

HI,

I have checked with the "view Dependencies" and all seems to be correct.

M


 
 
Gregory Panakkal





PostPosted: Visual C# Language, DllImport from C# Top




 
 
RizwanSharp





PostPosted: Visual C# Language, DllImport from C# Top

It simply says that DLL is not found. Try to put Test.DLL with the current dll/exe (assembly) in debug or release folder..

Dependency viewer will not resolve the dependancies made with DLLImport or Reflection.... So you have to make it sure manually....

Best Regards,

Rizwan



 
 
like_antani





PostPosted: Visual C# Language, DllImport from C# Top

Hi,

I have copied dll and its dependencies in debug folder and used DllImport but the result is the same.

Is it possible that the problem is linked with the compilation in VC8

Thanx

Marcello


 
 
littleguru





PostPosted: Visual C# Language, DllImport from C# Top

I think it has to do with the DLL. It is somehow corrupt or the methods are not exported properly. If you google for the HRESULT you will see that it has to do with a corrupt DLL that can't be accessed.

 
 
New-Bee





PostPosted: Visual C# Language, DllImport from C# Top

Are you missing any other dlls upon which your Test.dll might be depending


 
 
like_antani





PostPosted: Visual C# Language, DllImport from C# Top

I think I have found where's the problem; it is linked with the export specifics in VC8. Now I have to investigate better in my VC code.

In any case thanx to all for your time.

Marcello