.NET 4 Windows服务安装升级错误

时间:2011-03-11 20:22:46

标签: .net windows service installer

我有一个.NET 3.5 Windows服务,它是使用VS2008安装程序安装的。部署项目。它有一个自定义安装操作。这个服务的安装工作很好,直到我最近升级到VS2010 / .NET 4.现在,当我升级到新版本时,我收到安装错误:“错误1001 ... BadImageFormatException :可能不加载文件或程序集...此程序集由比当前加载的运行时更新的运行时构建...“。如果我卸载以前的版本,然后安装新版本,一切正常......没有错误。安装正在我的开发机器上执行,因此.NET 4框架已经存在。

我启用了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>

谢谢,
史蒂夫


Fusion Log:

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.**

2 个答案:

答案 0 :(得分:0)

当我从我的应用程序中删除自定义操作时,升级工作正常,所以我想我已经找到了问题的根源。

答案 1 :(得分:0)

我有一个非托管C ++ EXE通过COM调用.NET DLL。

此处需要提及的是,上面列出的<startup>...块需要添加到foo.exe.config以及app.config(其中foo.exe是您的app.config可执行文件)。配置文件需要存在于安装目录中。

我得到了完全相同的错误,因为FUSLOGVW显示Windows正在加载.NET 2框架,尽管我正在编译.NET 4.我已经格式化了{{1}}但这还不够。

相关问题