By using this site, you acknowledge that you have read and understand our Cookie policy, Privacy policy and Terms .
close

About C# Programming Language: features, and syntax and so on.

rss_feed Subscribe RSS

.NET Core is built in with dependency injection. Usually method ConfigureServices in Startup class is used to register services in the container.

The signature of the method looks like the following:

public void ConfigureServices(IServiceCollection services)
{

}

Sometimes it may be necessary to instantiate a service in this function. To do that, you can use the following method:

var sp = services.BuildServiceProvider();
var dbConfig = sp.GetService<IOptions<DatabaseConfig>>().Value;

In the above example, the BuildServiceProvider function is invoked to create a service provider object which then is used to get service.

info Last modified by Raymond at 2 years ago * This page is subject to Site terms.

info About author

More from Kontext

Machine Learning with .NET in Jupyter Notebooks

local_offer machine-learning local_offer jupyter-notebook local_offer C# local_offer dotnet core

visibility 172
thumb_up 0
access_time 2 months ago

In this article, I'm going to show you how to install Jupyter in Windows and then install .NET kernel for Jupyter notebooks. It also shows a machine learning example using ML.NET. The target audience are .NET developers who want to expand their skills in data engineering and science domain...

open_in_new View

local_offer lite-log local_offer spark local_offer pyspark

visibility 1538
thumb_up 0
access_time 8 months ago

When creating Spark date frame using schemas, you may encounter errors about “field **: **Type can not accept object ** in type &lt;class '*'&gt;”. The actual error can vary, for instances, the following are some examples: field xxx: BooleanType can not accept object 100 in type ...

open_in_new View

local_offer lite-log local_offer hive

visibility 801
thumb_up 0
access_time 11 months ago

Since Hive 3.x, new authentication feature for HiveServer2 client is added. When starting HiveServer2 service (Hive version 3.0.0), you may encounter errors like: ‘HiveServer2 metastore.RetryingMetaStoreClient: RetryingMetaStoreClient trying reconnect as [username]&nbsp; (auth:S...

open_in_new View

local_offer lite-log local_offer linux local_offer WSL local_offer ubuntu

visibility 1612
thumb_up 0
access_time 10 months ago

This page shows how to install Windows Subsystem for Linux (WSL) system on a non-system drive manually. Enable Windows Subsystem for Linux system feature Open PowerShell as Administrator and run the following command to enable WSL feature: Enable-WindowsOptionalFea...

open_in_new View

Kontext Column

Kontext Column

Created for everyone to publish data, programming and cloud related articles. Follow three steps to create your columns.

Learn more arrow_forward
info Follow us on Twitter to get the latest article updates. Follow us