简体   繁体   English

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

[英].NET 4 Windows service install upgrade error

I have a .NET 3.5 Windows service which is installed using a VS2008 Setup & Deployment project. 我有一个使用VS2008安装和部署项目安装的.NET 3.5 Windows服务。 It has a custom install action. 它具有自定义安装操作。 The installation of this service worked great until I recently upgraded to VS2010/.NET 4. Now, when I upgrade to the new version, I get the install error: "Error 1001... BadImageFormatException : Could not load file or assembly...This assembly is built by a runtime newer than the currently loaded runtime...". 在我最近升级到VS2010 / .NET 4之前,该服务的安装效果很好。现在,当我升级到新版本时,出现安装错误:“错误1001 ... BadImageFormatException :无法加载文件或程序集。 。此程序集由比当前加载的运行时新的运行时构建。” If I uninstall the previous version and then install the new version, everything works fine...no errors. 如果我卸载以前的版本,然后安装新版本,则一切正常,没有错误。 The install is being performed on my development machine so the .NET 4 framework is already there. 安装是在我的开发机器上执行的,因此.NET 4框架已经存在。

I enabled Fusion logging and found an error file (see below). 我启用了Fusion日志记录,并发现了一个错误文件(如下所示)。 The service "ServerService.exe" is being loaded by the .NET 2.0 framework, but I am not sure why this is. .NET 2.0框架正在加载服务“ ServerService.exe”,但我不确定为什么会这样。 Other files in the install are loaded by the 4.0 framework. 安装中的其他文件由4.0框架加载。 Does anyone have any suggestions on how to fix this or how I can investigate this further? 有人对如何解决此问题或我如何进一步调查有任何建议吗?

The project targets the .NET 4.0 framework and my app.config contains the following lines: 该项目面向.NET 4.0框架,而我的app.config包含以下几行:

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>

Thanks, 谢谢,
Steve 史蒂夫


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

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

I have an unmanaged C++ EXE calling a .NET DLL through COM. 我有一个非托管的C ++ EXE通过COM调用.NET DLL。

What needs to be mentioned here is that the <startup>... block, listed above, needs to be added to foo.exe.config , as well as app.config (where foo.exe is your executable). 这里需要提到的是,上面列出的<startup>...块需要添加到foo.exe.configapp.config (其中foo.exe是您的可执行文件)中。 The config file needs to be present in the install directory. 配置文件必须存在于安装目录中。

I was getting the exact same error, because FUSLOGVW showed that Windows was loading .NET 2 framework although I was compiling against .NET 4. I had formatted my app.config but that wasn't enough. 我遇到了完全相同的错误,因为FUSLOGVW显示Windows尽管正在针对.NET 4进行编译,但Windows正在加载.NET 2框架。我已经格式化了app.config但是还不够。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM