2011-03-11 90 views
1

我有一個使用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.** 
+0

看看這個問題上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

+0

卸載自定義操作正在運行舊應用程序。這可能是問題的一部分。還有另一件要檢查的是MSI的版本號更改,並且程序集版本是否在exe/dll文件中更改? (如果它們是相同的版本,它們可能不會被替換,因此舊文件仍然存在) – randbrown 2011-03-11 21:21:41

+0

是的,我傾向於同意,看起來卸載自定義操作似乎是問題的根源。不幸的是,我不知道如何超越我所處的位置來進一步解決問題。安裝項目的版本屬性增加(與ProductCode屬性一起)。 – Steve 2011-03-11 21:31:32

回答

0

當我刪除自定義操作從我的應用程序,升級工作得很好,所以我想我已經指出了問題的根源。

+0

如果這是該問題的正確答案,則可以繼續並將其標記爲答案。這樣做沒有任何處罰,並且它不會顯示在未回答問題的列表中。 – 2011-05-11 12:27:54

0

我有一個非託管的C++ EXE通過COM調用.NET DLL。

這裏需要提到的是什麼的<startup>...塊,上面列出的,需要被添加到foo.exe.config,以及app.config(其中foo.exe是你的可執行文件)。配置文件需要存在於安裝目錄中。

我得到了完全相同的錯誤,因爲FUSLOGVW顯示Windows正在加載.NET 2框架,雖然我正在編譯.NET 4.我已經格式化了我的app.config,但這還不夠。