Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
494 views
in Technique[技术] by (71.8m points)

c# - Could not load file or assembly 'msshrtmi' or one of its dependencies (Azure Table Storage Access)

I have an HTTPModule that I use to redirect traffic between a website in my data center and a website running on the Azure platform. This HTTPModule retrieves its redirect rules from Azure Table Storage.

Redirects work fine on my local dev machine as well as when running on Azure. However, when I deploy the module to my data center servers ( IIS 7, WS 2008 R2 Standard 64bit, .NET 4.0, ASP.NET 4.0 ) I receive the following error

Parser Error 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.
Line 124:                <add assembly="System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 125:                <add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
Line 126:                <add assembly="*" />
Line 127:            </assemblies>
Line 128:            <buildProviders>

Source File: C:WindowsMicrosoft.NETFrameworkv4.0.30319Configweb.config    Line: 126 

"msshrtmi.dll" actually exists in my deployment bin directory.

If I remove this dll the data center site works fine but but the HTTPModule fails to load its configuration data from Table Storage and instead throws the following error

---> System.TypeInitializationException: The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'msshrtmi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeEnvironment()
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.get_IsAvailable()

Also, I have manually included "Microsoft.WindowsAzure.ServiceRuntime.dll" as part of the deployment to ensure it is available on the data center servers.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It seems that Azure projects are very sensitive to that particular file. From: http://social.msdn.microsoft.com/Forums/en-US/windowsazuretroubleshooting/thread/0fac1f05-eb55-432f-80ac-6f15cde5b14b/

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 option was confirmed by http://social.msdn.microsoft.com/Forums/en/windowsazure/thread/286cecf6-1423-4ef3-93f9-0eb8a67d8192. (edit: now a dead link as at February '12.)

  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

This all suggests that you'll want to check that you've built the correct configuration for deployment on your target environment. Make sure you've targetted x64 for deployment to your data centre servers.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...