Run WPF App from Another Assembly

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

I am using the following code:

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

      

when i run my application 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 pass from B images and resource information to A? Thanks!

+2


a source to share


1 answer


Are you using the package URI?

Package URI syntax can be used to access resources embedded in other assemblies. The following example demonstrates the base URI package syntax for accessing embedded resources in other assemblies:

package: // Application: ,, /; component //

Thus, if you want to find a file named myPic.bmp in the myFolder folder in another assembly named myAssembly, you must use the following package URI:



Packaging: // Usage: ,, / MyAssembly; component /MyFolder/myPic.bmp

As with other URI packages, if the embedded file does not exist in the folder, the folder is not specified in the URI.

TRy using something like this:

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

      

+1


a source







All Articles