0

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.

4
  • 3
    What strange error do you get ? That would really help Commented Mar 13, 2010 at 8:40
  • It would help answering if you can provide more information regarding error Commented Mar 13, 2010 at 9:43
  • Does the second application need to be a stand-alone app? Could you accomplish the same task by using a new window in your original app? Commented Mar 13, 2010 at 14:17
  • The error is a XamlParserException saying that "resources/close.png" could not be found. The second application should add some Windows 7 functionality to the fist app. It contains code for the new Taskbar, Jumplists etc. That's why I've chosen this architecture. Commented Mar 13, 2010 at 15:14

3 Answers 3

1

Unfortunately, you can only have one App per AppDomain.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

2 Comments

Ok I think I see the problem, but I don't know how to fix it currently I'm using this code: <BitmapSource x:Key="imgClose">pack://application:,,,/Resources/close.png</BitmapSource>
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.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.