.NET 4 Windows service install upgrade error

I have a .NET 3.5 Windows service which is installed using a VS2008 Setup & Deployment project. 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...". 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.

I enabled Fusion logging and found an error file (see below). The service "ServerService.exe" is being loaded by the .NET 2.0 framework, but I am not sure why this is. Other files in the install are loaded by the 4.0 framework. 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:

  <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:WindowsMicrosoft.NETFrameworkv2.0.50727mscorwks.dll
Running under executable  C:Windowssyswow64MsiExec.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: User = NT AUTHORITYSYSTEM
LOG: Where-ref bind. Location = C:Program Files (x86)ServerServerService.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:UsersSteveAppDataLocalTempCFG94A5.tmp
LOG: Using machine configuration file from C:WindowsMicrosoft.NETFrameworkv2.0.50727configmachine.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)ServerServerService.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.

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

链接地址: http://www.djcxy.com/p/20354.html

上一篇: 安装程序:WIX或Inno安装程序?

下一篇: .NET 4 Windows服务安装升级错误