rebus-org / Rebus.AzureServiceBus

:bus: Azure Service Bus transport for Rebus
https://mookid.dk/category/rebus
Other
33 stars 20 forks source link

.Net Core assembly does not support System.Configuration.ConfigurationManager #7

Closed KennethJakobsen closed 6 years ago

KennethJakobsen commented 6 years ago

I'm Using rebus in a core console app and when ever I try to use the following code i get an exception Configure.With(new BuiltinHandlerActivator()) .Transport(configurer => configurer.UseAzureServiceBusAsOneWayClient( "Endpoint=sb://dev.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=[key]")) .Routing(r => r.TypeBased() .MapAssemblyOf<CreatePrivateProjectCommand>(Constants.Queues.WorkInput)) .Start();

Exeception: System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.' This is simply because the Configuration Manager does not exist in Core Also I recognize the simple convenience, but I don't think it should be the responsibility of Rebus to go find configurations.

mookid8000 commented 6 years ago

What do I do to reproduce this?

Create a .NET Core console application, and then change the target to full .NET fx?

KennethJakobsen commented 6 years ago

I just created a .net core console app and installed rebus, and used the code above.

mookid8000 commented 6 years ago

It makes no sense.

I can reproduce it by creating a .NET Core 2 console application.

The Rebus NuGet package can be installed, because it contains DLLs targeting .NET Standard 1.3 and .NET 4.5.

But the Rebus.AzureServiceBus package only targets .NET 4.5, which in my understanding should mean that only FULL .NET frameworks are targeted:

image

But apparently it is still possible to import the package into a .NET Core 2 application, and of course it then breaks because there's no System.Configuration DLL available.

mookid8000 commented 6 years ago

Hmm.... I think I might be getting closer to something now..... when you create a project for .NET Core 2, it seems to accept it when you install a NuGet package that does not target .NET Core at all. 😱

This might be because .NET Core 2 i supposed to be compatible with .NET 4.6.1 or something, at least according to the table on this page. πŸ€”

So I went and created a new .NET Core 2 console application, and then I installed WindowsAzure.ServiceBus into it.

If I then call something on the NamespaceManager (pretty central entity in the Azure Service Bus driver model), I get this:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
   at Microsoft.ServiceBus.Messaging.Configuration.KeyValueConfigurationManager.CreateNameValueCollectionFromConnectionString(String connectionString)
   at Microsoft.ServiceBus.Messaging.Configuration.KeyValueConfigurationManager.Initialize(String connection, Nullable`1 transportType)
   at Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(String connectionString)
   at ConsoleApp5.Program.Main() in c:\temp\ConsoleApp5\Program.cs:line 22

Poking around in Visual Studio, I noticed this:

image

which I guess is Visual Studio's way of saying "you're lucky if it works, but don't count on it". 😐


Conclusion at this point: It (still) doesn't seem like the old Azure Service Bus driver supports .NET Core. This is probably also the reason why Microsoft created the new driver.

The new driver just happens to represent a huge departure from the old driver's model, both because queue and topic management can no longer be done using the driver, but also because it insists on working in a more framework-like manner (i.e. it uses callbacks to process received messages and does not support the previous poll-to-receive way of receiving messages).

If there's any way you can use the full .NET framework, I suggest you do that. Otherwise, maybe you can move your code to AWS and use Rebus with Amazon SQS – Amazon has been kind enough to port their driver to .NET Standard 1.3, making it available anywhere you can think of 😁

mookid8000 commented 6 years ago

Btw., if anyone is interested in updating Rebus.AzureServiceBus to use the new driver, it would be cool. I would of course help as much as possible, but at the moment I don't have the time to do it myself.

KennethJakobsen commented 6 years ago

Alright I’m moving to framework, I would love to help out with the new ASB implementation later, but like you I don’t have the time right now