.NET 4 Windows service install upgrade error

1

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:\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.**
.net
windows
service
installation
asked on Stack Overflow Mar 11, 2011 by Steve • edited Mar 11, 2011 by Steve

2 Answers

0

When I remove the custom actions from my application, the upgrade works just fine so I guess I've pinpointed the source of the problem.

answered on Stack Overflow Mar 13, 2011 by Steve
0

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.

answered on Stack Overflow Sep 2, 2011 by Pierre • edited Sep 2, 2011 by Pierre

User contributions licensed under CC BY-SA 3.0