jbogard / MediatR.Extensions.Microsoft.DependencyInjection

MediatR extensions for Microsoft.Extensions.DependencyInjection
MIT License
327 stars 90 forks source link

Unable to register MediatR on .NET Framework 4.8 and Windows Forms project #125

Closed jcuello closed 1 year ago

jcuello commented 1 year ago

I was able to successfully install both MediatR and MediatR.Extensions.Microsoft.DependencyInjection for a Windows Forms and .NET 4.8 project written in VB.NET.

My problem is that when I try to use IServiceCollection.AddMediatR(Assembly) when setting up my services, that method is not found. Is it because I'm using VB.NET? I thought that .NET Framework 4.8 is compatible with the .NET Standard 2.0 and therefore I shouldn't have any issues.

jbogard commented 1 year ago

No, nothing to do with VB.NET. I've never used MediatR in Windows Forms (and I would be suuuuuuper careful if you mix MediatR and UI interactions. In fact, probably don't.).

The last version of MediatR that supports .NET Standard 2.0 is version 9.0. Check that first. Next, that extension method is in the MediatR namespace. Make sure that's in your Imports statements.

jcuello commented 1 year ago

I did install version 9.0 for both packages and Visual Studio's Intellisense did not pop up with the AddMediatR extension method. I had a simple windows form app running on .NET Core 6 to test it out and it was able to detect it so I figured it should work with .NET 4.8.

I think I'm going to take your advice and not use MediatR for this project, main reason I wanted to use it was to have commands that interact with UI components when a form needed to communicate with a different form. And as you mentioned this is not a good idea.

Thank you for quickly responding to my issue, I'll close this ticket unless you are curious to see what's going on. :)