none
Could not load file or assembly 'msshrtmi' - incorrect format in Azure deployment.

    Question

  • I am experiencing the issue of msshrtmi.dll messing up my Azure deployment of a WCF Web Service. 

    Rebuilding the same exact project as previously deployed now results in the error due to msshrtmi.dll not loading due to incorrect format.  Building from VS 2010 RTM + Azure SDK 1.4 on x86 development machine. 

    I have attempted the following suggested workarounds without success:

    - Remove all bin and obj directories and rebuild clean.

    - Explicitly target my project to x64.

    Any other suggestions?

    Before I take the ime to build a new dev machine, is moving to x64 dev environment a sure kill for this problem?

    - Rick

     

    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.

     

    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.

    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
    


    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.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
      System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
      System.Reflection.Assembly.Load(String assemblyString) +35
      System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +118
    
    [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) +11396867
      System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +484
      System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +127
      System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
      System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
      System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1087
    
    [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) +11529072
      System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
      System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4784373
    

     


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

     

    Monday, May 02, 2011 2:33 AM

Answers

All replies

  • Hi Rick,

    I understand that you experience a "Could not load file or assembly 'msshrtmi' or one of its dependencies" after deployment on the cloud.

    When you do a rebuild for the web role project, may I ask you to check if a msshrtmi.dll file in the bin folder or not? If yes, then please check if it is 64bit or 32bit using Dependency Walker. If it is 32bit, please try either of the following options to prevent outputing this dll file to bin folder.

    1. Target the web role project to x64 and recreate the azure service project. This is option is confirmed by http://social.msdn.microsoft.com/Forums/en/windowsazure/thread/286cecf6-1423-4ef3-93f9-0eb8a67d8192.

    2. Open the web site project file using Notepad and remove the PlatformTarget element from all configuration property groups. This option is quoted from http://tomkrueger.wordpress.com/2010/07/27/azure-deployment-issue-after-upgrading-to-visual-studio-2010-and-net-4-0/.

    3. Write Post-build event command to delete msshrtmi.dll when a build action is successfully performed. To do this, please right click the web role project and select Properties. Select the Build Events tab, in the "Post-build event command line" textbox, input the following command:

    cd $(TargetDir)
    del msshrtmi.dll

    Thanks,

     


    Wengchao Zeng
    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework

    • Marked as answer by Wenchao Zeng Monday, May 09, 2011 4:00 AM
    Monday, May 02, 2011 7:17 AM
  • Thanks for the post Wengchao Zeng: Solution 2 worked for me.

    Wednesday, July 20, 2011 3:20 PM
  • Solution 2 worked for me even though msshrtmi.dll was 64 bit.
    Tuesday, January 24, 2012 1:13 AM
  • Solution 2 worked for me as well.

     

    Thanks.

    Wednesday, February 01, 2012 10:13 PM
  • I have the same issue, I don’t have this element ( AnyCPU ) in my .csproject file, I also put these commands in post build script for the project, but still no luck.

    cd $(TargetDir)
    del msshrtmi.dll

    And I don’t see this file in my bin folder any more but when I deploy it on cloud I face the same issue, any suggestions??

    I'm using VS 2010 Express Edition

    --------------------------------------------------------------------------------------------

    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.
    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
    

    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.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
       System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
       System.Reflection.Assembly.Load(String assemblyString) +35
       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +123
    
    [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) +11567856
       System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +485
       System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +79
       System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +337
       System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
       System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1167
    
    [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) +11700592
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4868789
    


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


    BT

    Sunday, May 13, 2012 5:46 PM
  • I experience the same problem and solved it by not signing the Web project assembly.

    Wednesday, July 04, 2012 1:00 PM
  • I tried setting the target platform in my release build to x64, and i deleted  msshrtmi.dll, both to no avail. The thing that did it for me finally was upgrading to VS 2012 RC and azure toolkit june 2012. 

    Monday, August 06, 2012 6:55 PM