1
votes

I'm trying to use Azure service bus in a .net core 2.0 console application. I've installed the NuGet package and can see System.ServiceModel.Web in the SDK dependencies.

However when I try to add:

using System.ServiceModel;

I get an error stating it's not defined.

I found this tutorial online that does exactly the same: https://www.servicebus360.com/blogs/azure-service-bus-with-dot-net-core/

What am I missing

2
I'm confused; the blog page you linked to doesn't seem to contain the text "System.ServiceModel" so how did you reach the conclusion that it's doing "exactly the same" as what you're doing?Caius Jard
Apologies, they use Microsoft.Azure.ServiceBus, however it exhibits exactly the same problem when I try to add itkeitn
Did you check the log when you add the Microsoft.Azure.ServiceBus nuget package ?OrcusZ
Keitn, I think you may be right - that blog has some errors. The Microsoft.ServiceBus namespace is from the WindowsAzure.ServiceBus nuget pkg, not the one they tell you to add (Microsoft.Azure.ServiceBus). It also says "add using Microsoft.ServiceBus.Messaging to the top of your program.cs" and then posts the entire code of program.cs and it doesn't contain that line of code at all! I'd say, find another tutorial.. Or exercise some poetic license with the steps/dont follow it too closelyCaius Jard
guys, forgot about the tutorial, that was just an example of a similar project. The nuget package installed correctly. It's definitely there. I can do the same no problem when targeting .Net Framework 4.6keitn

2 Answers

2
votes

According to your description, I created my Net Core 2.0 console application to check this issue. As you said, the System.ServiceModel.Web.dll is provided by Microsoft.NETCore.App as follows:

enter image description here

Use ILSpy and check the Microsoft.NETCore.App 2.0.0 under C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0, there is no namespace for System.ServiceModel as follows:

enter image description here

Using Azure Service Bus in .Net core console app

For Net Core 2.0, I have referenced Microsoft.Azure.ServiceBus, and both V 1.0.0 and V 2.0.0 could work as expected as follows:

enter image description here

Moreover, for .Net Framework 4.6, you could only reference Microsoft.Azure.ServiceBus 1.0.0.

0
votes

Yes to get a .net core 2.0 console app working like from the blog [described above][1] https://www.servicebus360.com/blogs/azure-service-bus-with-dot-net-core/

You need to use Microsoft.Azure.ServiceBus nuget

I particularly liked his blog due to setting up the service bus via azure and instructions to newbies in the pub/sub architecture.