我有一个使用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