无法加载文件或程序集'msshrtmi',系统找不到指定的文件。

3
我正在尝试将Windows Azure网站从云降级为网站。我收到以下错误信息:
“找不到文件或程序集“msshrtmi,Version=1.7.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其中一个依赖项。系统无法找到指定的文件。”
因为我不在云端,所以我需要这个程序集吗?如何告诉网站不要寻找它?我已经将以下引用添加到我的项目中:
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;
    }
}
1个回答

5

删除以下引用(以及随之而来的所有代码):

  • Microsoft.WindowsAzure.CloudDrive
  • Microsoft.WindowsAzure.Diagnostics
  • Microsoft.WindowsAzure.ServiceRuntime

这些程序集的大部分功能只适用于云服务(Web/Worker角色)。

现在你看到的错误似乎与读取配置有关:

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中读取。如果不是(=Web Site / Virtual Machines / On-Premises),则会从AppSettings中读取。但如果您部署到Web Sites,则需要将以前在ServiceConfiguration.cscfg中的设置添加到web.config中的appSettings中。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接