Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Service throws System.BadImageFormatException on Windows Server 2008, x64, .NET 4 migrated from 3.5
    text
    copied!<p>I have tried compiling the service EXE file as AnyCPU, x86, and x64. It works on my Windows&nbsp;7 x64 box. I'm installing with installutil, the <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="nofollow noreferrer">.NET</a> 4 version.</p> <p>When I start the service, I get an error. It says nothing, but it does point to which modules are loaded. Those of potential interest:</p> <blockquote> <p>LoadedModule[0]=D:\yellowbook\grapevine_service\grapevinesystemservice.exe LoadedModule<a href="https://github.com/atheken/NoRM" rel="nofollow noreferrer">3</a>=C:\Windows\system32\KERNEL32.dll LoadedModule<a href="http://en.wikipedia.org/wiki/MongoDB" rel="nofollow noreferrer">4</a>=C:\Windows\system32\KERNELBASE.dll LoadedModule[9]=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscoreei.dll LoadedModule[17]=C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll LoadedModule[18]=C:\Windows\WinSxS\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4927_none_88dce9872fb18caf\MSVCR80.dll LoadedModule[22]=C:\Windows\assembly\NativeImages_v2.0.50727_64\mscorlib\9a017aa8d51322f18a40f414fa35872d\mscorlib.ni.dll</p> </blockquote> <p>I can run this service as a console application with a command-line switch, which yields this:</p> <blockquote> <p>Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'grapevinesystemservice.exe' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. File name: 'grapevinesystemservice.exe'</p> </blockquote> <p>I've tried to the registry hack to force the use of the latest runtime. No effect. I've looked at the installed EXE file in reflect to make sure it didn't get munged by my buildserver, but it's targeted at 4.0.30319. My local, build, and test server all have 30319 as the .NET 4 version. None ever had a beta/RC.</p> <p>They weren't listed in the load modules, but I am also using log4net (rebuilt in .NET 4 from source code), <a href="http://structuremap.net/structuremap/" rel="nofollow noreferrer">StructureMap</a>, <a href="https://github.com/atheken/NoRM" rel="nofollow noreferrer">NoRM</a> (<a href="http://en.wikipedia.org/wiki/MongoDB" rel="nofollow noreferrer">MongoDB</a>), <a href="https://github.com/AutoMapper/AutoMapper" rel="nofollow noreferrer">AutoMapper</a>, Newtonsoft.Json, and a number of other DLL files that were built by my team.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload