[英]Visual studio designer wont display my user controls but runs the application fine
for some reason my user controls display the error 'Cannot locate resource 'resources/backicon.png'. 由于某种原因,我的用户控件显示错误“无法找到资源'resources / backicon.png”。 I am confused as to why this is happening as the program runs fine it just cannot create an instance of the controls in the designer and is displaying a blue warning here: ''. 我对为什么这种情况发生感到困惑,因为程序运行正常,它无法在设计器中创建控件的实例,并且在此处显示蓝色警告:''。 The path in the error is 'resources/backicon.png' however in the actual user control the path is specified as '/Resources/BackIcon.png'. 错误中的路径为“ resources / backicon.png”,但是在实际的用户控件中,该路径被指定为“ /Resources/BackIcon.png”。 Also the build action for the images is set to resource. 图像的构建动作也设置为资源。
(I'm running Visual studio 2013 Express for Windows Desktop) (我正在运行用于Windows桌面的Visual Studio 2013 Express)
Right Click->Clean 右键单击->清洁
Once its cleaned 一旦清洗
Now RightClick-> Rebuild 现在右键单击->重建
You will see the blue warning gone. 您将看到蓝色警告消失。
Its because your user control must be added later on which resulted in designer not having any reference as its using previous build as base 这是因为您的用户控件必须稍后添加,这导致设计人员没有任何参考,因为它使用以前的构建作为基础
Explicitly specify the assembly name in the path although it belongs to the same assembly. 尽管路径属于同一程序集,但在路径中明确指定程序集名称。
pack://application:,,,/MyAssemblyName;component/MyResourcesFolder/MyImage.png
Make sure You set the build action of the image to the type 'Resource'. 确保将图像的构建操作设置为“资源”类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.