I'm developing an application that runs on AutoCAD using .NET Framework 4.8 and Npgsql, following the MVVM pattern. In my project, I use Dependency Injection (DI) to manage the lifecycle of objects through Microsoft.Extensions.DependencyInjection. However, when I use this DI framework, I encounter a conflict and receive the following error:
Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral...'
If I remove Microsoft.Extensions.DependencyInjection, the program runs fine. I would like to know if there's a way to continue using DI in my project while ensuring Npgsql works without issues. I've also tried using Autofac for DI, but I encountered a similar error.
I also tried follow this answer but not working
I tried binding like this:
<dependentAssembly>
<assemblyIdentity
name="System.Threading.Tasks.Extensions"
publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect
oldVersion="0.0.0.0-4.2.0.0"
newVersion="4.2.0.0" />
</dependentAssembly>
but it's not working.
Is there a solution to this problem?
I still want to use Dependency Injection (DI) and Npgsql. Is there a way to use both without causing conflicts or encountering the error Could not load file or assembly ?'System.Threading.Tasks.Extensions, Version=4.2.0.0 Culture=neutral