【发布时间】:2010-05-03 11:01:03
【问题描述】:
当我想向用户显示一个驻留在 DLL 中的(windows)表单(在本例中为 Form1)时,我使用来自另一个可执行文件的以下代码;
Assembly a = Assembly.Load(System.IO.File.ReadAllBytes("mydll.dll"));
Form MyDLLFormInstance = (Form)a.CreateInstance("myNamespace.Form1");
MyDLLFormInstance.Show();
现在,我使用 WPF 创建了另一个 DLL。当我使用上面的代码时,我得到了以下错误;
Unable to cast object of type 'myNamespace.Window1' to type 'System.Windows.Forms.Form'.
那么,如何将 System.Windows.Window 转换为 System.Windows.Forms.Form?或者,如何从 c# forms 应用程序显示驻留在 WPF 创建的 DLL 中的窗口?
【问题讨论】: