Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Azure服务总线-唯一受支持的隔离级别是';IsolationLevel.Serializable';_C#_Azure_Asp.net Web Api_Azureservicebus - Fatal编程技术网

C# Azure服务总线-唯一受支持的隔离级别是';IsolationLevel.Serializable';

C# Azure服务总线-唯一受支持的隔离级别是';IsolationLevel.Serializable';,c#,azure,asp.net-web-api,azureservicebus,C#,Azure,Asp.net Web Api,Azureservicebus,我正在尝试将消息推送到Azure服务总线上的某个主题,但当我这样做时,会出现以下异常: System.InvalidOperationException was unhandled by user code HResult=-2146233079 Message=The only supported IsolationLevel is 'IsolationLevel.Serializable'. Source=Microsoft.ServiceBus StackTrace:

我正在尝试将消息推送到Azure服务总线上的某个主题,但当我这样做时,会出现以下异常:

System.InvalidOperationException was unhandled by user code
  HResult=-2146233079
  Message=The only supported IsolationLevel is 'IsolationLevel.Serializable'.
  Source=Microsoft.ServiceBus
  StackTrace:
    Server stack trace: 
       at Microsoft.ServiceBus.Messaging.Sbmp.SbmpResourceManager.EnlistAsyncResult..ctor(SbmpResourceManager resourceManager, Transaction transaction, IRequestSessionChannel channel, SbmpMessageCreator messageCreator, Action`1 partitionInfoSetter, TimeSpan timeout, AsyncCallback callback, Object state)
       at Microsoft.ServiceBus.Messaging.Sbmp.SbmpResourceManager.BeginEnlist(Transaction transaction, IRequestSessionChannel channel, SbmpMessageCreator messageCreator, Action`1 partitionInfoSetter, TimeSpan timeout, AsyncCallback callback, Object state)
       at Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult`1.<>c__DisplayClass38.<GetAsyncSteps>b__32(TIteratorAsyncResult thisPtr, TimeSpan t, AsyncCallback c, Object s)
       at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
       at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.Start()
    Exception rethrown at [0]: 
       at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
       at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result)
       at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnEndSend(IAsyncResult result)
       at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
    Exception rethrown at [1]: 
       at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
       at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.RunSynchronously()
       at Microsoft.ServiceBus.Messaging.MessageSender.Send(TrackingContext trackingContext, IEnumerable`1 messages, TimeSpan timeout)
       at CryptoArb.Infrastructure.AzureStorage.ServiceBus.AzureServiceBusService.Send(String label, Object message)
我已经确保到服务总线的连接字符串是有效的,并且在尝试使用它们之前进行了检查以确保主题和订阅存在


为什么会出现异常?

调用Send方法的代码是否创建了TransactionScope?如果是,请确保isolotaionLevel设置为Serializable。

确保您不在其他事务下。 要将代码与它自己的隔离级别隔离,可以使用

using (var transaction = new TransactionScope(TransactionScopeOption.RequiresNew,
        new TransactionOptions {IsolationLevel = IsolationLevel.Serializable}))
{
    ...sending to the queue

    transaction.Complete();
}

不它不会创建TransactionScope。应该吗?谢谢你,抑制交易也是一种选择:)
using (var transaction = new TransactionScope(TransactionScopeOption.RequiresNew,
        new TransactionOptions {IsolationLevel = IsolationLevel.Serializable}))
{
    ...sending to the queue

    transaction.Complete();
}