MyDLL(生成类文件) 继承自 Application 文件中包含 Main.xaml 文件
booma 2008-07-05 03:05:23 MyDLL(生成类文件) 继承自 Application 文件中包含 Main.xaml 文件
C# code
FrameworkElement GetMainElement()
{
string componentName = typeof(MyDLL).Assembly.ToString();
Uri resourceLocator = new Uri(this.componentName + ";component/"
+ Path.ChangeExtension(name, ".xaml"), UriKind.RelativeOrAbsolute);
return (FrameworkElement)Application.LoadComponent(resourceLocator);
}
Main.xaml 文件内容
<Panel
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
</Panel>
为何程序执行到 LoadComponent 提示:PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The calling thread must be STA, because many UI components require this. 类似这个错误。