我有一個在我的項目中引用的COM對象。當我用目標框架4.5構建項目時,一切正常。但是,如果我將目標框架更改爲3.5(或2.0),則在嘗試使用DLLName.exe實例化類時,代碼會引發異常(我認爲它是ActiveX EXE)早期版本框架的互操作錯誤
以下是錯誤從一門外語,因此可能不準確):
System.BadImageFormatException: Could not load file or assembly 'Interop.DLLname, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'Interop.DLLname, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
....
Assembly loaded from: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under file execution C:\Users\Admin\Documents\Visual Studio 2012\Projects\....t\bin\Debug\EXEname.vshost.exe
#NAME?
=== Pre-bind state information ===
LOG: User =
LOG: DisplayName = Interop.DLLname, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Users/Admin/Documents/Visual Studio 2012/Projects/............/bin/Debug/
LOG: Initial PrivatePath = NULL
Assembly calls : EXEname, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
....
LOG: Using computer file configuration from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
....
ERR: Failed to complete assembly definition (hr = 0x8013101b).
我試圖從斌/ OBJ文件夾中刪除interop.DLLname.dll,我已籤,在構建所有項目的目標框架2.0
我失去了什麼東西?
這個效果很好,當我嘗試它。在互操作庫上運行corflags.exe實用程序以進行額外檢查。 –