Skip to content
christophersnay.com

christophersnay.com

  • Home
  • Education
  • Experience
  • Projects
  • Code Snippets
  • Error Messages
Posted on January 17, 2020January 17, 2020 by admin

Resolve dependencies manually in .NET Core

var serviceProvider = services.BuildServiceProvider();
using (var scope = serviceProvider.CreateScope())
{
    var app = serviceProvider.GetRequiredService<ISomeInterface>();
    app.SomeMethod();
}
CategoriesCode Snippets Tags.NET Core, ASP.NET, C#, Dependency Injection

Post navigation

Previous PostPrevious Display total lines of code in a git branch
Next PostNext Startup.cs example for .NET Core API w/ Swagger

Tags

  • .NET Core
  • Android
  • Android Studio
  • Angular
  • API
  • Arduino
  • ASP.NET
  • Bitbucket
  • C#
  • cmd
  • CORS
  • curl
  • Dependency Injection
  • Elasticsearch
  • Entity Framework
  • Error
  • Flask
  • GAC
  • git
  • HTTPS
  • IIS
  • Java
  • Jeep
  • JSON
  • Linq
  • Linux
  • Moq
  • MySQL
  • Node.js
  • npm
  • Pattern
  • pip
  • PowerShell
  • Projects
  • Python
  • Raspberry Pi
  • Raspbian
  • SOLID
  • sqlite
  • SSH
  • Swagger
  • Unity
  • Unreal Engine
  • Website
  • Windows
  • facebook
  • twitter
  • linkedin
  • gmail
Proudly powered by WordPress