Q:

Get azure deadletter information and save into cosmos db

In a project, my requirement is to get count of  azure deadletter. If the count is greater than 0 then I have to get details of every dead letter message like description or reason of dead letter and save into cosmos db.
To get dead letter count I am using code:
NamespaceManager namespaceManager=Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(sbConnectionString);    
var abc = namespaceManager.GetQueue("").MessageCountDetails;        
var deadLetterCount = messageDetails.DeadLetterMessageCount;    

and save into  cosmos db, code is:    
 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();    

But when I run above code, I am getting exception in line:    
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>

Please suggest what can be the reason for this issue.
- List item

A:

As WindowsAzure.ServiceBus notes as follows:

Please note that this package requires .Net Framework 4.5.2 Full Profile.

Moreover, I could encounter the same issue as you mentioned when using WIndowsAzure.ServiceBus 2.1.0. Also, I have checked the other versions, but failed in the end.

For NetCore 2.0, you could leverage the .NET Standard client library for Azure Service Bus and reference the package Microsoft.Azure.ServiceBus. For retrieving the dead letter queues, you could follow this tutorial.

my requirement is to get count of azure deadletter. If the count is greater than 0 then I have to get details of every dead letter message like description or reason of dead letter and save into cosmos db.

I noticed that you handle this processing within a WebAPI endpoint. I would recommend you register the MessageReceiver.RegisterMessageHandler callback mentioned under DeadletterQueue/Program.cs, then implement it as the background task in .NET Core 2.x. Details you could follow here. 
Additionally, you could distribute this processing out from your web application. And you could leverage WebJob to trigger your servicebus deadletter queue (e.g. the deadletter queue name for a specific queue would look like: $"{your-queue-name}/$DeadLetterQueue") and use the DocumentDB binding to save deadletter queue information into your cosmos db. Details, you could refer to How to use Azure Service Bus with the WebJobs SDK and Azure WebJobs SDK Extensions.

