NamedServiceProviderExtensions.GetRequiredService<TService> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Get service of type TService
from the INamedServiceProvider<TService>.
public:
generic <typename TService>
where TService : class[System::Runtime::CompilerServices::Extension]
static TService GetRequiredService(Microsoft::Extensions::DependencyInjection::INamedServiceProvider<TService> ^ provider, System::String ^ name);
public static TService GetRequiredService<TService>(this Microsoft.Extensions.DependencyInjection.INamedServiceProvider<TService> provider, string name) where TService : class;
static member GetRequiredService : Microsoft.Extensions.DependencyInjection.INamedServiceProvider<'Service (requires 'Service : null)> * string -> 'Service (requires 'Service : null)
<Extension()>
Public Function GetRequiredService(Of TService As Class) (provider As INamedServiceProvider(Of TService), name As String) As TService
Type Parameters
- TService
The type of service object to get.
Parameters
- provider
- INamedServiceProvider<TService>
The INamedServiceProvider<TService> to retrieve the service object from.
- name
- String
The name of the service.
Returns
TService
A service object of type TService
.
Exceptions
There is no service of type TService
with the name.
Remarks
This method returns the latest TService
registered under the name.
Applies to
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.