gpt4 book ai didi

c# - 无法加载文件或程序集“msshrtmi”,系统找不到指定的文件

转载 作者:行者123 更新时间:2023-11-30 15:01:38 25 4
gpt4 key购买 nike

我正在尝试将 Windows Azure 站点从云降级为网站。我收到此错误:

Could not load file or assembly 'msshrtmi, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

[FileNotFoundException: Could not load file or assembly 'msshrtmi, Version=1.7.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() +546

[TypeInitializationException: The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception.]
Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(String configurationSettingName) +0
AzureInit.AzureHelper_GetApplicationSettings(String key) +28

[HttpException (0x80004005): The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception.]
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 state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception.] 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.CloudDriveMicrosoft.WindowsAzure.诊断Microsoft.WindowsAzure.ServiceRuntimeMicrosoft.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;
}
}

最佳答案

删除这些引用(以及它们附带的所有代码):

  • 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 中读取。如果不是(= 网站/虚拟机/本地),它将从 AppSettings 中读取。但是,如果您部署到网站,则需要将 ServiceConfiguration.cscfg 中的设置添加到 web.config 中的 appSettings

关于c# - 无法加载文件或程序集“msshrtmi”,系统找不到指定的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13938504/

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