【发布时间】:2011-03-18 20:37:44
【问题描述】:
有没有办法在 LinqPad 中合理地实例化 WPF 对象?这是我的示例(在查询中添加了正确的程序集等):
var w = new Window();
w.Loaded += (o,e) => {
w.Content = new TextBlock() { Text = "Foo" };
};
w.Show();
然而,这会死得很惨:
System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
at System.Windows.Input.TextServicesContext.StopTransitoryExtension()
at System.Windows.Input.TextServicesContext.Uninitialize(Boolean appDomainShutdown)
at System.Windows.Input.TextServicesContext.TextServicesContextShutDownListener.OnShutDown(Object target, Object sender, EventArgs e)
at MS.Internal.ShutDownListener.HandleShutDown(Object sender, EventArgs e)
关于我如何使它工作的任何线索?
【问题讨论】:
-
更新:这已在最近的 LINQPad 测试版中得到修复 - 您可以以任何您想要的方式显示 WPF 窗口,并且没有可怕的死亡 :) 您还可以执行以下操作,在输出面板:PanelManager.DisplayWpfElement (new TextBlock() { Text = "Foo" });