简体   繁体   中英

Background Image is displayed OK at design time but compiler throws exception at runtime (when debugging)?

This problem makes me confused. I simply set Background of my Window to an ImageBrush all using Properties window at design time. First, I add a JPG image to my Resources (Double-click on Resources -> Select Images -> Add Existing File ...). Then I select my Window , open Properties window to select ImageSource for the Background property. It shows the image OK at that time. But when running the application, it throws the exception: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '75' and line position '10

I don't understand this exception well, searching with Goolge won't help much because there are many various exceptions (inner exception) can throw this. In my case the inner exception is Could not find a part of the path 'D:\\Ellipse button with Animation\\bin\\Debug\\Resources\\back_ground.jpg' .

The strangest thing is it shows the image OK at design time, but at run time, that exception is thrown.

Do you have any idea to solve this? Thanks!

嘿KingBoy问题与你为图像设置的属性有关..现在你的图像属性设置为DesignTime 。所以使它成为内容复制总是一切都会正常工作。你可以点击你的图像,然后在属性Window..hope中设置其属性,它可以帮助你..

尝试将文件的“复制到输出目录”属性设置为“始终复制”值

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