I wish to implement a clone method in a dynamic type, but the problem is I can't new up said type before I've declared typeBuilder.CreateType() - I get the exception: System.NotSupportedException : The invoked member is not supported before the type is created.
Is there a way around this?
edit: Here's what I'm replicating with Emit. The cloning work itself is done in a protected constructor, and isn't done externally because I need to copy private members.
public class SomeOperatorInstance : OperatorInstance, ISomeOperatorInstance
{
public SomeOperatorInstance() { }
internal SomeOperatorInstance(SomeOperatorInstance source) : base(source) { }
public override IOperatorInstance Clone()
{
return new SomeOperatorInstance(this);
}
}