求助
问大家一个问题 这个函数的用法。
Assembly.Load (Byte[])
我有两个 Assembly ,ClassLibrary1和ClassLibrary2 其中
ClassLibrary2引用了ClassLibrary1。
我在ClassLibrary2中 创建了一个ClassLibrary1中的类实例。
具体如下:
我在一个程序中,通过如下代码 调用 ClassLibrary2
System.IO.FileStream fs = System.IO.File.Open(@"D:\ClassLibrary2\bin\Debug\ClassLibrary1.dll",System.IO.FileMode.Open,System.IO.FileAccess.Read);
Byte[] cl1 = new byte[fs.Length];
fs.Read(cl1, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
System.Reflection.Assembly ass1 = System.Reflection.Assembly.Load(cl1);
System.IO.FileStream fs2 = System.IO.File.Open(@"D:\学习练习\2003 QISystem\ClassLibrary2\bin\Debug\ClassLibrary2.dll",System.IO.FileMode.Open,System.IO.FileAccess.Read);
Byte[] cl2 = new byte[fs2.Length];
fs2.Read(cl2, 0, System.Convert.ToInt32(fs2.Length));
fs2.Close();
System.Reflection.Assembly ass = System.Reflection.Assembly.Load(cl2);
System.Windows.Forms.Form ff = ass.CreateInstance("ClassLibrary2.Form1") as System.Windows.Forms.Form;
ff.Show();
然后在,ClassLibrary2 中通过如下代码 调用ClassLibrary1
ClassLibrary1.Class1 ff = new ClassLibrary1.Class1();
MessageBox.Show(ff.ff.ToString());
并且在这里报错。
大家帮我看看。
我想了好久,没法解决。这次我放在首页,过几天我拿掉。
谢谢