I have a working C# program which requires a set of command line arguments to start. My problem is that when I change the arguments in the project settings of Visual Studio 2012 (VS) and run the application, a XamlParseException
is thrown shortly after startup:
System.Windows.Markup.XamlParseException:
'Set property 'System.Windows.ResourceDictionary.Source' threw an exception.'
---> System.IO.IOException: Cannot locate resource 'theme/textblockstyle.xaml'.
...
at MyAssembly.View.MainWindow.InitializeComponent()
at MyAssembly.View.MainWindow..ctor()
The "missing" resource is referenced in MainWindow.xaml
and has nothing to do with the given command line arguments:
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/MyAssembly;component/Theme/TextBlockStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
The interesting thing is that after rebuilding the project, the exception does not pop up anymore. Of course, I would like to have a less cumbersome solution than this, so I tried the following ideas:
- Change the "Build Action" of
TextBlockStyle.xaml
from "Page" to "Resource" - Circumvent an optimization bug of VS by adding a dummy style to the root dictionary like in question "Trouble referencing a Resource Dictionary that contains a Merged Dictionary".
None of it resolved the problem however. What can I do in order to avoid a rebuild each time I change the command line arguments?