views:

142

answers:

1

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 resource '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!

+1  A: 

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>
Archie
in this way I have to modify all resource references in my wpf application "A". Instead it would be great if there is a way to modify the relative search path used by A
Ricibald
See the modified answer
Archie