An exception is thrown: "_The invoked member is not supported before the type is created_".
This exception is thrown when DeclaringType or GetParameters() members of ConstructorBuilder get called. And both are called in NewObject method.
In ConstructorBuilder context, the ReflectedType property should be a good alternative to DeclaringType, but the parameter list is not available anywhere.
Maybe a NewObject(ConstructorBuilder, Type[]) overload should be enough (but not completely safe).
When creating dynamic types it is not possible to emit a method that uses a ConstructorBuilder.
Given that ctor is a ConstructorBuilder, the following code works fine:
But its Sigil version doesn't:
An exception is thrown: "_The invoked member is not supported before the type is created_".
This exception is thrown when DeclaringType or GetParameters() members of ConstructorBuilder get called. And both are called in NewObject method.
In ConstructorBuilder context, the ReflectedType property should be a good alternative to DeclaringType, but the parameter list is not available anywhere.
Maybe a NewObject(ConstructorBuilder, Type[]) overload should be enough (but not completely safe).