我有一個使用VS2008安裝程序安裝的.NET 3.5 Windows服務&部署項目。它有一個自定義安裝操作。這個服務的安裝很好,直到我最近升級到VS2010/.NET 4.現在,當我升級到新版本時,我得到安裝錯誤:「錯誤1001 ... BadImageFormatException:無法加載文件或程序集...此程序集由比當前加載的運行時更新的運行時構建......「。如果我卸載以前的版本,然後安裝新版本,一切正常......沒有錯誤。正在我的開發機器上執行安裝,因此.NET 4框架已經在那裏。.NET 4 Windows服務安裝升級錯誤
我啓用了Fusion日誌記錄,發現了一個錯誤文件(見下文)。服務「ServerService.exe」正在由.NET 2.0框架加載,但我不確定這是爲什麼。安裝中的其他文件由4.0框架加載。有沒有人有任何建議如何解決這個問題或我如何進一步調查?
該項目面向.NET 4.0框架和我的app.config包含以下行:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
感謝,
史蒂夫
融合日誌:
Assembly Binder Log Entry (3/11/2011 @ 2:44:03 PM)
The operation failed.
Bind result: hr = 0x8013101b. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable C:\Windows\syswow64\MsiExec.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = NT AUTHORITY\SYSTEM
LOG: Where-ref bind. Location = C:\Program Files (x86)\Server\ServerService.exe
LOG: Appbase = file:///C:/Windows/syswow64/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===<br>
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: No application configuration file found.
LOG: Using host configuration file: C:\Users\Steve\AppData\Local\Temp\CFG94A5.tmp
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Server/ServerService.exe.
LOG: Assembly download was successful. Attempting setup of file: C:\Program Files (x86)\Server\ServerService.exe
LOG: Entering run-from-source setup phase.
ERR: Error extracting manifest import from file (hr = 0x8013101b).
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.**
看看這個問題上SO:http://stackoverflow.com/questions/3953063/how-to-force-an-application-to-use-net-3-5-or-above – kd7 2011-03-11 20:31:27
卸載自定義操作正在運行舊應用程序。這可能是問題的一部分。還有另一件要檢查的是MSI的版本號更改,並且程序集版本是否在exe/dll文件中更改? (如果它們是相同的版本,它們可能不會被替換,因此舊文件仍然存在) – randbrown 2011-03-11 21:21:41
是的,我傾向於同意,看起來卸載自定義操作似乎是問題的根源。不幸的是,我不知道如何超越我所處的位置來進一步解決問題。安裝項目的版本屬性增加(與ProductCode屬性一起)。 – Steve 2011-03-11 21:31:32