Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to resolve interface which is registered as Reuse.Scoped #673

Open
rrajeshkhunt opened this issue Dec 20, 2024 · 1 comment
Open

Comments

@rrajeshkhunt
Copy link

rrajeshkhunt commented Dec 20, 2024

I have registered one inteface as below to scope against each new request (http request).

registrator.RegisterMany(Reuse.Scoped);
I have interface ICurrentRequest which has implementation over CurrentRequest class.

I am trying to resolve above in my application using below code:
private readonly IServiceProvider _serviceProvider;
Consider _serviceProvider is getting initialized in constructor of application class
var currentHttpRequest= _serviceProvider.GetService();

Here i am not getting this and getting error like object reference not set to an instance of object. This is happening only for Reuse.Scoped, rest all like singelton or transient working fine.

I am getting this error only after upgrading to latest .Net 9 and latest DryIoc 6.2.0, earlier i was using .Net 6 & DryIoc 4.0.2 where it was working pefectly fine. It seems something has changed in DryIoc from 4.0.2 to 6.2.0 on handling Scoped.

Any help would be much appreciated as i am unable to find any such change documentation in release version.

@dadhi
Copy link
Owner

dadhi commented Dec 21, 2024

@rrajeshkhunt Could you provide the sample project or the Test reproducing the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants