Azure Deployment Issue after upgrading to Visual Studio 2010 and .NET 4.0

If you have recently upgraded your Web Role project from Visual Studio 2008 to Visual Studio 2010 you may end up experiencing a problem getting your Web Role to startup when you deploy it to Windows Azure.

There are a variety of reasons that your Web Role will not startup properly, however, if you are in this upgrade scenario check the bin of your Web Role project for the msshrtmi.dll.  If it exists then you are in luck, because that is likely your issue.  For some reason when you upgrade, this file ends up in your bin and therefore gets deployed to Windows Azure.  However, if you are developing on a x86 version of Windows (vs x64) then the dll that is in your bin will be the x86 version.  Windows Azure is x64 and thus when Azure attempts to startup your Web Role an error such as the following occurs.

Exception message: Could not load file or assembly ‘msshrtmi’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

Solution
It took a bit of playing around and comparing of the project files of a brand new Web Role to an upgraded one.

I was told that if I delete all of the bin directories in all of my projects then the file will not get copied.  I personally found this to be false, but it may be something that you will want to try.  After quite a bit of playing around I found that if I remove the <PlatformTarget> element from the configuration property group in the project file of my web project then the msshrtmi.dll file is not copied to the bin.  Hurray!

Steps

  1. Open the web site project file using Notepad.
  2. Remove the PlatformTarget element from all configuration property groups.

Example Configuration Property Group
<PropertyGroup Condition=” ‘$(Configuration)|$(Platform)’ == ‘Debug|AnyCPU’ “>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Optimize>false</Optimize>
<WarningLevel>4</WarningLevel>
</PropertyGroup>

If you still are unable to get your Web Role to start I believe you will need to log a case with “Report Live Site Issues” for Windows Azure from the Windows Azure support page.  I currently do not know how to view the log files that would provide you the startup errors, which is why you will need to log a case.  If anyone knows how to get the startup errors please post a comment or email me.

About these ads
Explore posts in the same categories: Windows Azure

Tags:

You can comment below, or link to this permanent URL from your own site.

21 Comments on “Azure Deployment Issue after upgrading to Visual Studio 2010 and .NET 4.0”

  1. thaw Says:

    Thanks. you saved my day Tom. :)

  2. Tim Says:

    Thanks! This was exactly what I needed! Though I saw this as a result of starting the project as a normal VS2008 ASP.NET MVC 2 project and then modifying it to run from a new Azure project I added, rather than upgrade from VS2008 to VS2010.

  3. Thirks Says:

    Fantastic,
    Fixed it for me!
    Thanks

  4. Pawel G. Says:

    You don’t have to use notepad, just right click the project and => Unload project and then Edit project.csproj, you get formatting and coloring ;)

  5. Alex Angas Says:

    Great (but concerning) find! Thanks so much for publishing this!


  6. Fantastic! It worked very smooth.

    In my case, I had a .targets file included in the web role’s csproj so the PlatformTarget was coming from there

  7. Anonymous Says:

    Thanks Tom and Pawel!

    That was helpful!

  8. Aaron Bird Says:

    Worked for me. Thanks so much, this was driving me crazy.

  9. chrishawn Says:

    Awesome.. saved me


  10. This has worked for me in the past. I opened my project with the latest SDK released this week and I get the same error. Even without the tag in the project file.

    I really don;t know how to tackle this one anymore…

  11. Anonymous Says:

    I had this problem because I had an x64 console app that needed to run in my Azure configuration that I needed copied to approot/bin, which caused msshrtmi.dll to be copied into my bin directory.

    This seemed to be necessary if you are running x64 console apps in the cloud fabric. My solution was to delete it in a pre-build event:

    del $(TargetDir)\msshrtmi.dll
    del $(TargetDir)\mswacdmi.dll

    Then when i ran in debug mode, it wasn’t there and I was fine.


  12. Ahhh! That’s SO much better. Nice fix!

  13. Anonymous Says:

    Thanks for your time-saving post!

  14. Anonymous Says:

    I have some issue but my .csproject file doenst have element. what should I do?
    I have been struggling with it. Thanks

    • Tom Krueger Says:

      Sorry I missed your comment. I would create a new project using Visual Studio 2010 using .NET 4.0 and then compare your csproj file to the one you just created. You should be able to find the missing elements.

      Good luck,
      Tom

  15. Basit Says:

    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??

    • Tom Krueger Says:

      Basit,

      Sorry for such a delay on a response. Did you ever figure this out? The steps I would take is start a brand new project and then compare the project file with yours and start making your look like the one that works. Other than that if you don’t know what the actual error is you will likely need to log a request to get the log. I don’t know if they have gotten better at providing logs for startup errors yet.

      Wish you luck!

  16. Anonymous Says:

    Hi,
    Thanks for providing the solution, It really helped me.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: