简体   繁体   English

从调试更改为发布版本时出现“找不到资源”异常

[英]'Cannot locate resource' exception when changed from debug to release build

I have a solution with a wpf application and a library which the application depends on. 我有一个使用wpf应用程序和该应用程序依赖的库的解决方案。 Application invokes a method on the library(with assembly name Serialization) which in turn loads an image with code 应用程序在库上调用一个方法(程序集名称为Serialization),该方法又用代码加载图像

const string adornerImageUri = "pack://application:,,,/Serialization;component/TimelinePanel/Images/BoundaryAdornerGlyph.gif";
adornerImage.UriSource = new Uri(adornerImageUri, UriKind.Absolute);

Build action of BoundaryAdornerGlyph.gif is set to 'Resource' and Copy to Output Directory is set to 'Do not Copy'. 将BoundaryAdornerGlyph.gif的构建操作设置为“资源”,将“复制到输出目录”设置为“不复制”。 Above code gives 'cannot locate resource' exception when solution, as a result application and the library, is built in release mode whereas there is no exception when built in debug mode. 当解决方案(作为结果应用程序和库)以发布模式构建时,以上代码给出了“无法定位资源”异常,而在调试模式中构建时也不例外。 I am using Visual Studio 2010. Why this happens? 我正在使用Visual Studio2010。为什么会发生这种情况?

Exception is resolved by cleaning and building the solution but I still don't know what caused it. 异常是通过清洁和构建解决方案来解决的,但我仍然不知道是什么原因引起的。 I cannot reproduce it by cleaning first and building in debug and release mode successively. 我无法通过先清理并依次在调试和发布模式下进行构建来重现它。 I won't accept this as answer as the question asks for the reason of the exception. 我不会接受这作为答案,因为问题是出于异常原因而提出的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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