Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF application error 'Set property 'System.Windows.ResourceDictionary.Source' threw an exception.'

Tags:

c#

.net

wpf

I have created WPF application in Visual Studio 2010 when I run the application in Visual Studio 2017 it is generating the following Unhandled Exception:

System.Windows.Markup.XamlParseException: 'Set property 'System.Windows.ResourceDictionary.Source' threw an exception.' Line number '8' and line position '18'. ---> System.IO.IOException: Cannot locate resource 'resourcedic/maindictionary.xaml'.

Following is the app.xaml file that I am using in the application:-

<Application x:Class="AttendenceSystem.UI.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="StartWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="ResourceDic\MainDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>    
</Application>

How can I resolve this error?

like image 731
Anil Bali Avatar asked Jun 01 '26 22:06

Anil Bali


1 Answers

I had the same issue, I had to add this itemGroup to the .csproj of the project

<ItemGroup>
    <PackageReference Include="MaterialDesignThemes.Wpf">
    <Version>1.0.1</Version>
    </PackageReference>
    <PackageReference Include="Newtonsoft.Json">
    <Version>12.0.3</Version>
    </PackageReference>
</ItemGroup>
like image 50
N.Pozzi Avatar answered Jun 03 '26 12:06

N.Pozzi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!