简体   繁体   English

生产中的Azure SDK 2.2:无法加载文件或程序集“msshrtmi”或其依赖项之一。 该系统找不到指定的文件

[英]Azure SDK 2.2 in Production: Could not load file or assembly 'msshrtmi' or one of its dependencies. The system cannot find the file specified

I have read about this problem on several other threads both on StackOverflow and other sites. 我已经在StackOverflow和其他站点上的其他几个线程上读到了这个问题。 None of the other solutions have solved my problem and most are outdated, referencing old versions of the Azure SDK. 其他解决方案都没有解决我的问题,而且大多数已经过时,引用了旧版本的Azure SDK。

I have a typical Azure website role deployed to Azure that uses Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener to log trace messages. 我有一个典型的Azure网站角色部署到Azure,使用Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener来记录跟踪消息。 When tracing occurs, it appears as though DiagnosticMonitorTraceListener is using the RoleEnvironment class, which in turn tries to load the apparently non-existent msshrtmi.dll . 当发生跟踪时,似乎DiagnosticMonitorTraceListener正在使用RoleEnvironment类,而后者又尝试加载显然不存在的msshrtmi.dll Here is a portion of the stack trace that is being logged to the file system in Azure: 以下是在Azure中记录到文件系统的堆栈跟踪的一部分:

[FileNotFoundException: Could not load file or assembly 'msshrtmi, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeEnvironment() +0
   Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment..cctor() +747

[TypeInitializationException: The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception.]
   Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.get_IsAvailable() +0
   Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.GetDefaultStartupInfoForCurrentRoleInstance() +23
   Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener..ctor() +34

[ConfigurationErrorsException: Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.]
   System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData) +9004943
   System.Diagnostics.TypedElement.BaseGetRuntimeObject() +110
   System.Diagnostics.ListenerElement.GetRuntimeObject() +989
   System.Diagnostics.ListenerElementsCollection.GetRuntimeObject() +252
   System.Diagnostics.TraceInternal.get_Listeners() +331
   System.Diagnostics.TraceInternal.WriteLine(String message) +161
   Microsoft.WindowsAzure.AzureApplicationSettings..ctor() +437
   Microsoft.WindowsAzure.CloudConfigurationManager.get_AppSettings() +137
   Microsoft.WindowsAzure.CloudConfigurationManager.GetSetting(String name) +27
   TankSoft.EverMarket.EverMarketPrereleaseRole.Endpoints.Api.Notify..ctor() +40
   lambda_method(Closure , Object[] ) +60
   Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +315

Various threads have mentioned how I need to clean this DLL from my bin folder, but the DLL is not being copied in the first place. 各种线程已经提到我需要如何从我的bin文件夹中清除这个DLL,但是首先没有复制DLL。 I suspect this has to do with me running under Azure SDK 2.2 and not 1.x. 我怀疑这与我在Azure SDK 2.2下运行而不是1.x有关。 I realize I can reference the DLL directly but I feel that I should not have to do this in order to deploy what is a quite normal project to Azure. 我意识到我可以直接引用DLL,但我觉得我不应该这样做,以便将一个非常正常的项目部署到Azure。 Why is Microsoft not automatically detecting that my project requires this file and deploying the correct file for me? 为什么Microsoft不会自动检测到我的项目需要此文件并为我部署正确的文件? This is maddening. 这令人抓狂。

Let me also say that the project I am publishing is not a Cloud Service but rather a regular Azure website project. 我还要说,我发布的项目不是Cloud Service ,而是一个常规的Azure网站项目。

Has anyone running Azure SDK 2.x managed to solve this issue? 运行Azure SDK 2.x的任何人都设法解决了这个问题吗? What were the exact steps you followed? 您遵循的具体步骤是什么?

This feels like a hack but it was the only way I could think of to solve this issue. 这感觉就像一个黑客,但这是我能想到解决这个问题的唯一方法。

  1. Open Configuration Manager for the solution 打开解决方案的Configuration Manager
  2. Select the Debug solution configuration 选择Debug解决方案配置
  3. Create a new solution platform for x64 为x64创建一个新的解决方案平台
  4. For each web role and worker role project, set the platform to x64 对于每个Web角色和辅助角色项目,将平台设置为x64
  5. Remove the Any CPU solution platform 删除Any CPU解决方案平台
  6. Make the same changes to the Release configuration 对Release配置进行相同的更改
  7. Add a reference to C:\\Program Files\\Microsoft SDKs\\Windows Azure\\.NET SDK\\v2.2\\bin\\runtimes\\base\\x64\\msshrtmi.dll 添加对C:\\Program Files\\Microsoft SDKs\\Windows Azure\\.NET SDK\\v2.2\\bin\\runtimes\\base\\x64\\msshrtmi.dll
  8. Set Copy Local on the new reference to True 在新引用上将Copy Local设置为True

配置管理器

EDIT : I ended up removing the code that was checking RoleEnvironment; 编辑 :我最终删除了检查RoleEnvironment的代码; instead, I'm relying on Web.config/App.config transforms to modify behavior at runtime. 相反,我依靠Web.config / App.config转换来修改运行时的行为。 This removes the dependency on msshrtmi.dll. 这消除了对msshrtmi.dll的依赖。

I encountered this same error when publishing a Web App. 发布Web App时遇到同样的错误。 After trying every other solution above, the following finally worked for me: 在尝试了上述所有其他解决方案后,以下内容最终对我有用:

In the Azure Portal, select your Web App. 在Azure门户中,选择您的Web App。 Select 'Settings > Application settings'. 选择“设置>应用程序设置”。 Change the Platform value from 32-bit to 64-bit. 将Platform值从32位更改为64位。 Re-publish. 重新发布。

I'm also using SDK 2.2 and deploying a website using Visual Studio 2013. In previous projects I had the following lines in my Postbuild event commandline: 我也使用SDK 2.2并使用Visual Studio 2013部署网站。在以前的项目中,我在Postbuild事件命令行中有以下几行:

cd $(OutDir)
del msshrtmi.dll

But this doesn't solve my problem anymore. 但这不再解决我的问题了。 The dll is not being copied into the bin folder anymore. dll不再被复制到bin文件夹中。

I have encounter the same problem. 我遇到了同样的问题。 I have Azure SDK 2.5 installed on my machine, but the project is created on SDK 2.2 and previously SDK 2.2 was installed. 我在我的机器上安装了Azure SDK 2.5,但该项目是在SDK 2.2上创建的,之前安装了SDK 2.2。 The problem is the SDK 2.2 is removed from GAC and its pointing to 2.5. 问题是SDK 2.2已从GAC中删除,并指向2.5。 Therefore, I referenced Microsoft.WindowsAzure.ServiceRuntime 2.2 and mark as "Copy to local=true", the Assembly has dependencies on "msshrtmi.dll", so i put postbuild event on my project. 因此,我引用了Microsoft.WindowsAzure.ServiceRuntime 2.2并标记为“Copy to local = true”,程序集依赖于“msshrtmi.dll”,所以我将postbuild事件放在我的项目上。 Therefore, "msshrtmi.dll" will be copied. 因此,将复制“msshrtmi.dll”。

Remember, you don't need to reference "msshrtmi.dll". 请记住,您不需要引用“msshrtmi.dll”。

I hope this will help. 我希望这将有所帮助。

I believe changing "For each web role and worker role project, set the platform to x64 & Remove the Any CPU solution platform" is not required. 我相信不需要更改“对于每个Web角色和辅助角色项目,将平台设置为x64并删除任何CPU解决方案平台”。

Important part is setting all the reffered Azure SDK assemblies and any 3rd party Dlls which are not part of .NET framework to mark them as CopyLocal = true; 重要的是设置所有引用的Azure SDK程序集和任何不属于.NET框架的第三方Dll,将它们标记为CopyLocal = true; This solved the problem for me. 这解决了我的问题。 And for more error information keep checking the Event Logs of Azure Virtual Machine under Azure Event section. 并且有关更多错误信息,请继续在Azure事件部分下检查Azure虚拟机的事件日志。 This will give you idea what could be possible reason for your build failure or any other unhandled errors while application startup. 这将使您了解在应用程序启动时可能导致构建失败或任何其他未处理错误的原因。

Uninstall all other versions of Azure SDK and make sure that you have the latest. 卸载所有其他版本的Azure SDK并确保您拥有最新版本。

This is a common conflict that makes Visual Studio reference part of the Microsoft.WindowsAzure.ServiceRuntime (in this case the msshrtmi.dll) to an older version of the SDK. 这是一个常见的冲突,使Visual Studio将Microsoft.WindowsAzure.ServiceRuntime(在本例中为msshrtmi.dll)的一部分引用到旧版本的SDK。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集或其依赖项之一。 该系统找不到指定的文件。 (不允许GAC) - Could not load file or assembly or one of its dependencies. The system cannot find the file specified. (No GAC allowed) 无法加载文件或程序集“ServiceStack”或其依赖项之一。 该系统找不到指定的文件 - Could not load file or assembly 'ServiceStack' or one of its dependencies. The system cannot find the file specified 无法加载文件或程序集“Logging.SNLLoggingStandard3”或其依赖项之一。 该系统找不到指定的文件 - Could not load file or assembly 'Logging.SNLLoggingStandard3' or one of its dependencies. The system cannot find the file specified 无法加载文件或程序集“Elmah”或其依赖项之一。 该系统找不到指定的文件 - Could not load file or assembly 'Elmah' or one of its dependencies. The system cannot find the file specified 无法加载文件或程序集的“扩展名”或其依赖项之一。 该系统找不到指定的文件 - Could not load file or assembly 'Extensions' or one of its dependencies. The system cannot find the file specified 无法加载文件或程序集“ Ajax”或其依赖项之一。 该系统找不到指定的文件 - Could not load file or assembly 'Ajax' or one of its dependencies. The system cannot find the file specified 具体:无法加载文件或程序集“xxxx”或其依赖项之一。 该系统找不到指定的文件 - A specific: Could not load file or assembly 'xxxx' or one of its dependencies. The system cannot find the file specified 无法加载文件或程序集“ XXX”或其依赖项之一。 该系统找不到指定的文件 - Could not load file or assembly 'XXX' or one of its dependencies. The system cannot find the file specified 无法加载文件或程序集“coba4”或其依赖项之一。 该系统找不到指定的文件 - Could not load file or assembly 'coba4' or one of its dependencies. The system cannot find the file specified 无法加载文件或程序集“路径”或其依赖项之一。 该系统找不到指定的文件 - Could not load file or assembly "path" or one of its dependencies. The system cannot find the file specified
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM