Comment appeler des fonctions à partir d'une DLL C++?Interface C# C++ DLL?
La DLL C++ contient des fonctions comme ceci:
__declspec(dllexport) bool Setup() { return simulation.Setup(); }
Le programme C# fait ceci:
[DllImport("mydll.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Setup();
C# programme se bloque avec le message suivant quand il tente de charger la DLL (?) :
An unhandled exception of type 'System.BadImageFormatException' occurred in TestFrame.exe
Additional information: There was an attempt to load a file with a wrong format (exception from HRESULT: 0x8007000B)
The C++ DLL is a standard DLL (no MFC, no ATL).
assembly .NET 64 bits essayant de charger un fichier .dll natif 32 bits? Vice versa? –
Google se traduit par 'Une tentative a été faite pour charger un programme avec un format incorrect. (Exception de HRESULT: 0x8007000B) ' – SLaks
Est-ce sur le système d'exploitation 64 bits? Si l'application .NET est compilée en tant que AnyCPU et que la DLL C++ est en 32 bits, la DLL ne se chargera pas. –