System.Windows.Markup.XamlParseExceptionoccurredA first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dllAdditional information: 'Set property 'System.Windows.ResourceDictionary.Source' threw an exception.' Line number '21' and line position '6'."Could not load file or assembly 'ResourceLibrary, Culture=neutral' or one of its dependencies. The system cannot find the file specified.":"ResourceLibrary, Culture=neutral"

=== Pre-bind state information ===
LOG: DisplayName = ResourceLibrary, Culture=neutral
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: ResourceLibrary, Culture=neutral | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\QTAgent32.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/ResourceLibrary/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PrivateAssemblies/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PrivateAssemblies/ResourceLibrary/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PublicAssemblies/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PublicAssemblies/ResourceLibrary/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/DataCollectors/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/DataCollectors/ResourceLibrary/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/DataCollectors/x86/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/DataCollectors/x86/ResourceLibrary/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PrivateAssemblies/DataCollectors/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PrivateAssemblies/DataCollectors/ResourceLibrary/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PrivateAssemblies/DataCollectors/x86/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PrivateAssemblies/DataCollectors/x86/ResourceLibrary/ResourceLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/ResourceLibrary/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PrivateAssemblies/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PrivateAssemblies/ResourceLibrary/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PublicAssemblies/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PublicAssemblies/ResourceLibrary/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/DataCollectors/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/DataCollectors/ResourceLibrary/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/DataCollectors/x86/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/DataCollectors/x86/ResourceLibrary/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PrivateAssemblies/DataCollectors/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PrivateAssemblies/DataCollectors/ResourceLibrary/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PrivateAssemblies/DataCollectors/x86/ResourceLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Users/me/Documents/projects/Autom/git/Autom/VisCong/VisConf_Tests/bin/Debug/PrivateAssemblies/DataCollectors/x86/ResourceLibrary/ResourceLibrary.EXE.

最佳答案

这个问题仅是对我自己以及在寻求解决此问题的过程中到达此处的任何人的引用。
引用中的Copy Local设置为True,但DLL未复制到构建文件夹。
由于仅在XAML中使用了此资源库,因此我必须添加using语句:

using ResourceLibrary;
在引用代码中(实际上,是调用引用代码的代码,它是应用程序或单元测试)
这样就在目标构建目录中创建了DLL
编辑:
有时,即使using ResourceLibrary也无效。解决方案是在ResourceLibrary的代码背后创建一些空的静态方法:
namespace ResourceLibrary {
    public static class ReferencePoint {
        public static ReferToMe() {}
    }
}
并从引用代码中调用它:
ReferencePoint.ReferToMe();

关于c# - XamlParseException : Could not load file or assembly 'ResourceLibrary, ...' or one of its dependencies.系统找不到指定的文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23218320/

10-12 00:11