_From @davidfowl on Monday, July 24, 2017 8:28:43 AM_
See for details https://github.com/aspnet/Mvc/issues/6410.
There isn't an isolated repro yet.
_Copied from original issue: aspnet/DependencyInjection#555_
_From @xxjthxx on Friday, August 4, 2017 4:58:27 AM_
I can confirm we have this issue as well. I don't know if this is the solution, but I can say that refactoring helped for this instance. This exception is very troubling though as it crashes kestrel
Service with dependencies:
Controller
-- Service1
-- Service2
---- Service1
What helped is moving common code to a separate Service
Controller
-- Service1
---- Service3 (common methods from Service1)
-- Service2
---- Service3 (common methods from Service1)
_From @Eilon on Monday, August 7, 2017 2:30:24 PM_
@pakrym can you take a look?
_From @muratg on Tuesday, September 5, 2017 9:56:34 AM_
Could anyone provide an isolated repro app?
cc @alohaninja, @xxjthxx
_From @xxjthxx on Wednesday, September 6, 2017 12:03:55 PM_
@muratg as I said before, this is a bug we where experiencing on certain data and certain e2e test in our environment. Although the setup was very specific the bug was very real because it was consistently reproduced it with our data. We didn't find simple repro to send it to you unfortunately. As a last resort we switched to Autofac, which helped.
_From @davidfowl on Wednesday, September 6, 2017 11:42:33 PM_
This bug doesn't seem to have a high number of hits so it's likely something specific that the 2 reported applications are doing. We need more information before we can do anything else here.
_From @papaytl185 on Friday, October 6, 2017 2:05:49 PM_
We are also running into this issue now, we have a few services that inject a fairly large dependency tree of services. Whats strange is that it seems to run well in 32 bit mode but we do get the stack overflow every so often. Once I run it in 64 bit, the first request loads fine and brings back the page with no memory spike, then on the 2nd request, the memory spikes like crazy until it consumes everything on my machine.
I'm going to try autofac or simple injector to see if it helps.
If anyone has any ideas id appreciate it.
_From @pakrym on Friday, October 6, 2017 2:21:11 PM_
@papaytl185 can you please share a memory dump from when the process starts to grow memory to [email protected]. It might help us to diagnose the issue because we weren't able to get any repos until now.
_From @papaytl185 on Saturday, October 7, 2017 8:46:12 AM_
@pakrym the memory dump is going to be huge like 5 gb plus, if I cant get it to dump fast enough before it grows to 20gb, I can't email that.
Do you have another recommendation?
On a side note, I tried lightinject last night, finally got everything running, but it takes awhile to boot up to my login page. After I click login, the site just hangs. So I must have a dependency wrong or something somewhere, maybe the lifetime IDK.
While I was messing around with lightinject, I found a setting called AddControllersAsServices() which is part of IMvcBuilder. When I used this option with default microsoft dependency injection, the memory spiked to 4-5gb and then settled back down to 3ish without crashing my app. So maybe that can help others.
I still want to figure out why lightinject isn't working correctly and if my service dependencies are too big for microsoft dependency injection to see how lightinject handles it. Or if I have some singleton or other lifetime scope incorrect masking an issue somewhere..
_From @davidfowl on Saturday, October 7, 2017 9:44:44 AM_
When I used this option with default microsoft dependency injection, the memory spiked to 4-5gb and then settled back down to 3ish without crashing my app. So maybe that can help others.
@papaytl185 It might make sense to do a live debug session with you. That just sounds insane.
_From @papaytl185 on Saturday, October 7, 2017 11:44:18 AM_
@davidfowl that would be great, I could really use some help with this. How / when should we set this up? I could do a live assist with you and walk you through the startup etc.
_From @papaytl185 on Saturday, October 7, 2017 12:00:14 PM_
@davidfowl Does the attached DebugDiag memory analysis report help identify anything for you?
memorydump.pdf
_From @pakrym on Monday, October 9, 2017 9:16:31 AM_
@papaytl185 It definitely shows concerning amounts of Expression related data structures that are used to optimize DI operations.
_From @papaytl185 on Monday, October 9, 2017 11:16:59 AM_
Do you have any recommendations on what I should do?
_From @pakrym on Monday, October 9, 2017 11:43:45 AM_
Are you able to take timeline profile with dotTrace? It would show both memory allocation source and where time is spent during startup.
_From @papaytl185 on Monday, October 9, 2017 12:10:15 PM_
Ill try to use dotTrace, I keep trying to use visual studio to grab a snapshot but it crashes due to memory.
Some other tidbits.
It gets through the startup fine and I can load my home controller with just static html.
Using Microsoft Depedency Injection
Once I jump to my AccountController it spikes.
Using LightInject:
It loads my AccountController without a spike, however once I try to login to the application it does nothing and just hangs. As if its blocked, the console says User Authenticated and never continues..
It has to be the way I am registering something in DI? I know the below proabably wont help much without the entire context of code. But maybe you see something since I'm pulling at straws.
Images below also.
My account controller injects:
c#
private readonly ABSignInManager _signInManager;
private readonly ABUserManager _userManager;
private readonly ABRoleManager _roleManager;
private readonly IHostLogger _hostLogger;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IUrlPrefix _urlPrefix;
private readonly IDistributedCache _distributedCache;
And my startup registers:
container.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
container.AddScoped<ABHostContext>();
container.AddScoped<HostLogContext>();
container.AddScoped<HostEntityLockContext>();
container.AddScoped<DealerContext>();
container.AddScoped<DealerLogContext>(); //should result in a new context shared for the dealer log
container.AddScoped<DealerEntityLockContext>(); //should result in a new context shared for entity locks
//repository overrides
container.AddScoped<IHostRepository<Log>, HostLogRepository<Log>>();
container.AddScoped<IRepositoryAsync<Domain.Models.Dealer.Log>, DealerLogRepository<Domain.Models.Dealer.Log>>();
container.AddScoped<IRepositoryAsync<aEntityLock>, DealerEntityLockRepository<aEntityLock>>();
//Loggers
container.AddScoped<ISerilogFactory, SerilogFactory>();
container.AddScoped<IHostLogger, HostLogger>();
container.AddScoped<IHostLogService, BusinessLogic.HostServices.LogService>();
container.AddScoped<Serilog.ILogger, DealerLogger>();
container.AddScoped<IDealerLogService, BusinessLogic.DealerServices.LogService>();
container.AddScoped<IUrlPrefix, UrlPrefix>();
container.AddScoped<IDealerDocumentFolder, DealerDocumentFolder>();
container.AddScoped<IDealerEncryptionKey, DealerEncryptionKey>();
container.AddScoped<IDealerInfo, DealerInfo>();
container.AddScoped<IClaimsGenerator, ClaimsGenerator>();
//host services
container.AddScoped((provider) => Postal.Email.CreateEmailService(provider));
//Misc
container.AddScoped<IUtilityWrapper, UtilityWrapper>();
container.AddScoped<IHttpSessionManager, HttpSessionManager>();
container.AddScoped<IHttpHostContextWrapper, HttpHostContextWrapper>();
container.AddScoped<IHostConnectionStringService, HostConnectionStringService>();
container.AddScoped<IDealerConnectionStringService, DealerConnectionStringService>();
//container.AddSingleton(typeof(RedisHubLifetimeManager<>), typeof(RedisHubLifetimeManager<>));
//services.AddSingleton(typeof(HubLifetimeManager<>), typeof(RedisPresenceHublifetimeManager<>));
//services.AddSingleton(typeof(IUserTracker<>), typeof(RedisUserTracker<>));
container.AddScoped<ABSession>();
//add a forwarding registration that will allow us to request ISedonaOneSession and get the same object.
//We can slowly replace references to ABSession with ISedonaOneSession, once all direct references to
//ABSession are replaced we can provide a separate implementation for mobile that doesn't rely on HttpContext
container.AddScoped<ISedonaOneSession>(x => x.GetService<ABSession>());
container.AddScoped<IMessageBus, MessageBus>();
//Register Generic Repositories
container.AddScoped(typeof(IHostRepository<>), typeof(HostRepository<>));
//container.AddTransient(typeof(ITempDataRepository<>), typeof(TempDataRepository<>));
container.AddScoped(typeof(IRepositoryAsync<>), typeof(DealerRepository<>));
//Register Generic Services
container.AddScoped(typeof(IHostService<>), typeof(HostService<>));
container.AddScoped(typeof(IService<>), typeof(DealerService<>));
//Register Generic Manager
container.AddScoped(typeof(IValidator<>), typeof(SimpleValidator<>));
container.AddScoped(typeof(IConverter<,>), typeof(AutoConverter<,>));
container.AddScoped(typeof(IManager<,>), typeof(Manager<,>));
// Refresh token services
container.AddScoped<IRefreshTokenService, OpenIddictService>();`
Garbage collections is in like an infinite loop it looks like:
_From @papaytl185 on Tuesday, October 10, 2017 8:13:08 AM_
@davidfowl SimpleInjector works, keeps my memory around 1gb. Its crazy that there can be so many differences between containers. I also need to refactor my classes to use less dependencies and better follow SRP. I think that is the root cause. I have some classes with 10-15 injections.
_From @Eilon on Friday, October 13, 2017 10:36:09 AM_
@pakrym is there any further action for us to take here?
_From @pakrym on Friday, October 13, 2017 10:55:16 AM_
@Eilon there still no isolated repro or memory dump so not a lot of actionable items for now.
_From @Eilon on Friday, October 13, 2017 11:11:54 AM_
Ok we'll give it a few more days and close if we can't repro.
_From @papaytl185 on Friday, October 13, 2017 11:50:26 AM_
I can give someone a memory dump, just need to know how and where to upload a 5-6 GB file. On a side note, I finally ended up using the autofac extension with 3 lines of code and it works perfect. My app now runs at 600-700 MB, so there is something going on in Microsoft's dependency injection with large dependency graphs. I just don't know how to give you a repro without my project.
_From @pakrym on Friday, October 13, 2017 11:51:21 AM_
@papaytl185 You can use onedrive/dropbox and share a link via email
_From @papaytl185 on Friday, October 13, 2017 11:57:55 AM_
@pakrym Sounds good, I will start uploading the memory dump to my one drive account tonight. Once it finishes I'll send you an email with the link. Hopefully it helps, I grabbed the dump right when it started skyrocketing and snagged it at about 4.1 GB.
_From @pakrym on Thursday, October 19, 2017 3:20:31 PM_
@papaytl185 any luck with memory dump?
_From @Zoxive on Tuesday, January 2, 2018 9:13:38 AM_
@pakrym I can get you a memory dump. I am not a normal use case however. (Im in the slow process of converting a non dotnet core proj to dotnet core. Step one is staying on MVC 5 but swapping out Unity for DependancyInjection which is where I'm at) I'm having the similar symptoms but it only happens every other request.
Just like @alohaninja mentioned in https://github.com/aspnet/Mvc/issues/6410 if i comment out the magical Interlocked.Increment block (https://github.com/aspnet/DependencyInjection/blob/release/2.0.0/src/Microsoft.Extensions.DependencyInjection/ServiceProvider.cs#L92) it works fine.
Also I've tried recreating simpler project that reproduces it to no avail.
_From @pakrym on Tuesday, January 2, 2018 10:13:07 AM_
@Zoxive thank you for the memory dump. From the quick look it indeed shows very large System.Linq.Expressions.Expression<System.Func<Microsoft.Extensions.DependencyInjection.ServiceProvider, System.Object>>
with a lot of nesting. I'll investigate further.
_From @Zoxive on Tuesday, January 2, 2018 10:16:58 AM_
@pakrym let me know if you need anything else.
@zoxive
Looking at SO stack I can see GetRequiredService
call from RegisterEntityActionsAndServices.AnonymousMethod__3_1
, are you sure that it doesn't produce circular dependency?
Microsoft.Extensions.DependencyInjection.Abstractions.dll!Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService<Infor.Keystone.Runtime.Entities.Actions.Factories.EntityActionStepFactory>(System.IServiceProvider provider) Unknown
Infor.Keystone.Runtime.dll!Infor.Keystone.Runtime.Entities.EntitiesUnity.RegisterEntityActionsAndServices.AnonymousMethod__3_1(System.IServiceProvider ioc) Unknown
Microsoft.Extensions.DependencyInjection.dll!Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(Microsoft.Extensions.DependencyInjection.ServiceLookup.FactoryCallSite factoryCallSite, Microsoft.Extensions.DependencyInjection.ServiceProvider provider) Unknown
@pakrym
I'm sure. I've looked at it a bunch of times before resorting to compiling DependancyInjection myself and debugging from there.
Wouldn't I still be having a problem if I commented out
if (Interlocked.Increment(ref callCount) == 2)
{
Task.Run(() =>
{
Debug.WriteLine($"RealizeService.TaskRun {serviceType.ToGenericTypeString()}");
var realizedService = new CallSiteExpressionBuilder(_callSiteRuntimeResolver)
.Build(callSite);
provider.RealizedServices[serviceType] = realizedService;
});
}
As i said before when I remove those lines it all works fine. It also works fine on the 1st request, then the 2nd request overflows (When that line is NOT commented out).
@Zoxive Interlocked turns on compiled expression tree based service resolution for services requested multiple times and the bug seems to be somewhere in the tree generation its code, that why commenting it out fixes things.
Did you try running same app with 2.1 prerelease bits?
Does this bug repro if you run outside IIS? Kestrel for example.
@pakrym
Thanks for your help looking into this.
Using 2.1 which defaults to ServiceProviderMode.Dynamic same thing, every other request fails with a stackoverflow.
I switched it to Mode = ServiceProviderMode.Runtime and it works everytime.
Switching to Mode = ServiceProviderMode.Compiled fails everytime.
I also believe using 2.1 proves that i dont have circular dependencies? (https://github.com/aspnet/DependencyInjection/pull/592)
I dont think I can use Kestrel, the proj is 4.7 Full Framework (non dotnet core)
Yes, I don't think you have circular dependencies, the current theory is that you have pretty large service graph and we use stack space un-optimally when generating expression trees or during their compilation. I also suspect that there might be stricter memory limit inside IIS that's why I would like to try it outside IIS.
Kestrel runs fine on the full framework, it doesn't require core.
@pakrym
The service graph is quite large.
Heres another wrench in the issue.
I created a console app that registers all my services and calls the main service (That the web api proj blows up on) and it works fine.
I just forced my console app to use Mode = ServiceProviderMode.Compiled
And it just sits there eating CPU (memory barley moves about ~ 0.1 megs every few seconds)
The line its on is
CallSiteExpressionBuilder#68
BuildExpression(callSite).Compile();
@Zoxive can you privately share the app that forces issue to reproduce?
@pakrym Its a 50~ proj solution only half compiles.. during my IOC conversion..
Let me spend the next hour or so trying to re-create my dependency tree in a single proj I can share.
@Zoxive I was able to repro the issue when running in IIS, it fails around 810 services deep into tree generation process with service graph like S1->S2->....->S999
Correction, it fails in Expression compiler around 250 services deep.
So attempting to create a standalone app.
I created skeletons of my classes so they just have constructors with their dependencies.
Where I'm at right now i get a stackoverflow instantly no matter what ServiceProviderMode I select. So not quite the same behavior..
However I came across some of the weirdness carried over from our old IOC (Unity) where we resolve some things a Lazy<T>
I removed the 3 places we use it and its a circular reference. I'm going to see if i can remove the Lazy<T>
and the circular reference and see what happens. (In my console and then real app)
@pakrym transient? Does the scope matter? What does the method look like? Can you share the codez
None of my services are transient. The majority are Scoped with the remaining that can be are singletons. (However in my example proj all are scoped.. i generated the files via code..)
Regarding my previous Lazy<T>
note above, I had it setup wrong. (My lazy wasn't lazy..) Using Lazy<T>
to break circular dependency appears to work fine.
With that being said, i think i'm narrowing down the problem. I can reproduce it right now in my Single Proj even with the Lazy<T>
commented out.
I'll push this to github in a bit, see if i can narrow it down even more.
@pakrym
I believe this reproduces the problem I am seeing.
https://github.com/Zoxive/DependencyInjection/tree/zoxive/StackOverflow/test/ReproduceStackoverflow
@davidfowl scoped is generally the worst because it generates largest expressions.
Code: https://gist.github.com/pakrym/7fdee5a01a8b21776b0b4294b87bff94
@pakrym Is there anything else I can help with or provide to help debug this issue?
@Zoxive Thank you, I think we figured it out, the fix itself is not trivial so we are considering our options at the moment.
@pakrym Awesome. Is there a branch or anything I can use to use to make my own internal package for now? Otherwise I'll probably make an internal version of 2.1 with Runtime engine as the default.
No, there is none as of yet. Using runtime engine is fine, just be careful as might decrease the performance.
You can also try to increase w3wp stack size: https://blogs.msdn.microsoft.com/tom/2008/03/31/stack-sizes-in-iis-affects-asp-net/
@pakrym If it helps, at least for me, the stack overflow happens when I throw some custom Exception
and when it enters the catch
block of my custom error handler middleware (ApiErrorHandlerMiddleware
), the application dies.
I was able to reproduce the problem almost with the initial project setup, without any business or database logic, so feel free to give a look (Addapt.Parks.Central.zip). Just run the application and it will fail with a StackOverflowException
. The startup.cs:
public class Startup
{
private readonly DateTimeOffset _startedOn = DateTimeOffset.Now;
private readonly FileVersionInfo _fileVersionInfo;
public Startup(IConfiguration configuration)
{
Configuration = configuration;
var assemblyLocation = typeof(Startup).GetTypeInfo().Assembly.Location;
_fileVersionInfo = string.IsNullOrWhiteSpace(assemblyLocation)
? null
: FileVersionInfo.GetVersionInfo(assemblyLocation);
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddLocalization();
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en"),
SupportedCultures = new List<CultureInfo>
{
new CultureInfo("en"),
new CultureInfo("pt")
}
});
app.UseApiErrorHandler(new ApiErrorHandlerOptions
{
BasePath = null,
IndentJson = env.IsDevelopment(),
IncludeDeveloperDetails = env.IsDevelopment()
});
// added to reproduce the StackOverflowException
app.Run(ctx =>
{
// if the exception is custom it is sending a StackOverflowException
throw new Addapt.Parks.Central.Middleware.Exceptions.ValidationException(
"Forcing a StackOverflowException", new Dictionary<string, IReadOnlyCollection<string>>(0));
// but if instead is a core exception, it enters the ApiErrorHandlerMiddleware and
// the expected JSON is returned
//throw new InvalidOperationException("Forcing a StackOverflowException");
});
/*
app.UseMetadata(new MetadataOptions
{
Path = "_meta",
IndentJson = true,
Name = env.ApplicationName,
Environment = env.EnvironmentName,
StartedOn = _startedOn,
Version = new MetadataVersionOptions
{
Major = (uint) _fileVersionInfo.FileMajorPart,
Minor = (uint) _fileVersionInfo.FileMinorPart,
Patch = (uint) _fileVersionInfo.FileBuildPart,
Revision =(uint) _fileVersionInfo.FilePrivatePart,
Alias = _fileVersionInfo.ProductVersion
}
});
app.UseMvc();
//*/
}
}
@pakrym just ignore my previous comment...
It seams someone overloaded ToString()
in the custom exceptions and it was making a recursive and infinite loop when writing to the log. What a well passed morning looking at dump files...
@Zoxive can you please confirm that running with https://dotnet.myget.org/feed/aspnetcore-release/package/nuget/Microsoft.Extensions.DependencyInjection/2.1.0-preview2-30406 fixies your issue?
@pakrym Hmm when i tested the branch manually earlyer in the week i believe it worked. However getting that nugetpackage does not work.
The first couple requests work (I assume its using Runtime mode while compiling), then every following request fails.
Saying it failed to create a controller.
An error occurred when trying to create a controller of type 'EntityRecordsController'. Make sure that the controller has a parameterless public constructor
Doesn't seem like the same issue. Are you sure you didn't change the code?
No i think it is this.
Only happens when i switch to the new version, my branch which has "Runtime" mode hardcoded works fine.
I attached a debugger and it throws an IL exception.
```
Common Language Runtime detected an invalid program.
System.InvalidProgramException
at ResolveService(ILEmitResolverBuilderRuntimeContext , ServiceProviderEngineScope )
TargetSite
{System.Object ResolveService(ILEmitResolverBuilderRuntimeContext, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope)}
System.Reflection.MethodBase {System.Reflection.Emit.DynamicMethod.RTDynamicMethod}
@Zoxive do you see Common Language Runtime detected an invalid program.
in the repro you gave me before? I still see only SO there.
Yes in my reproduction repository linked above, I still see StackOverflow.
But due to myget issues i had to reference the project directly instead of using the nuget package.
(Myget.org Issue)
I can see the latest version in myget https://dotnet.myget.org/feed/aspnetcore-release/package/nuget/Microsoft.Extensions.DependencyInjection/2.1.0-preview2-30460 and in visual studio searching, but when trying to install, it fails. Microsoft.Extensions.DependencyInjection 2.1.0-preview2-30406 was not found. An approximate best match of Microsoft.Extensions.DependencyInjection 2.1.0-preview3-30379 was resolved.
I can confirm hitting https://dotnetmyget.blob.core.windows.net/artifacts/aspnetcore-dev/nuget/v3/flatcontainer/microsoft.extensions.dependencyinjection/index.json manually it does not show version 30460 or the older version 30406 you linked.
@pakrym / @muratg - is this a must-have for Preview2? If not, let's move to RC1.
Also, this issue is still tagged as 3-Done - does that need to be updated?
Started to get this problem with preview2.
With preview1 and before, never had this problem.
How can I set this "Runtime Mode" so I can test?
System.InvalidProgramException: JIT Compiler encountered an internal limitation.
at ResolveService(ILEmitResolverBuilderRuntimeContext , ServiceProviderEngineScope )
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
@stewshka what runtime are you using (.net core/.net framework?). Can you provide a repro?
@pakrym
.net core 2.1 preview2
I get the error on a big 50 project solution, with hundreds of services registered, I'm not sure how could I provide a way to reproduce.
Getting the error on VS debug and on the new dotnet preview2 docker alpine images.
Also compiled both from windows and the new dotnet sdk docker image.
The error happens only the third time I call GetServices on a few specific types.
I opened a separate issue for this: https://github.com/aspnet/Home/issues/3054
Small update on my end. I'm in the process of converting my solution to dotnet core + kestrel and the same error happens there as well.
System.InvalidProgramException: 'Common Language Runtime detected an invalid program.'
@Zoxive I tried your approach from above:
Using 2.1 which defaults to ServiceProviderMode.Dynamic same thing, every other request fails with a stackoverflow.
I switched it to Mode = ServiceProviderMode.Runtime and it works everytime.
Switching to Mode = ServiceProviderMode.Compiled fails everytime.
However the Mode on the Options object is internal and I cannot figure out anyway to set it in my project. I am upgrading a very large project from AspNetCore 1.1 to AspNetCore 2.0 and I am getting the SO error from the AspNetCore DI as discussed in this thread and other GitHub issues. I tried upgrading to the AspNetCore 2.1.1 nuget packages but the SO is still occurring.
Should this version of AspNetCore resolve the SO-DI issue?
@pakrym Any suggestions would be great as my team is getting stuck on this issue. Thank you.
An update to my comment above. We downloaded the Microsoft.Extensions.DependencyInjection 2.1.1 source and rebuilt it using the ServiceProviderMode.Runtime flag. We then hosted the nuget package locally and referenced it throughout our code. This appears to have fixed our StackoverflowException for the time being.
@pakrym Is there an ETA for a fix being provided in the official package? Thank you.
@ghawkescs I was doing the same, but found it easier for me to just set the mode via reflection.
// Workaround until this is resolved https://github.com/aspnet/Home/issues/2737
var type = options.GetType();
var propertyInfo = type.GetProperty("Mode", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
propertyInfo.SetValue(options, 1); // SET TO RUNTIME
@zoxive - Thank you, that would work for us too.
It's not clear what we'll be able to do in 2.2 milestone. Tentatively moving this to 3.0.
@Zoxive where are you doing that configuration? I'm running into this issue on a large project and I'd like to use the workaround you found.
@dbredvick
Inside UseDefaultServiceProvider() in Program.cs
//
.UseDefaultServiceProvider((context, options) =>
{
options.ValidateScopes = !context.HostingEnvironment.IsProduction();
// Workaround till they fix this https://github.com/aspnet/Home/issues/2737
var type = options.GetType();
var propertyInfo = type.GetProperty("Mode", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
propertyInfo.SetValue(options, 1); // SET TO RUNTIME
})
//
@pakrym it would be great if we could get some of these applications to test the new version of DI.
@davidfowl @pakrym I'll try it out Monday
@davidfowl @pakrym Tested Dynamic, Expressions and ILEmit with the preview packages briefly seems to be working.
So when this is finally released i can remove my forced "Runtime" mode!
Thanks!
Thanks for the work around Zoxive which seems to work.
It would be nice to know when v3 will be out of preview though
Most helpful comment
@dbredvick
Inside UseDefaultServiceProvider() in Program.cs