0

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:

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?

Community
  • 1
  • 1
xandriksson
  • 101
  • 5

1 Answers1

0

The following two steps resolved the problem for me:

  • Change the fallback language in the assembly settings from

    [assembly: NeutralResourcesLanguageAttribute("en-US", UltimateResourceFallbackLocation.Satellite)]

    to

    [assembly: NeutralResourcesLanguageAttribute("")]

  • Remove the UI culture of the project:

    <UICulture>en-US</UICulture>

Maybe someone can elaborate on that. I don't understand why changing the command line parameters had an influence on finding language resources.

xandriksson
  • 101
  • 5