locked
Can't find resource dictionary RRS feed

  • Question

  • I'm using VS2010, .net 4, in a pure WPF app. I'm using the code here to customize an expander control

    http://msdn.microsoft.com/en-us/library/ms753296.aspx

    I've put the code in a separate xaml file (/Styles/ScreenStyles.xaml) and included it via my app.xaml file using a merged dictionary

    <Application x:Class="WpfApplication1.App"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Application.Resources>
    <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="Styles/ScreenStyles.xaml" />
    </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    </Application.Resources>
    </Application>

    But now whenever i add even a user control to the app, i get a designer error for the file that states the file cannot be found (extremely helpful). Note that it does run correctly, it's only a designer error. So I attached VS to the VS instance throwing the error and caught this exception

    System.InvalidCastException occurred
      Message=Specified cast is not valid.
      Source=AxTools.VS10X.MethodBlockMarker
      StackTrace:
           at AxTools.VS10X.MethodBlockMarker.TextViewCreationListener.TextViewSinkManager.TextViewSink.MethodBlockMarker._ReadOpacityCodeBackgroundSetting()
      InnerException:

    which is meaningless to me. However, the targetsite for this exception is "{Void _ReadOpacityCodeBackgroundSetting()}"

    I then get the FileNotFound exception

    System.IO.FileNotFoundException occurred
      Message=Unable to find the specified file.
      Source=Microsoft.Windows.Design.Platform.WPF
      StackTrace:
           at Microsoft.Windows.Design.Platform.ViewProducerBase.Microsoft.Expression.DesignModel.DocumentModel.IDocumentRootResolver.GetDocumentRoot(String path)
      InnerException:

    Followed By Cannot Find Resource

    System.IO.IOException occurred
      Message=Cannot locate resource ''.
      Source=PresentationFramework
      StackTrace:
           at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
      InnerException:
     

     And Finally the error reported via the designer

    Microsoft.Expression.DesignModel.Core.InstanceBuilderException occurred
      Message=An error occurred while finding the resource dictionary "/Styles/ScreenStyles.xaml".
      Source=Microsoft.Expression.Platform.WPF
      StackTrace:
           at Microsoft.Expression.Platform.WPF.InstanceBuilders.ResourceDictionaryInstanceBuilder.ProvideResourceDictionary(IInstanceBuilderContext context, DocumentCompositeNode resourceDictionaryReferenceNode, IDocumentRoot& relatedRoot)
      InnerException: System.IO.FileNotFoundException
           Message=Unable to find the specified file.
           Source=Microsoft.Windows.Design.Platform.WPF
           StackTrace:
                at Microsoft.Windows.Design.Platform.ViewProducerBase.Microsoft.Expression.DesignModel.DocumentModel.IDocumentRootResolver.GetDocumentRoot(String path)
                at Microsoft.Expression.Platform.WPF.InstanceBuilders.ResourceDictionaryInstanceBuilder.ProvideResourceDictionary(IInstanceBuilderContext context, DocumentCompositeNode resourceDictionaryReferenceNode, IDocumentRoot& relatedRoot)
           InnerException:

    And finally finally, a couple of NotImplementedExceptions that look meaningless.

    So i started eliminating code from the template piece by piece and found that it's the VisualStateManager. In fact, i first just gutted the storyboards and just put stubs, didn't work. I have to actually remove it completely. Then all is well. I can't seem to repro this outside of my project.

    Any ideas how i can debug any further? I can't seem to get a meaningful stack trace that helps point me to a specific point.

    Wednesday, October 13, 2010 4:36 AM

Answers

  • uuuhhgggg! I just realized I have a reference to the WPFToolkit. Remove the reference and everything worked.

    there's an entire night wasted on a useless error. Highlighting that last error mentioned (ambiguous reference) is much more helpful but doesn't show up in the list until you try to design something. My error list is autohide so it never actually was seen. I found it by chance.

    so thanks for the help :)

    • Marked as answer by Drew Dials Wednesday, October 13, 2010 5:11 AM
    Wednesday, October 13, 2010 5:11 AM

All replies

  • Ah! another piece of info I found in the error list was this error

    Ambiguous type reference. A type named 'VisualStateManager' occurs in at least two namespaces, 'System.Windows' and 'System.Windows'. Consider adjusting the assembly XmlnsDefinition attributes. 

    now if I only knew what that meant...

     

     

    Wednesday, October 13, 2010 5:03 AM
  • uuuhhgggg! I just realized I have a reference to the WPFToolkit. Remove the reference and everything worked.

    there's an entire night wasted on a useless error. Highlighting that last error mentioned (ambiguous reference) is much more helpful but doesn't show up in the list until you try to design something. My error list is autohide so it never actually was seen. I found it by chance.

    so thanks for the help :)

    • Marked as answer by Drew Dials Wednesday, October 13, 2010 5:11 AM
    Wednesday, October 13, 2010 5:11 AM
  • removing the reference from the project will force you to remember to include the DLL when you start/deploy the application. WPFToolkit is just too old for .net 4 or 4.5 :(

    http://bitbonk.spaces.live.com

    Friday, November 16, 2012 4:51 PM