tags:

views:

68

answers:

3

My application consists of App.cs/App.xaml and some other files. Everything is compiled to an exe file. However, I want a 2nd application, which should reference the first one. In this application is a class derived from App. But when I call the the Run() function I get an very strange error in the XAML code of the first application, saying that some image files could not be loaded.

I had a similar architecture when I was using Windows Forms and it worked fine.

+1  A: 

Unfortunately, you can only have one App per AppDomain.

Ray
+1  A: 

The problem is that the image is located in the first application's executable. When the second application is created, the relative paths for the images break. You can fix this by telling WPF which assembly they are located in:

<Image Source="/BaseApplication;component/resources/close.png" />

MSDN has a good article on Pack URIs in WPF that explains this more in-depth.

Abe Heidebrecht
Ok I think I see the problem, but I don't know how to fix itcurrently I'm using this code:<BitmapSource x:Key="imgClose">pack://application:,,,/Resources/close.png</BitmapSource>
hans
Just change that to pack://application:,,,/YourBaseExecutable;/component/Resources/close.png. The pack://application:,,, can be omitted, as the xaml parser can figure it out.
Abe Heidebrecht
A: 

Thank you for your input. I fixed the problem now:

<BitmapSource x:Key="imgClose">pack://application:,,,/AssemblyName;component/Resources/close.png</BitmapSource>

You have to place the name of the current Assemly (AssemblyName) in the URI.

hans