我必须在我的应用程序中使用第三方DLL.DLL是32位,我使用的系统是64位操作系统.
我在我的DotNet应用程序(framework-4.5)中导入了32位DLL,如下所示
[DllImport("Sample.dll",
EntryPoint = "Add",
CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.StdCall)]
public static extern int Add(int iA, int iB);
Run Code Online (Sandbox Code Playgroud)
在IIS 7.5中 - 我将"启用32位应用程序"设置为"True".
并尝试将编译器管理器设置为 - X86,x64和任何CPU.
但是所有的尝试都会导致相同的错误
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题......
我在我的 asp.net Web 应用程序中使用第 3 方 C++ dll。
dll - 64-bit
asp.net Platform - Any Cpu
asp.net Framework - 4.0 (vs 2010)
System Os - Win 7 Professional (64-bit)
Run Code Online (Sandbox Code Playgroud)
我已将该 dll 放在“应用程序”文件夹中,并调用该 dll,其完整路径为:
[DllImport(@"D:\Application\Sampledll.dll",
EntryPoint = "SampleFunc",
CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.StdCall)]
public static extern int SampleFunc(char[] ch1, char[] ch2);
Run Code Online (Sandbox Code Playgroud)
但我得到了以下结果:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Run Code Online (Sandbox Code Playgroud)
当使用错误代码进行搜索时:0x8007000B - 这意味着“在 64 位系统上使用 32 位 dll”
但是这个dll是64位的dll......
我如何通过将 VS 的目标平台更改为“x86”和“x64”并将 …