简体   繁体   中英

WPF IOException Cannot Locate Resource Dictionary XAML

 <Application x:Class="ControlsBox.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml"
>

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/ControlsBox;LibraryControlRescourceDictionary.xaml"/>
            <ResourceDictionary Source="/Microsoft.Surface.Presentation.Generic;v2.0.0.0;31bf3856ad364e35;component/themes\styles.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Error:

'Set property 'System.Windows.ResourceDictionary.Source' threw an exception.' Line number '10' and line position '18'.
{"Cannot locate resource 'controlsbox;librarycontrolrescourcedictionary.xaml'."}

I tried following the advice provided in the following: WPF IOException Cannot locate resource No avail. I've moved the LbiraryControlRescourceDictionary.xaml file to different project folders, readding the file, changing the target platform, changing the property to Page or Rescource, Copying it to the output directory, and more.

The biggest weird part is that sometimes the same project, with no changes, will load on some computers without this error with no problem. It can build it and deploy the executable fine. But some machines, same OS, same WPF SDK and visual studio, will not handle this rescource file right.

Here is the project layout if it helps: i.imgur.com/XdifDHa.png

EDIT: For the last week or so I just deleted it. I had no idea what it was and my program has worked fine since. It was part of the Microsoft SDK example pack so it was already there when I found it. But I guess it wasn't that important. If you have an idea of what the problem was, please let me know and I'll add it back in for kicks.

我对这个SDK示例也遇到了同样的问题... Nitesh的上述注释包含了对我有用的答案,即Source属性值中的“ / Shared /”前加“ LibraryControlRescourceDictionary.xaml”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM