我正在使用一个使用2个库的应用程序,第一个存储在我的项目之外的c:\ windows \ system32文件夹下,它用于:
[DllImport("FWLIB32.dll", EntryPoint="cnc_settimeout")]
public static extern short cnc_settimeout( ushort FlibHndl, int a );
第二个导入项目参考。
我需要同时使用它们,但如果我将Visual Studio配置为使用平台进行编译:"任何CPU" (并且更喜欢32位)第一部作品而第二部作品不起作用,我设置平台x86第二部作品但不是第一作品。
在这两种情况下都抛出 System.BadImageFormatException 。 如何使用这两个DLL?可能吗?
这是第一个dll细节:
PE details
Date compiled: Thu, July 21, 2011, 10:19:34 PM
Linker version: 6.0
Machine type: Intel 386 or later processors and compatible processors
PE format: PE32
Characteristics: Dynamic-link library
DLL Characteristics: None
Subsystem: The Windows graphical user interface (GUI) subsystem
Min OS: Windows 95
Min OS version: 4.0
Subsystem version: 4.0
File version: 0.0
Manifest: No
Images: No
Icons: No
Dialogs: Unknown (Not implemented)
String tables: Unknown (Not implemented)
Accelerators: Unknown (Not implemented)
Cursors: Unknown (Not implemented)
Menu: Unknown (Not implemented)
More details
designedFor: 32-bit Windows
typeOfFile: DLL
fileVersion: 5.9.0.1
productVersion: 5.9.0.1
Comments: DCompanyName
CompanyName: FANUC CORPORATION
FileDescription: Data Window Library for Win32
FileVersion: 5, 9, 0, 1
InternalName: Fwlib32
LegalCopyright: Copyright (C) 1996-2011 FANUC CORPORATION
LegalTrademarks: @OriginalFilename
OriginalFilename: Fwlib32.dll
PrivateBuild: TProductName
ProductName: FANUC Data Window Library
这是第二个细节:
PE details
Date compiled: Fri, December 7, 2012, 9:25:47 AM
Linker version: 10.0
Machine type: x64
PE format: PE32+
Characteristics: Application can handle > 2GB addresses (Large address aware); Dynamic-link library
DLL Characteristics: Image is NX compatible (No eXecute)
Subsystem: The Windows graphical user interface (GUI) subsystem
Min OS: Windows XP 64-Bit Edition / Windows Server 2003 / Windows Server 2003 R2
Min OS version: 5.2
Subsystem version: 5.2
File version: 0.0
Manifest: Yes (406 bytes)
Images: No
Icons: Yes (2 icons)
Dialogs: Unknown (Not implemented)
String tables: Unknown (Not implemented)
Accelerators: Unknown (Not implemented)
Cursors: Unknown (Not implemented)
Menu: Unknown (Not implemented)
More details
designedFor: 32-bit Windows on Windows NT
typeOfFile: DLL
fileVersion: 4.0.0.0
productVersion: 4.0.0.0
CompanyName: Siemens
FileDescription: Rpc Sinumerik Assembly
FileVersion: 4.0.0.0
InternalName: Siemens.Sinumerik.Rpc.dll
LegalCopyright: Copyright (C) 2012
OriginalFilename: RpcSinum.dll
对我来说都是32位...但为什么第一个只适用于"任何CPU"选项?