Questions tagged [iserviceprovider]

7 questions
1
vote
1 answer

ServiceProviderServiceExtensions.GetRequiredService may not be used in setup and verification expressions

How to inject dependency for ServiceProvider in xUnit used for injecting cache object. xUnit gives the below error ServiceProviderServiceExtensions.GetRequiredService may not be used in setup / verification expressions.
Dev-lop-er
  • 578
  • 1
  • 7
  • 16
1
vote
1 answer

Instance of RoleManager/IServiceProvider in .NET 7 Blazor

In .NET Core 3.1, we were able to create roles on startup like this: public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider) { CreateRoles(serviceProvider).Wait; } private async Task…
user3656651
  • 619
  • 1
  • 9
  • 25
1
vote
0 answers

.NET Core - Apply Multiple Constructor Discovery Rules in Implementation Factory

I am working with c# and .NET Core 3.1, and I have a class that looks like this. public class MyClass : IMyClass { public MyClass() { … } public MyClass(IDependency dependency) { … } public…
0
votes
1 answer

C# IServiceProvider and Dependency Injection ambiguous interface

I would like to use Microsoft's dependency injection extension to achieve DI. I have created a simple console application to test out my understanding. I have 2 objects, Dog and Cat both have a interface IAnimal. Very simple setup. I wanted to use…
0
votes
0 answers

I have d365 database and mysql database and need to make this as a generic but the catch is that the attributes names are not same in both database

` using (var s = webRequest.GetResponse().GetResponseStream()) { using (var sr = new StreamReader(s)) { var entitydatafromMysql = sr.ReadToEnd(); string bsObj2 =…
Jdz777
  • 1
  • 1
0
votes
0 answers

Error in markup extension due to missing IXamlTypeResolver service in Design mode

The markup extension uses the IXamlTypeResolver service to convert a TypeName string to a CLR Type. But in design mode, IServiceProvider does not return this service. Because of this, errors occur in the XAML Editor window and the Designer does not…
EldHasp
  • 6,079
  • 2
  • 9
  • 24