开发者

Run WPF Application from another assembly

I want to run my wpf application "A" from another assembly "B".

I use the following code:

static void main() 
{
  var app = new A.App();
  app.InitializeComponent();
  app.Run();
}

when i run my app I got the following error:

Cannot convert string '/Resources/icon.gif' in attribute 'Icon' to object of type 'System.Windows.Media.ImageSource'. Cannot locate res开发者_StackOverflow中文版ource 'resources/icon.gif'.  Error at object 'MainWindow' in markup file 'A;component/shell/shellview.xaml'.

How can I transfer from B images and resources info to A? Thanks!


Are you using the Pack URI?

You can use the pack URI syntax to access resources embedded in other assemblies. The following example demonstrates the basic pack URI syntax for accessing embedded resources in other assemblies:

pack://application:,,,/;component//

Thus, if you wanted to locate a file named myPic.bmp in the folder myFolder in another assembly named myAssembly, you would use the following pack URI:

Pack://application:,,,/myAssembly;component/myFolder/myPic.bmp

As with other pack URIs, if the embedded file does not exist within a folder, the folder is omitted in the URI.

TRy using something like this:

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="CustomControls.Controls;component\Themes/...."
/>
</ResourceDictionary.MergedDictionaries>


Today I had the same problem, and I solved it by putting just:

Source="../../Resources/name.jpg"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜