none
When using IIS Express I get: System.BadImageFormatException: Could not load file or assembly 'msshrtmi' or one of its dependencies.

    Question

  • I'm using Windows 7 64-bit and Visual Studio 2010 RC to develop a Windows Azure Web Role application. I have the Azure SDK 1.3 (with refresh) installed. I'm able to run my web role as a standard web application on full IIS 7.5 - i.e. not using the emulator. This is quicker for development purposes than spinning up the emulator. However, if I try to use IIS Express 7.5 I get an error (see end of posting). 

    I believe this is because my web role has dependencies on binaries which are 64-bit only as they are designed to run on Azure? As far as I can tell, IIS Express 7.5 is 32-bit only. Full IIS (on a 64-bit machine) works because the dependencies are also 64-bit.

    Can anyone confirm that this is the most likely cause of the error and if there are any workarounds that would allow me to use IIS Express without removing all the Azure dependencies from my web role project, and without needing to use the Azure emulator.


    Server Error in '/' Application.

    Could not load file or assembly 'msshrtmi' or one of its dependencies. An attempt was made to load a program with an incorrect format.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.BadImageFormatException: Could not load file or assembly 'msshrtmi' or one of its dependencies. An attempt was made to load a program with an incorrect format.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Assembly Load Trace: The following information can be helpful to determine why the assembly 'msshrtmi' could not be loaded.

    === Pre-bind state information ===
    LOG: User = XXXXXXXXXXXXXXXXXXXXX
    LOG: DisplayName = msshrtmi
     (Partial)
    WRN: Partial binding information was supplied for an assembly:
    WRN: Assembly Name: msshrtmi | Domain ID: 5
    WRN: A partial bind occurs when only part of the assembly display name is provided.
    WRN: This might result in the binder loading an incorrect assembly.
    WRN: It is recommended to provide a fully specified textual identity for the assembly,
    WRN: that consists of the simple name, version, culture, and public key token.
    WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
    LOG: Appbase = file:///C:/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/
    LOG: Initial PrivatePath = C:\XXXXXXXXXXXXXXXXXXXXXXXXXXWebRole\bin
    Calling assembly : (Unknown).
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\XXXXXXXXXXXXXXXXXXXXXXXWebRole\web.config
    LOG: Using host configuration file: C:\Users\XXXXXXXXXXXXXXX\Documents\IISExpress\config\aspnet.config
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/a2e921fe/486708f3/msshrtmi.DLL.
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/a2e921fe/486708f3/msshrtmi/msshrtmi.DLL.
    LOG: Attempting download of new URL file:///C:/TeamProjects/Consus/Dev/PostPublicBeta/Code/Consus.Server.WebRole/bin/msshrtmi.DLL.
    ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
    

    Stack Trace:

    [BadImageFormatException: Could not load file or assembly 'msshrtmi' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
      System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
      System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
      System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
      System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144
      System.Reflection.Assembly.Load(String assemblyString) +28
      System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
    
    [ConfigurationErrorsException: Could not load file or assembly 'msshrtmi' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
      System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +618
      System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209
      System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
      System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
      System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +94
      System.Web.Compilation.BuildManager.CallPreStartInitMethods() +332
      System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +677
    
    [HttpException (0x80004005): Could not load file or assembly 'msshrtmi' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
      System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8972384
      System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
      System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
    


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.372 

    Thursday, February 24, 2011 4:58 PM

Answers

  • Removing this line from the project file solved the problem:

    <PlatformTarget>AnyCPU</PlatformTarget>

    I originally ignored that blog post when I found it because it was talking about problems when deploying to Azure, rather than running it locally through IIS, but it does help with my problem too.

    I've not tried copying the DLL but I expect that would work too - I didn't realise there was a 32-bit version.

    Thanks

    • Marked as answer by Mog Liang Thursday, March 03, 2011 10:14 AM
    Sunday, February 27, 2011 5:31 PM

All replies