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

Dependency with a default (null) argument result in InvalidProgramException when targeting net6.0 #386

Closed
WGroenestein opened this issue Nov 23, 2021 · 1 comment
Assignees
Labels
Milestone

Comments

@WGroenestein
Copy link

When you have a dependency with a default (null) argument and have null injection enabled on the kernel, when targeting net6.0, it will throw an InvalidProgramException (Common Language Runtime detected an invalid program). On net5.0 it succeeds happily.

An example of a dependency with the scenario:

class ClassWithOptionalArgument
{
	public ClassWithOptionalArgument(string keyPrefix = null)
	{
		Console.WriteLine(keyPrefix);
	}
}

A full repro can be found here: Repro repo

@scott-xu
Copy link
Member

Thanks for reporting the issue. The bug is fixed. You can try it out from CI build: https://ci.appveyor.com/project/Ninject/ninject/builds/43200302/artifacts

@scott-xu scott-xu added this to the 3.3.5 milestone Apr 12, 2022
@scott-xu scott-xu self-assigned this May 29, 2022
@scott-xu scott-xu added the Bug label May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants