none
Ngen error: Failed to load the runtime. RRS feed

  • Question

  • I'm trying to Ngen some of the assemblies we create and I'm running into the follow error on a few of them which has me stumped:

    Microsoft (R) CLR Native Image Generator - Version 4.0.30319.1
    Copyright (c) Microsoft Corporation.  All rights reserved.
    Installing assembly AssemblyFilePath Failed to load the runtime. (Exception from HRESULT: 0x80131700). Assembly AssemblyFilePath requires version v4.0.30319 of the runtime to run.
    Assembly will be compiled once the correct runtime is installed.
    All compilation targets are up to date.

    The runtime is definitely installed.  The application uses the "problem" assemblies and runs just fine but try as I might, I can't get Ngen to generate a native image for them.

    I also tried to use Ngen on a previous version of our product which uses .NET 3.5 and receive a similar error on the same assemblies but referencing the 2.0 runtime instead so the problem does not seem to be specific to .NET 4.0.

    I wondered if there was any x64 vs x86 platform issue at play because some of the dependencies are mixed assemblies (Native and Managed.)  I tried the /NoDependencies option, an x86 OS, and I also set the platform target for the assembly to x86 but I always get the same error.  In addition, some of the assemblies which do not trigger this error also reference the same mixed assemblies and are targeted to Any CPU so I've done my best to rule this out as the issue.

    Wednesday, October 26, 2011 7:09 PM

Answers

  • It turns out the config files contained the following:

      <startup>
        <supportedRuntime version="v3.5"/>
      </startup>
    Wednesday, November 2, 2011 8:17 PM

All replies

  • Try reinstall .NET framework to see if the problem persist.

    Also if your runtime is using any of the web related technologies, pake sure you're installing full .NET framework runtime instead of client profile.

    Friday, October 28, 2011 3:06 AM
  • It does not appear to be an issue with the installation of the .NET Framework.  We are experiencing the on every machine we try to Ngen the assemblies in question on.  It is occurring accross multiple framework versions and even on developer machines which have Visual Studio 2010 Ultimate installed.  It seems something about some of our assemblies is causing Ngen to fail with this error but I believe the error message itself is not representative of the true problem.
    Friday, October 28, 2011 3:31 PM
  • I'm suggesting possiblity of client profile because .NETv4 is the first version of runtime that have a "favour" that does not contain all assemblies, and your aseemblies would see a previous version when trying to load the trimmed away ones.

    However this guess is unlikely to be the case if you also experienced the problem on VS2010 Ultimate machines.

    I currently have no idea... however since this problem is not shown to be asked a lot, this fact suggested that the problem could be something trival to solve once you look at the project files. I'll suggest you open the project(*.*proj) files, config files and manifest files with a plain text editor to see if you can find some hint there.


    • Edited by cheong00 Saturday, October 29, 2011 1:38 AM
    Saturday, October 29, 2011 1:37 AM
  • It turns out the config files contained the following:

      <startup>
        <supportedRuntime version="v3.5"/>
      </startup>
    Wednesday, November 2, 2011 8:17 PM
  • Thanks for the update.
    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, November 8, 2011 3:27 AM
    Moderator