从另一个程序集运行WPF应用程序
问题描述:
我想从另一个程序集“B”运行我的wpf应用程序“A”。从另一个程序集运行WPF应用程序
我使用下面的代码:
static void main()
{
var app = new A.App();
app.InitializeComponent();
app.Run();
}
当我运行我的应用程序,我得到了以下错误:
Cannot convert string '/Resources/icon.gif' in attribute 'Icon' to object of type 'System.Windows.Media.ImageSource'. Cannot locate resource 'resources/icon.gif'. Error at object 'MainWindow' in markup file 'A;component/shell/shellview.xaml'.
如何我的B图像和资源的信息传送到? 谢谢!
答
您使用Pack URI吗?
您可以使用pack URI语法来访问其他程序集中嵌入的资源。下面的例子演示了基本包URI语法在其他组件访问嵌入资源:
包://应用:,,, /; //组件
因此,如果你想找到一个名为myPic文件.BMP在另一集的文件夹MyFolder文件名为MyAssembly,你可以使用下面的包URI:
包://应用:,,,/MyAssembly程序,组件/ MyFolder中/ myPic.bmp
与其他打包URI,如果嵌入文件不存在于文件夹中,则URI中的文件夹被省略。使用这样的事情
尝试:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="CustomControls.Controls;component\Themes/...."
/>
</ResourceDictionary.MergedDictionaries>
哪一个您使用了最后? – Archie 2010-05-04 06:41:59