gpt4 book ai didi

c# - 无法加载文件或程序集 'msshrtmi' 或其依赖项之一(Azure 表存储访问)

转载 作者:IT王子 更新时间:2023-10-29 03:51:11 26 4
gpt4 key购买 nike

我有一个 HTTPModule,用于在数据中心的网站和 Azure 平台上运行的网站之间重定向流量。此 HTTPModule 从 Azure 表存储检索其重定向规则。

重定向在我的本地开发计算机以及在 Azure 上运行时都可以正常工作。但是,当我将该模块部署到我的数据中心服务器(IIS 7、WS 2008 R2 Standard 64bit、.NET 4.0、ASP.NET 4.0)时,我收到以下错误

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:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config Line: 126

“msshrtmi.dll”实际上存在于我的部署 bin 目录中。

如果我删除此 dll,数据中心站点工作正常,但 HTTPModule 无法从表存储加载其配置数据,而是抛出以下错误

---> 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()

此外,我还手动将“Microsoft.WindowsAzure.ServiceRuntime.dll”包含在部署中,以确保它在数据中心服务器上可用。

最佳答案

Azure 项目似乎对该特定​​文件非常敏感。来自: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

这一切都表明您需要检查是否已为目标环境上的部署构建了正确的配置。确保您已将 x64 定位为部署到数据中心服务器的目标。

关于c# - 无法加载文件或程序集 'msshrtmi' 或其依赖项之一(Azure 表存储访问),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8273321/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com