日期:2014-05-17  浏览次数:21642 次

再次请教反射达人——如何反射调用internal构造函数的类
需要被反射调用类代码片段如下:

namespace Cj.Tk.Form
{
    public partial class Form_ZZS : Cj.Common.Forms.InvForm
    {
        internal Form_ZZS(LX lx, string bm, string mc)
        {
            ........
        }
        ......
    }
}


我想要反射调用这个类,但是他的构造函数是internal类型的,我使用了下面的方法,不行,报错内容是找不到构造函数
     Type t2 = testAssembly.GetType("Cj.Tk.Form.Form_ZZS");
    object cm2 = Activator.CreateInstance(t2, new object[] { LX.ZY, GetCurrent[0], GetCurrent[1] });


使用下面的方法仍然报错,直接进入else分支中

Type[] types = new Type[3];
types[0] = typeof(LX);
types[1] = typeof(string);
types[2] = typeof(string);
ConstructorInfo constructorInfoObj = t2.GetConstructor(types);
if (constructorInfoObj != null)
{
    MessageBox.Show(constructorInfoObj.ToString());
}
else
{
    MessageBox.Show("The constructor of MyClass1 that takes an integer " +
                    "as a parameter is not available.");
}


请教各位高手该如何处理呢?
C#?反射?internal构造函数

------解决方案--------------------
声明友源http://www.cnblogs.com/awpatp/archive/2010/05/17/1737822.html
------解决方案--------------------
internal作用在同一个命名空间下
你把你现在的命名空间也搞成namespace Cj.Tk.Form