.net - 如何跟踪尝试为监听器设置 Azure 接收器时的异常来源

标签 .net azure azure-table-storage semantic-logging slab

我正在尝试使用语义日志记录应用程序 block 将日志存储到Azure 表存储中。设置:

ObservableEventListener listener1 = new ObservableEventListener();
var conString =
    $"DefaultEndpointsProtocol={CloudStorageAccount.DevelopmentStorageAccount.TableEndpoint.Scheme};" +
    $"AccountName={CloudStorageAccount.DevelopmentStorageAccount.Credentials.AccountName};" +
    $"AccountKey={Convert.ToBase64String(CloudStorageAccount.DevelopmentStorageAccount.Credentials.ExportKey())}";
    
listener1.LogToWindowsAzureTable( // <---- EXCEPTION HERE
        instanceName: "instName",
        connectionString: conString);

我遇到了一个奇怪的异常:

Exception thrown: 'System.MissingMethodException' in Microsoft.Practices.EnterpriseLibrary.SemanticLogging.WindowsAzure.dll

Additional information: Method not found: 'Void Microsoft.WindowsAzure.Storage.Table.CloudTableClient.set_RetryPolicy(Microsoft.WindowsAzure.Storage.RetryPolicies.IRetryPolicy)'.

我的真实账户也有同样的问题。软件包版本(全部来自 NuGet):

  • EnterpriseLibrary.SemanticLogging — 2.0.1406.1
  • EnterpriseLibrary.SemanticLogging.WindowsAzure — 2.0.1406.1
  • WindowsAzure.Storage — 7.0.0

如何跟踪异常的来源?Google 对于未找到的方法只字不提。在您的机器上测试的项目是 here .

最佳答案

您收到此错误的原因是 SLAB 依赖于存储客户端库 3.0.2.0 ( source ) 并在客户端 (CloudTableClient 例如)在版本 4.0.0.0 ( source ) 中已弃用,并在某些更高版本中删除(不确定是哪一个)。

由于您使用的是 7.x 版存储客户端库,因此在 CloudTableClient 上设置 RetryPolicy 的方法不存在,因此您会收到此错误。

关于.net - 如何跟踪尝试为监听器设置 Azure 接收器时的异常来源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38141018/

相关文章:

.net - 使用 .NET 在慢速网络中移动不同大小文件的最佳方法

c# - Azure 使用 C# 实现具有多种方法的单个 HTTP 触发器

c# - 使用 NoAutomaticTrigger 时 Azure WebJobs SDK 中的依赖注入(inject)?

c# - 从 Azure 表存储检索超过 100 万条记录

c# - 如何从 Zebra 收据打印机回读状态?

c# - 您更喜欢哪种方法签名,为什么?

c# - 参数化 SQL 查询

azure - 单个网络作业中有多个触发器

azure - 如何从Azure表存储api调用获取x-ms-request-id

Azure SQL 数据库与表存储的 session 状态