ServiceProviderServiceExtensions.GetRequiredService 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.
Overloads
GetRequiredService(IServiceProvider, Type) |
Get service of type |
GetRequiredService<T>(IServiceProvider) |
Get service of type |
GetRequiredService(IServiceProvider, Type)
Get service of type serviceType
from the IServiceProvider.
public:
[System::Runtime::CompilerServices::Extension]
static System::Object ^ GetRequiredService(IServiceProvider ^ provider, Type ^ serviceType);
public static object GetRequiredService (this IServiceProvider provider, Type serviceType);
static member GetRequiredService : IServiceProvider * Type -> obj
<Extension()>
Public Function GetRequiredService (provider As IServiceProvider, serviceType As Type) As Object
Parameters
- provider
- IServiceProvider
The IServiceProvider to retrieve the service object from.
- serviceType
- Type
An object that specifies the type of service object to get.
Returns
A service object of type serviceType
.
Exceptions
There is no service of type serviceType
.
provider
has already been disposed.
Applies to
GetRequiredService<T>(IServiceProvider)
Get service of type T
from the IServiceProvider.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static T GetRequiredService(IServiceProvider ^ provider);
public static T GetRequiredService<T> (this IServiceProvider provider);
static member GetRequiredService : IServiceProvider -> 'T
<Extension()>
Public Function GetRequiredService(Of T) (provider As IServiceProvider) As T
Type Parameters
- T
The type of service object to get.
Parameters
- provider
- IServiceProvider
The IServiceProvider to retrieve the service object from.
Returns
A service object of type T
.
Exceptions
There is no service of type T
.
provider
has already been disposed.
Applies to
Povratne informacije
https://aka.ms/ContentUserFeedback.
Kmalu na voljo: V letu 2024 bomo ukinili storitev Težave v storitvi GitHub kot mehanizem za povratne informacije za vsebino in jo zamenjali z novim sistemom za povratne informacije. Za več informacij si oglejte:Pošlji in prikaži povratne informacije za