在一個項目中,我的要求是獲得天藍色的死亡信件數。如果計數大於0,那麼我必須得到每個死信的詳細信息,如死信的描述或原因,然後保存到cosmos數據庫中。 要獲得一紙空文計數我使用代碼:獲取天藍色的死亡信息並保存到宇宙數據庫中
NamespaceManager namespaceManager=Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(sbConnectionString);
var abc = namespaceManager.GetQueue("").MessageCountDetails;
var deadLetterCount = messageDetails.DeadLetterMessageCount;
,並保存到宇宙數據庫,代碼爲:
DocumentDBModel objItem = new DocumentDBModel();
objItem.DeadLetterReason = "TestReason";
objItem.DeadLetterDescription = "TestDescription";
objItem.DeadLetterDate = DateTime.Now;
objItem.Body = "TestBody";
DbSettings objSettings = new DbSettings();
objSettings.Uri = "";
objSettings.Key = "";
objSettings.DatabaseId = "TestDB";
objSettings.Collection = "TestCollection";
DocumentDBRepository<DocumentDBModel> abc = new
DocumentDBRepository<DocumentDBModel>(objSettings);
abc.CreateAsync(objItem).Wait();
但是當我運行上面的代碼,我本着讓例外:
var abc = namespaceManager.GetQueue("").MessageCountDetails;
<b> Method not found: 'Void System.Runtime.Serialization.DataContractSerializer..ctor(System.Type, System.Collections.Generic.IEnumerable`1<System.Type>, Int32, Boolean, Boolean, System.Runtime.Serialization.IDataContractSurrogate)'.
at Microsoft.ServiceBus.Messaging.MessagingDescriptionSerializer`1.CreateSerializer[T]()
at Microsoft.ServiceBus.Messaging.MessagingDescriptionSerializer`1..ctor()
at Microsoft.ServiceBus.Messaging.ServiceBusResourceOperations.GetAsyncResult`1..ctor(TrackingContext trackingContext, IResourceDescription[] collectionDescriptions, String[] collectionResourceNames, IEnumerable`1 managementAddresses, NamespaceManagerSettings settings, TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.NamespaceManager.OnBeginGetQueue(String path, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.NamespaceManager.GetQueue(String path)
at WebApplication2.Controllers.ValuesController.Get() </b>
請建議可能是什麼原因導致此問題。 - 列表項
Web應用程序中[WindowsAzure.ServiceBus](https://www.nuget.org/packages/WindowsAzure.ServiceBus/)的版本是什麼?您是否正在創建網絡核心Web應用程序,目標框架是什麼? –
我正在使用WIndowsAzure.ServiceBus版本2.1.0和框架是ASP.Net核心2.0 –