unitycontainer / microsoft-dependency-injection

Unity.Microsoft.DependencyInjection package
Apache License 2.0
63 stars 36 forks source link

IServiceProvider gets disposed #48

Closed weng271190436 closed 5 years ago

weng271190436 commented 5 years ago

If I use Unity as my default DI container (by UseUnityServiceProvider()) and I call Url.Link() in a controller action twice, it is going to say: System.ObjectDisposedException: 'Cannot access a disposed object. Object name: 'IServiceProvider'.'

I have a simple repro here: https://github.com/weng271190436/unityrepro/blob/master/WebApplication1/Controllers/ValuesController.cs

Start the .NET Core 2.2 web application. If you hit localhost:5001/api/values for the first time, you will get a response. If you hit that url the second time, you will see the ObjectDisposedException error.

Hieronymus1 commented 5 years ago

This is a known issue that is still open.

weng271190436 commented 5 years ago

I thought that version 5.10.2 is supposed to work around this problem? My simple repro is using 5.10.2 but it still hits this problem.

ENikS commented 5 years ago

5.10.1 has workaround

Closing as duplicate of #40

adrianpetrescu commented 5 years ago

@ENikS Indeed, using 5.10.1, you can no longer repro this issue but if you are using version 5.10.1 together with any version of Unity.Interception ASP.NetCore website fails starting. I mean of course to the usage of .UseUnityServiceProvider(). Is this also a known issue?

adrianpetrescu commented 5 years ago

In the end I managed troubleshooting this downgrading Unity.Interception to 5.10.0