DryIoc: System Invalid program exception when removing dependency

Hi…

We just ran into an issue that when we remove single dependency from services constructor it causes Invalid program exception runtime. It happens after resolving the type twice. First time it goes through then it fails when executing compiled expression with message

System.InvalidProgramException: 'Common Language Runtime detected an invalid program.'

Its strange because it works if the dependency is there… but fails without it 😕

We are using DryIoc 4.0.7 but I tested upgrading to 4.1.4 and it did not resolve the issue.

I’m trying to reproduce it but its non-trivial due to so long dependency chains…

We are using DryIoc WithoutFastExpressionCompiler option

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 59 (59 by maintainers)

Commits related to this issue

Most upvoted comments

@Havunen DryIoc v4.2 is out!

Hi @Havunen

Update on this issue:

I’ve added a more customizable expression dump to code in #268 and tested it on ReducedLoadTest.

Here is the dump in VSCode collapsed:

image

I’ve spent some time on this, but at least now I can see the shape of the expressions we deal with. Here the types are abbreviated for brevity. There are 2 nested lambdas marked with /*$*/ and the whole thing spans 100 000 lines and has 20000+ constants. Some constructors have up to 50 arguments.

I am not sure what to do with the #265 here… so work-in-progress

Using interpretation only seems to pass all tests

var container = new Container((rules) =>
	rules
		.WithUseInterpretation()
		.With(FactoryMethod.ConstructorWithResolvableArguments)
);
var providerFactory = new DryIocServiceProviderFactory(container);

return providerFactory.CreateBuilder(serviceCollection);