Friday, September 5, 2008

Specifying an Alternate Assembly for StartupURI

By default, when creating a WPF application in Visual Studio 2008, the StartupURI value is appropriately set to the main window of the application (typically Window1.xaml).

It is simple enough to manually edit the StartupURI to point to another component, provided the code resides in the local assembly. Referencing a window in another assembly is not so intuitive. In order to specify an alternate assembly, the pack:// nomenclature must be used:


  • assembly_name is the name of the referenced assembly, sans extension
  • path is the subfolder in which the component resides; if the component is at the project root, this element is omitted
  • file_name is the file name of the component

assembly - UI.dll
path - none (file at project root)
file_name - CalculatorView

assembly - MyApp.UI.dll
path - Views
file_name - CalculatorView

pack://application:,,,/UI;component/Views/External/CalculatorView.xaml assembly - UI.dll
path - Views/External
file_name - CalculatorView

No comments: