首 页 网络编程
网页制作 图形图象 操作系统 冲浪宝典
软件教学 认证考试

网络安全 网络办公 行业资讯 评测对比
您当前位置:站长天空 -> 网页制作
使用ImageList时候发生运行错误提示资源问题的解决方法-.NET教程,评论及其它
作者:网友供稿 点击:184
推荐
西部数码-全国虚拟主机10强!20余项虚拟主机管理功能,全国领先!第6代双线路虚拟主机,南北访问畅通无阻!可在线rar解压,自动数据恢复设置虚拟目录等.免费赠送访问统计,企业邮局.Cn域名注册10元/年,自助建站480元起,免费试用7天,满意再付款!P4主机租用799元/月.月付免压金
站内搜索
文章页数:[1] 
今天在给一个程序加入imagelist的时候碰到了这样的运行错误:

未能在给定的程序集中找到任何适合于指定的区域性(或非特定区域性)的资源。请确保已将“frmmain.resources”正确嵌入或链接到程序集“xxx”。
basename: yyy locationinfo: xxx.yyy resource file name: yyy.resources assembly: xxx, version=1.0.1698.16471, culture=neutral, publickeytoken=null

其实之前在给这个程序的主窗口自定义icon的时候也碰到过同样的问题,只是当时没有注意。
查找资料,在微软的支持站点发现如下文章:

http://support.microsoft.com/default.aspx?scid=kb;en-us;q318603

prb: error when you access .resources file of the form at run time
article id : 318603
last review : august 7, 2003
revision : 2.0

this article was previously published under q318603
on this page
symptoms
cause
resolution
status
more information

symptoms
when you are running your visual basic .net, visual c# .net, or visual j# .net windows application, you may receive the following error message or a similar one when you load a form:
an unhandled exception of type system.resources.missingmanifestresourceexception occurred in mscorlib.dll

additional information: could not find any resources appropriate for the specified culture (or the neutral culture) in the given assembly. make sure "form1.resources" was correctly embedded or linked into assembly "myapplication".

basename: form1 locationinfo: windowsapplication4.form1 resource file name: form1.resources assembly: myapplication, version=1.0.781.33026, culture=neutral, publickeytoken=null
if you click break in the error dialog box, and if you are running the code in the integrated development environment (ide), you discover that a line of code inside the initializecomponent statement causes this problem. for example, if you create the sample from the "more information" section, this error occurs in conjunction with an imagelist control. although the error message may refer to a different control, notice that resources.getobject appears on that line of code in the error message:
this.imagelist1.imagestream = ((system.windows.forms.imageliststreamer)(resources.getobject("imagelist1.imagestream")));
cause
this problem occurs because the form class is not the first class in the code module of the form.

note: this article documents one specific cause of this problem. there may be other situations that can lead to similar results.
resolution
to resolve this problem, move all of the other class definitions so that they appear after the forms class definition.
status
this behavior is by design.
more information
a form code module can contain multiple classes. when the project is built, the build system must decide which class it should use to create the .resources file. the design of the project build system specifies that the first class in the code module is the class on which the .resources file is based. the .resources file is named according to that class, not the name of the form. in most cases, these two names are the same. however, if these names differ, you receive the error message that is listed in the "symptoms" section.

when you load the form at run time, the initializecomponent method may need to get objects from the .resources file. initializecomponent searches for the form_name.resources file in the assembly. because the initial form_name.resources file was never created or linked to the assembly, the attempt to retrieve the .resources file fails.
steps to reproduce the behavior
1. create a windows application project in visual basic .net, visual c# .net, or visual j# .net. form1 is created by default.
2. add an imagelist control to form1.
3. add an icon file to the imagelist control.
4. in the code module of form1, add the following code before the form1 definition: visual basic .net:
public class someclass
end class

visual c# .net and visual j# .net:
public class someclass
{
}


5. build the project. notice that the project builds successfully.
6. run the project. notice that you receive the error message that is listed in the "symptoms" section.


--------------------------------------------------------------------------------

applies to
• microsoft visual basic .net 2002 standard edition
• microsoft visual c# .net 2002 standard edition
• microsoft visual j# .net 2003 standard edition
• microsoft visual j# .net 2003 standard edition
• microsoft visual c# .net 2003 standard edition
• microsoft visual basic .net 2003 standard edition



把主窗体的类提到程序最前面,问题解决。^_^

文章整理:站长天空 网址:http://www.z6688.com/
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

文章页数:[1] 


放大字体显示 缩小字体显示 打印文章 推荐给朋友
热门文章
·中文字符从jsp传送到servlet的处理-JSP教程,Jsp/Servlet
·带右键菜单的树形控件(1)-ASP教程,ASP应用
·RSA加密解密及RSA签名和验证-.NET教程,安全和优化
·VB中String的用法及原理-.NET教程,VB.Net语言
·ASP Forum2.0学习笔记之二---了解Master Pages库-ASP教程,数据库相关
·使用ImageList时候发生运行错误提示资源问题的解决方法-.NET教程,评论及其它
·web.config点滴:更改login控件对密码安全性的要求-.NET教程,组件控件开发
·基于h.323协议的ip视频会议质量技术
·框架(javascript)-JSP教程,Java技巧及代码
·讲一讲ASP处理数据用的组件ADO (ActiveX Data Object)-ASP教程,数据库相关
最新文章
·从两方面看ajax与b/s_ajax教程
·google adsense for content新的广告样式_google推广
·flash as代码简单实现动态文本包边效果_flash教程
·我做gg广告从0到每月1000美元详细全过程_网赚技巧
·google adsense 中文高价关键词一览_网赚技巧
·谁说小网站赚不到钱!_网赚技巧
·什么样的网站才算是高质量网站呢?_站长心得
·经验:搜索引擎的页面各个元素的权重比例参考_站长心得
·搜索引擎google排名优化全攻略_google推广
·月入千美金不是梦--adsense高收入实战及分_google推广
相关主题
西部数码虚拟主机

友情链接
CNNIC 西部数码
万网 自助建站
虚拟主机 asp空间
域名注册 域名
域名申请 主页空间
论坛空间 网站空间
国际域名 虚拟空间
空间租用 DDOS防火墙
成都主机托管 四川主机托管
主机租用 服务器租用
网站目录 自助建站
虚拟主机 网址大全
软件下载
自助链接
虚拟主机资讯 特价虚拟主机
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
关于我们:站长天空:专业提供最新的站长资讯、在线教程、虚拟主机权威评测、虚拟主机性能对比、网站制作教程,开发教程,站长工具。包括网页制作教程、冲浪宝典、编程参考、操作系统、软件教学、行业动态等。
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
发表评论 打印  刷新     关闭