0

I created a resource dictionary (Style.xaml) and put it in it's own assembly (ResourceSharing.dll). I then have a solution with two projects. In both projects, I added a reference to ResourceSharing.dll, and in App.xaml I added this code:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/ResourceSharing;component/Style.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

When I try to use a resource contained in the resource dictionary, something like

<Grid Background="{StaticResource GridBackgroundColor}">

In one project, that works. The changes are applied at design time, and everything builds, compiles, and runs. But in the other project, that line is underlined with a blue line and I get the error "The resource "GridBackgroundColor" could not be resolved.", but intellisense will autocomplete the resource name and the designer even shows the correct color square next to it. The code will build and run fine even with this error, it is only at design time that it has a problem.

Why would this happen in one project but not another? Could there be specific project settings that would cause this? And if so, what are some settings that would affect this?

I am running Visual Studio Professional 2019 v16.8.4

Note: The project that is not working was an existing project that I attempted to add this resource dictionary assembly reference to and utilize. The other project was added just to test the resource assembly.

Update: I've tried everything mentioned in this person's question and the answers: Design-time Error finding the Resource Dictionary - Inconsistent between projects

Update#2: This error does not occur when opening the solution in Visual Studio 2017

Mikkel Bang
  • 574
  • 2
  • 13
  • 27
  • XAML Designer isn't perfect, and things like this happen all the time. Try to rebuild all projects and restart Visual Studio. – Clemens Jan 27 '21 at 16:52
  • Tried that, multiple times. No luck. I even tried adding another project to the solution, creating a whole new solution with a new project, all work fine with my resource assembly. – Mikkel Bang Jan 27 '21 at 16:55

0 Answers0