Comments (7)
Indeed i just checked and ServiceProvider
is internal
in 1.1.1.
I also checked Microsoft.Extensions.DependencyInjection
2.1.1 (net461, netstandard2.0), ServiceProvider
is public in this version, thus the disposal of the ServiceProvider can be trigger by user code.
I'm closing this issue as ServiceProvider lifetime management is not handled by this package.
from extensions-dependency-injection.
Both MVC and WebApi packages externalize the IServiceProvider
lifetime management to the user as the IServiceProvider
instance is injected by constructor. I checked the MVC/WebApi sample and noticed that the IServiceProvider
instance is not disposed, thus singleton are not disposed too.
You should indeed be able to get singleton instances disposed by adding the below code in Global.asax.cs file.
public void Application_End()
{
ServiceProviderConfig.ServiceProvider?.Dispose();
}
Could you please open a pull request to fix the sample ?
from extensions-dependency-injection.
ServiceProviderConfig.ServiceProvider?.Dispose()
doesn't work because IServiceProvider doesn't have Dispose()
.
Would it be better to change the type of ServiceProviderConfig.ServiceProvider
to ServiceProvider
?
Any solutions?
from extensions-dependency-injection.
As you suggested you could change the type of the property in the sample to be able to call Dispose method of the user provided instance of IServiceProvider.
from extensions-dependency-injection.
Actually I have tried it but it didn't work because the ServiceProvider
class didn't exist.
I think it because of the .NET Framework version of the sample projects are 4.5.2 and the using package version of Microsoft.Extensions.DependencyInjection is very old.
I'm sorry I don't have enough time to update all projects to the latest version and try it out.
from extensions-dependency-injection.
You need to install Microsoft.Extensions.DependencyInjection
to get acces to the ServiceProvider
type.
from extensions-dependency-injection.
Already installed it but the version is 1.1.1 because the packages.config of WebApi.Sample project references the very old version.
Microsoft.Extensions.DependencyInjection
of version 1.1.1 seems to not publish the ServiceProvider
class.
from extensions-dependency-injection.
Related Issues (8)
- Change the license
- Update samples and minimum target framework of packages to net461 as ServiceProvider disposal requires MS.Extensions.DependencyInjection 2.x HOT 1
- do not forget date in licence HOT 1
- Sonar and azure devops badges and nuget page link inside readme
- setup editorconfig file
- Cleanup samples
- Rename AF.Extensions.DependencyInjection.WebApi.Sample sample
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extensions-dependency-injection.