internal static object CreateInstance(Type type, params object[] args) { var typeDefinition = new TypeDefinition(type.TypeHandle.Value); if (typeDefinition.DefaultConstructor.IsNull) { throw new ArgumentException("Type has no parameterless constructor."); } var thisObject = Internal.AllocateObject(type.TypeHandle, typeDefinition.Size); return(Intrinsic.CreateInstanceSimple(typeDefinition.DefaultConstructor.Method, thisObject)); }