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

发布于 2024-12-17 23:20:37 字数 1776 浏览 1 评论 0原文

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

重定向在我的本地开发计算机以及在 Azure 上运行时都可以正常工作。但是,当我将该模块部署到我的数据中心服务器(IIS 7、WS 2008 R2 Standard 64 位、.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”包含在部署中以确保它在数据中心服务器上可用。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(16

物价感观 2024-12-24 23:20:38

只需在项目中添加“_bin_deployableAssemblies”文件夹即可。将文件“C:\Program Files\Microsoft SDKs\Windows Azure.NET SDK\2012-06\bin\runtimes\base\x64\msshrtmi.dll”放入此文件夹中。将构建操作更改为“”并部署...

这对我有用...

Just add the "_bin_deployableAssemblies" folder in your projet. Put the file "C:\Program Files\Microsoft SDKs\Windows Azure.NET SDK\2012-06\bin\runtimes\base\x64\msshrtmi.dll" in this folder. Change the Build Action to "None" and just deploy...

It's work for me...

风吹短裙飘 2024-12-24 23:20:38

我可能疯了,但这件事发生在我身上,因为 Windows Azure SDK根本就没有安装。我知道这很愚蠢,但在某些情况下保持警惕很有用。

I may be crazy, but this happened to me because the Windows Azure SDK WAS NOT EVEN INSTALLED. Stupid, I know, but useful to keep an eye for in certain situations.

南风几经秋 2024-12-24 23:20:38

我最近经历过这种情况,并确定,至少就我而言,此错误是由于引用了比当前 SDK 版本更旧的 Microsoft.WindowsAzure.ServiceRuntime 引起的。

在我的实例中,我刚刚升级到 SDK 2.2,但我的 ServiceRuntime 引用仍然是 2.1,将这些引用更新到 2.2 解决了问题,而无需引用 msshrtmi.dll。

I experienced this recently and determined that, in my case at least, this error was caused by having a reference to Microsoft.WindowsAzure.ServiceRuntime that was older than the current SDK version.

In my instance I had just upgraded to SDK 2.2 but my ServiceRuntime references were still 2.1, updating these references to 2.2 solved the problem without me having to reference msshrtmi.dll.

木緿 2024-12-24 23:20:38

我将“复制本地”属性更改为“False”。这对我有用。

步骤

  1. 转到参考。
  2. 从引用中打开 dll 的属性。
  3. 将“复制本地”属性更改为False

I changed the "Copy Local" property to "False". And it worked for me.

Steps:

  1. Go to the reference.
  2. Open the properties of the dll from reference.
  3. Change "Copy Local" property to False.
乖乖兔^ω^ 2024-12-24 23:20:38

在使用可部署到 Windows Azure 和物理硬件的解决方案时,我遇到了类似的错误。尝试在物理硬件上运行该解决方案时会出现该错误。问题源于这样一个事实:Azure 库是解决方案的一部分,尽管本地构建不需要它们。

简单的解决方案是在物理硬件上安装 Windows Azure SDK。这会将缺少的库安装到 GAC 中

I suffered from a simlar error when working with a solution that was deployable to both Windows Azure and physical hardware. The error would show up when attempting to run the solution on physical hardware. The problem stemmed from the fact that Azure libraries were part of the solution, even though they were'nt required for the on-premise build.

The simple solution is to install the Windows Azure SDK on the physical hardware. This will install the missing libraries into the GAC

梨涡少年 2024-12-24 23:20:38

这个解决方案对我有用:

  • 用记事本打开项目
  • 删除所有“PropertyGroup”下的所有“PlatformTarget”标签

This solution work for me:

  • Open the project with a notepad
  • Delete all "PlatformTarget" tags under all "PropertyGroup"
南七夏 2024-12-24 23:20:38

我对此问题的解决方案是将 msshrtmi.dll(x86 和 x64)与我的应用程序一起提供,然后在需要时动态加载它们。

请参阅http://jake.ginnivan.net/azure-and-msshrtmi

My solution to this problem was to ship msshrtmi.dll (both x86 and x64) with my app, then dynamically load them when needed.

See http://jake.ginnivan.net/azure-and-msshrtmi

花开浅夏 2024-12-24 23:20:38

我通过将 msshrtmi 添加到 GAC 解决了问题。

I've solved issue by adding msshrtmi to GAC.

み零 2024-12-24 23:20:38

通过确保我在 GAC [1] 中引用 msshrtmi.dll 的 X64 版本(以匹配 x64 的平台目标),我能够解决此问题在项目上设置)。

[1] c:\Windows\Assembly\GAC_64\msshrtmi\1.7.0.0__31bf3856ad364e35>

I was able to get around this problem by making sure that I was referencing the X64 version of msshrtmi.dll in the GAC [1] (to match the platform target of x64 set on the project).

[1] c:\Windows\assembly\GAC_64\msshrtmi\1.7.0.0__31bf3856ad364e35>

窝囊感情。 2024-12-24 23:20:38

我也遇到了同样的问题。

从您的解决方案文件夹/子文件夹中删除所有文件“msshrtmi.dll”,然后重建。

I was having the same problem.

From your solution folder/subfolders delete all files "msshrtmi.dll" then rebuild.

顾忌 2024-12-24 23:20:37

Azure 项目似乎对该特定​​文件非常敏感。来自:http://social.msdn.microsoft.com/Forums/en-US/windowsazuretroubleshooting/thread/0fac1f05-eb55-432f-80ac-6f15cde5b14b/

当您对 Web 角色项目进行重建时,我可以请您检查一下吗
bin文件夹中是否有msshrtmi.dll文件?如果是,那么请
使用 Dependency Walker 检查它是 64 位还是 32 位。如果是32位的话
请尝试以下任一选项来防止输出此内容
dll 文件复制到 bin 文件夹。

  1. 将 Web 角色项目定位到 x64 并重新创建 azure 服务项目。该选项已被确认
    http://social.msdn.microsoft.com/Forums/en/windowsazure/thread/286cecf6-1423-4ef3-93f9-0eb8a67d8192。 (编辑:截至 2012 年 2 月现在是一个死链接。)

  2. 使用记事本打开网站项目文件,并从所有配置属性组中删除 PlatformTarget 元素。这
    选项引用自
    http://tomkrueger.wordpress.com/2010/07/27/azure-deployment-issue-after-upgrading-to-visual-studio-2010-and-net-4-0/.

  3. 编写构建后事件命令以在成功执行构建操作时删除 msshrtmi.dll。为此,请右键单击
    Web 角色项目并选择属性。选择构建事件选项卡,
    在“构建后事件命令行”文本框中,输入以下内容
    命令:

cd $(TargetDir)
删除 msshrtmi.dll

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

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.

寄人书 2024-12-24 23:20:37

这为我解决了问题。在 VS2013 的开发人员命令提示符中运行此命令。

gacutil /i "C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.0\bin\runtimes\base\x64\msshrtmi.dll"
gacutil /i "C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.0\bin\runtimes\base\x86\msshrtmi.dll"

这将在全局程序集缓存中注册运行时文件,以便所有 .NET 应用程序都可以访问它。

This solved the problem for me. Run this command within the Developer Command Prompt for VS2013.

gacutil /i "C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.0\bin\runtimes\base\x64\msshrtmi.dll"
gacutil /i "C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.0\bin\runtimes\base\x86\msshrtmi.dll"

This will register the runtime files in the Global Assembly Cache so all .NET applications will have access to it.

贩梦商人 2024-12-24 23:20:37

我刚刚看到这篇文章是因为我遇到了同样的问题 - 不幸的是上述步骤都不适合我

经过一番绞尽脑汁和胡思乱想后,我找到了解决方案,非常简单/令人尴尬。

我在这里写了关于它的博客

  • 右键单击您的 Azure 项目(带有蓝色地球的项目)。
  • 单击“应用程序”选项卡。
  • 请注意,有一个按钮告诉您已经安装了较新的 SDK?
    点击它!

因此,事实证明,对几个文件进行了一些细微的更改,从而产生了巨大的差异:

  • .csdef 文件 - 'schemaVersion' 已更新。
  • .ccproj - 'ProductVersion' 和 'CloudExtensionsDir' 已更新。
  • .csproj - 您的 Azure SDK 引用将被更新(ServiceRuntime、诊断等)。

我认为对我来说杀手是“CloudExtensionsDir”,这已更改为

<CloudExtensionsDir Condition=" '$(CloudExtensionsDir)' == '' ">
  $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Windows Azure Tools\1.7\
</CloudExtensionsDir>

: :

<CloudExtensionsDir Condition=" '$(CloudExtensionsDir)' == '' ">
  $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Windows Azure Tools\1.8\
</CloudExtensionsDir>

部署到 Azure,立即生效。

希望这有帮助!

PS:我应该补充一点,我不需要卸载任何旧的 SDK 或任何东西,也不需要搞乱“平台目标”。只要改变这个就可以了。

I've just come across this post because I had the same issue - and unfortunately none of the above steps worked for me.

After a bit of head-scratching and messing around - I found the solution, which was remarkably/embarrassingly simple.

I blogged about it here.

  • Right-click your Azure project (the one with the blue globe).
  • Click the "Application" tab.
  • Note that there is a button telling you that you have a newer SDK installed?
    CLICK IT!

So, it turns out that some minor changes get made to a few files that make all the difference:

  • .csdef file - 'schemaVersion' is updated.
  • .ccproj - 'ProductVersion' and 'CloudExtensionsDir' are updated.
  • .csproj - You're Azure SDK references will be updated (ServiceRuntime, Diagnostics etc.)

I think the killer was the 'CloudExtensionsDir' for me, this changed FROM:

<CloudExtensionsDir Condition=" '$(CloudExtensionsDir)' == '' ">
  $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Windows Azure Tools\1.7\
</CloudExtensionsDir>

TO:

<CloudExtensionsDir Condition=" '$(CloudExtensionsDir)' == '' ">
  $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Windows Azure Tools\1.8\
</CloudExtensionsDir>

Deployed to Azure, worked straight away.

Hope this helps!

PS: I should add, that I didn't need to uninstall any of the old SDK's or anything or mess around with 'Platform Targets'. Just changing this worked fine.

沩ん囻菔务 2024-12-24 23:20:37

我在处理这个问题很长时间后遇到了这个问题。它帮助了我。

http://mictorino.wordpress.com /2011/09/20/vs2010-build-configurations-and-msshrtmi-dll-x86

I ran across this after dealing with this issue for a long time. It helped me.

http://mictorino.wordpress.com/2011/09/20/vs2010-build-configurations-and-msshrtmi-dll-x86

雪若未夕 2024-12-24 23:20:37

这个问题困扰了我两天,这里和其他网站上提到的所有解决方案都不起作用。

现在我终于开始工作了。问题是我的机器上安装的 SDK 和工具版本的组合不佳。几天前,我下载了以下内容:

  • Windows Azure Tools 1.7
  • Windows Azure SDK Preview for Visual Studio 2012(2012 年 6 月)

我知道 Azure SDK 是预览版,但一些发行说明让我相信它包含当前版本的(稳定) SDK for Visual Studio 2010。

在我卸载预览版并安装Windows Azure SDK for .NET (VS 2010 SP1) - June 2012后,一切运行良好。

This problem has bugged me for the last two days, and all solutions mentioned here and on other websites did not work.

Now I finally got it working. The problem was some bad combination of SDKs and tools versions installed on my machine. Some days ago I downloaded the following:

  • Windows Azure Tools 1.7
  • Windows Azure SDK Preview for Visual Studio 2012 (June 2012)

I knew the Azure SDK was a preview, but some release notes made me believe it included the current version of the (stable) SDK for Visual Studio 2010.

After I uninstalled the preview and installed Windows Azure SDK for .NET (VS 2010 SP1) - June 2012, everything worked perfectly.

当梦初醒 2024-12-24 23:20:37

引用解决了我们遇到的问题,

我通过简单地添加对C:\Program Files\Microsoft SDKs\Windows Azure.NET SDK\2012-06\bin\runtimes\base\x86\msshrtmi.dll 的

它可能不适用于所有情况但值得一试。

I fixed the issue we were having by simply adding a reference to

C:\Program Files\Microsoft SDKs\Windows Azure.NET SDK\2012-06\bin\runtimes\base\x86\msshrtmi.dll

It probably wont work for all scenarios but is worth a try.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文