title: Windows Service: The module was expected to contain an assembly manifest
body: <p>I've got a C# program that was built as a Windows service.  I tested this last week and it worked fine, but today I'm getting an error.</p>
  
  <p>When I try to install using installutil.exe, I get the error:</p>
  
  <blockquote>
    <p>Could not load file or assembly [file name] or one of its dependencies.  The module was expected to contain an assembly manifest.</p>
  </blockquote>
  
  <p>Rebuilding the project had no effect.  I also noticed in task manager that the service is still listed and running.  On the chance that might be interfering with the installation, I tried uninstalling via installutil, but got the same error message back again.</p>
  
  <p>I've seen many other questions related to this error, but most of them have either no answer, or a very specific answer related to their unique situation.  Has anybody had this happen, and how did you fix it?  Any ideas are appreciated.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I successfully uninstalled the service using the "sc delete" command via command prompt, but I'm still getting the same error from installutil on trying to reinstall.</p>
  
  <p><strong>Update 2:</strong></p>
  
  <p>Just for the sake of trying something, I deleted the bin folder from the project, reopened the solution, and did a clean and build.  It still won't install, but now I've got a different message:</p>
  
  <blockquote>
    <p>This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.</p>
  </blockquote>
  
  <p><strong>Question:</strong></p>
  
  <p>What would cause there to be a mismatch in runtimes?  As far as I know, I've only used .NET Framework 4.5 and haven't deviated.  Is there a value I should be looking at / changing to fix that?</p>
  
  <p><strong>Update 3:</strong></p>
  
  <p>Here's what I've tried so far:</p>
  
  <p>One answer suggested the version of installutil being used matters.  I'd been running v2.0.50727, but there's also a v4.0.30319 I hadn't thought to try.  Running this resulted in:</p>
  
  <blockquote>
    <p>An attempt was made to load a program with an incorrect format...</p>
  </blockquote>
  
  <p>I'd be willing to work on that error instead, <em>if</em> it would solve the problem.  However, I'm compelled to think that's not the problem since I'd been successfully running v2.0.etc just before the first error popped up.</p>
  
  <p>Inside App.config, there's a line "supported Runtime version=v4.0".  I switched this to 4.5, but it had no effect good or bad.</p>
  
  <p>I tried switching the target framework (under project properties) down to 4.0, but this cause an error with:</p>
  
  <blockquote>
    <p>Some NuGet packages were installed using a target framework different from the current target framework, etc...</p>
  </blockquote>
  
  <p>This was referring to the EntityFramework, and I'd rather not start messing with NuGet again unless it's the only way (last time it was a nightmare).</p>
  
  <p>I tried installing the service on the target server (the machine it will eventually be deployed to) and got the same error.  This leads me to think it's a problem with the project / solution and not the pc.</p>