【问题标题】:Azure SDK Storage assembly not found exception when publishing发布时未发现 Azure SDK 存储程序集异常
【发布时间】:2016-09-10 07:57:57
【问题描述】:

我尝试使用云服务和 Azure SDK 2.9 将演示应用程序发布到 Windows Azure。在我的服务中,我有一个 Web 角色和一个 Worker 角色。两者都使用 Azure 存储。在本地主机(模拟器)上一切正常,但是当我尝试发布应用程序时,我在 Web 角色上收到以下错误:

未处理的异常:System.Runtime.Serialization.SerializationException,
详细信息:异常:无法找到程序集 'Microsoft.WindowsAzure.Storage, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf385)

在 Worker Role 项目中一切正常,它也在使用存储。

我尝试将 Web 角色转换为标准 Web 应用程序,一切正常,但我想在云应用程序上解决此问题。

我尝试过的:

  • 在对 true 的引用中设置本地副本
  • 将 .Net Framework 更改为 4.5.1 和 4.6(默认 4.5)
  • 再次删除并添加了对存储的引用
  • 通过 nuget 重新安装了所有库
  • 随 Storage 7.0 和 6.2 发布
  • 由 VS 和门户网站(包)发布
  • 在 web.config 中添加了dependentAssembly

在我的 VM 上,我检查了 bin 文件夹,Microsoft.WindowsAzure.Storage 存在。

有什么想法吗?

【问题讨论】:

标签: c# asp.net .net azure azure-storage


【解决方案1】:

两天后,我找到了解决该问题的方法。 在我的 WebRole.cs 我有这个:

public override bool OnStart()
{
    var csa = CloudStorageAccount.Parse(RoleEnvironment
        .GetConfigurationSettingValue("Credentials"));
    var cqc = csa.CreateCloudQueueClient();
    var inputQueue = cqc.GetQueueReference("inputqueue");
    inputQueue.CreateIfNotExists();
    var outputQueue = cqc.GetQueueReference("outputqueue");
    outputQueue.CreateIfNotExists();
    var ctc = csa.CreateCloudTableClient();
    var ct = ctc.GetTableReference("last");
    ct.CreateIfNotExists();
    return base.OnStart();
}

当我将此初始化移动到其他地方时,例如到 RouteConfig.cs 一切正常。我不知道为什么,但从 WebRole 对存储的每次引用都会在发布到 Azure 后引发错误。 我希望这个解决方案有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-24
    • 1970-01-01
    • 2021-01-18
    • 1970-01-01
    • 2013-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多