Visual C#在控件上更改图像会产生异常 [英] Visual C# changing image on control gives exception

查看:193
本文介绍了Visual C#在控件上更改图像会产生异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用C#编写一个插件,其中我有一个用户控件,其上有一个 linklabel ,它控制一个显示为工具提示和标签旁边的图片框,以显示表单是否可见或隐藏状态。

I am writing a plugin in C#, in which I have a user control with a linklabel on it that controls a form that shows up like a tooltip and a picturebox next to the label to show the status whether or not the form is visible or hidden.

本书通过Visual Studio PludingResources Designer添加了两个图像作为资源。 (我尝试将图像的持久性设置为在编译时链接到嵌入式以解决问题。)

I have two images that are added as resources by the book via the Visual Studio PludingResources Designer. (I tried setting the Persistence of the images both to Linked at compile time and to embedded to solve the problem.)

橡胶符合以下代码中的道路:

The rubber meets the road in the following code:

pictureBox1.Image = SubAsst.PluginResources.SubAsst_Enabled1;

当代码执行到达此行以显示图像时,我得到
System.Resources.MissingManifestResourceException 异常。例外情况如下:

When the code execution hits this line to display the image, I get the System.Resources.MissingManifestResourceException exception. The exception reads:


无法找到适合指定文化或中性文化的任何资源。请确保SubAsst.PluginResources.resources 在编译时正确嵌入或链接到程序集SubtitlingAssistant,或者所有所需的附属程序集都是可加载和完全签名的。

"Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "SubAsst.PluginResources.resources" was correctly embedded or linked into assembly "SubtitlingAssistant" at compile time, or that all the satellite assemblies required are loadable and fully signed."



<我在msdn以及其他任何地方都可以查看,但我找不到解决方案了。除非,如果我更改代码以使用内置系统图标,则有效:

I looked all over on msdn and everywhere else I could but I could not find a solution yet. Except, if I change the code to use the built-in system icons, that works:

pictureBox1.Image = System.Drawing.SystemIcons.Information.ToBitmap();

这是我到目前为止的解决方法。但是我想将自定义图像用于插件。

So that is my workaround so far. However I would like to use my custom images for the plugin.

我怀疑API不允许使用图像资源,但是没有记录。我想这是因为可以导入图标并显示在插件的默认按钮上。

I suspect that the API does not allow image resources to be used, but this is not documented. I guess this from the fact that an icon can be imported and is displayed on the default button for the plugin.

我将不胜感激任何建议。

I would appreciate any advice on this.

推荐答案

看起来缺少某些资源文件,请查看这些

Looks like some resource file is missing, check these

MSDN链接

您可能会收到在运行时访问表单的.resources文件时出现System.Resources.MissingManifestResourceException错误消息
当您尝试访问本地化资源时发生System.Resources.MissingManifestResourceException异常

C#:MissingManifestResourceException是什么意思以及如何修复它?

这篇关于Visual C#在控件上更改图像会产生异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆