Windows应用程序,使用Assembly.CreateInstance创建实例,构造函数中有参数,应当如何处理呢:
objNewObject = objAssembly.CreateInstance(objClassName, false, BindingFlags.CreateInstance, null, objs, null, null);
抛出以下异常,应当如何解决?最后一个激活属性我应当如何使用呢?
未处理 System.Reflection.TargetInvocationException
Message="调用的目标发生了异常。"
Source="mscorlib"
StackTrace:
在 System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
在 System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
在 System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
在 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
在 System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
在 System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
在 Wonsoft.SourceCompiler.CShapCompiler.CreateObject() 位置 I:\Wonsoft\WonsoftScriptManager\Wonsoft\SourceCompiler\CShapCompiler.cs:行号 106
在 Wonsoft.SourceCompiler.CShapCompiler.GetObject() 位置 I:\Wonsoft\WonsoftScriptManager\Wonsoft\SourceCompiler\CShapCompiler.cs:行号 120
在 WonsoftScriptManager.Form1.GeneratePropertiesByOptionsWithDriver() 位置 I:\Wonsoft\WonsoftScriptManager\WonsoftScriptManager\Form1.cs:行号 299
在 WonsoftScriptManager.Form1.button1_Click_1(Object sender, EventArgs e) 位置 I:\Wonsoft\WonsoftScriptManager\WonsoftScriptManager\Form1.cs:行号 410
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 WonsoftScriptManager.Program.Main() 位置 I:\Wonsoft\WonsoftScriptManager\WonsoftScriptManager\Program.cs:行号 18
InnerException: System.NullReferenceException
Message="未将对象引用设置到对象的实例。"
Source="WonsoftScriptManager"
StackTrace:
在 WonsoftScriptManager.Form1.OnGridPropertyChanged(String propertyname) 位置 I:\Wonsoft\WonsoftScriptManager\WonsoftScriptManager\Form1.cs:行号 69
在 Wonsoft.Options1.set_vlan(Int32 value)
在 Wonsoft.Options1..ctor(IGridPropertyDriver owner)
InnerException:
ObjectHandle CreateInstance(
string assemblyName,
string typeName,
Object[] activationAttributes
)
最后一个激活属性应当如何使用呢?