Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An error occurred while finding the resource dictionary

I have a merged resource dictionary in App.xaml Main assembly, which combines various resource dictionaries from separate assemblies: Common and PresentationLayer.

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Common;component/Themes/Button.xaml"/>
            <ResourceDictionary Source="/PresentationLayer;component/DataTemplates/AppointmentsDataTemplates.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

At run time the styles in the resource dictionaries are applied to the controls correctly. However, at design time the styles are not applied and Visual Studio 2012 keeps giving the following error:

An error occurred while finding the resource dictionary "/Common;component/Themes/Button.xaml".

And warning:

The resource "BannerButton" could not be resolved.

I came across this post but the problem persists despite Build Action set to Resource. Also, I did not have this problem when running under Visual Studio 2010 or Expression Blend 4. The Main assembly definitely holds a reference to the Common assembly and I haven't changed the Pack URIs.

like image 234
Blake Mumford Avatar asked Jan 18 '13 05:01

Blake Mumford


3 Answers

This was a known issue with Visual Studio 2012. See this link at Microsoft Connect. After installing VS2012 Update 1 this issue resolved for me. If you think you're running the most up to date version of VS2012 and still experiencing this issue, make absolutely sure that the update has been applied. I thought I had updated using Windows Update, but then found that I had to tell VS2012 to apply the update. After VS2012 did its thing everything was fine.

like image 139
Blake Mumford Avatar answered Nov 19 '22 21:11

Blake Mumford


For VS2017 if assembly is referenced and double-checked that all namings are OK try to close VS and delete .vs directory in solution directory. This will cause you to lose all user settings (startup project, WPF designer zoom, etc.) but will fix this.

like image 40
rattler Avatar answered Nov 19 '22 19:11

rattler


If you are using Visual Studio 2017, try to restart your computer. The problem may be solved.

like image 4
Casper Avatar answered Nov 19 '22 21:11

Casper