![](/img/trans.png)
[英]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
[英]Could not load file or assembly 'msshrtmi, The system cannot find the file specified
我正在尝试将Windows Azure网站从云降级到网站。 我收到此错误:
无法加载文件或程序集'msshrtmi,Version = 1.7.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 该系统找不到指定的文件。
[FileNotFoundException:无法加载文件或程序集'msshrtmi,Version = 1.7.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 该系统找不到指定的文件。]
Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeEnvironment()+0 Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment..cctor()+546[TypeInitializationException:'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment'的类型初始值设定项引发异常。
Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(String configurationSettingName)+0
AzureInit.AzureHelper_GetApplicationSettings(String key)+28[HttpException(0x80004005):'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment'的类型初始值设定项引发异常。]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context,HttpApplication app)+9859725
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext,HttpContext context,MethodInfo [] handlers)+118
System.Web.HttpApplication.InitSpecial(HttpApplicationState状态,MethodInfo []处理程序,IntPtr appContext,HttpContext上下文)+172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,HttpContext context)+336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)+296[HttpException(0x80004005):'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment'的类型初始值设定项引发异常。] System.Web.HttpRuntime.FirstRequestInit(HttpContext context)+9873912
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context)+254
因为我不在云中,我需要这个程序集吗? 我如何告诉网站不要寻找它? 我已将这些引用添加到我的项目中:
Microsoft.WindowsAzure.CloudDrive Microsoft.WindowsAzure.Diagnostics Microsoft.WindowsAzure.ServiceRuntime Microsoft.WindowsAzure.StorageClient
在我的WorkerRole.cs类中,这是我的代码:
/// <summary>
/// Reads settings from service configuration file.
/// </summary>
/// <param name="key">Setting key.</param>
string AzureHelper_GetApplicationSettings(string key)
{
try
{
return RoleEnvironment.GetConfigurationSettingValue(key);
}
catch
{
// Setting key was not found
return null;
}
}
删除这些引用(以及它们附带的所有代码):
这些程序集的大多数功能仅用于云服务(Web /工作者角色)。
现在您看到的错误似乎与阅读配置有关:
Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(String configurationSettingName) +0
AzureInit.AzureHelper_GetApplicationSettings(String key) +28
请考虑更改AzureHelper_GetApplicationSettings中的代码以使用Microsoft.WindowsAzure.ConfigurationManager NuGet包。 这允许您在ServiceConfiguration.cscfg和Web.config(AppSettings)之间自动切换。 如果RoleEnvironment.IsAvailable(= Cloud Service),它将从ServiceConfiguration.cscfg中读取。 如果不是(=网站/虚拟机/内部部署),它将从AppSettings中读取。 但是,如果部署到网站,则需要将以前在ServiceConfiguration.cscfg中的设置添加到web.config中的appSettings中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.