教程中国
PHOTOSHOP CS9.0中文版 MAYA 8.5 FOR WINDOWS Corel Painter v9.0 Flash MX2004 中文版 Illustrator cs2 中文版
VC++6.0含sp6 中英文版 VB6.0 +sp6 简体中文版 Borland Delphi 7汉化版 MSDN for vb6.0中文版 Visual Studio 2005简体
教程中国下属 文件存储共享专家BIBIDU.COM 提供大型软件,教材,源码,电影,音乐,图书等下载 更多精品请点此进入
  您目前所在位置: 教程中国 >> .NET类 >> ASP.NET >> 使用ImageList时候发生运行错误提示资源问题的解决方法 RSS订阅
使用ImageList时候发生运行错误提示资源问题的解决方法
教程(视频,书籍)下载:  ASP.NET AutoCAD 数据库 C# ASP java photoshop 网页设计 delphi 3dmax Flash C++ VB 张孝祥 实例   更多请进入BIBIDU搜索
IT搜索引擎   
今天在给一个程序加入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 form's 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



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


来源:upschool.com.cn
作者:
关键字:解决方法
发表日期:2005-12-23

网页显示有限 阅读全文请下载本文完整版WORD文档

上一篇:VB中枚举指定目录下所有文件的方法   下一篇:为你的EXCEL增加一个收藏夹


本文的相类似文章
  • 真假ARP的防范区别以及解决方法
  • 机房管理常见三大难题的解决方法
  • 典型网络故障的解决方法
  • 拒绝服务攻击原理及解决方法
  • 开机自动运行解决方法
  • 被 DDOS 分布式攻击后的解决方法
  • 实战:ARP攻击原理及解决方法
  • MySQL中文模糊检索问题的解决方法
  • ADO控件和DATA控件的冲突(不能共存)的解决方法
  • 梅花雨的日历控件在ASP.NET2.0下不可用的解决方法
  • 网友评论 查看本文全部评论
    笔 名: *
    评 论:
    最多500字。当前字数:0
    联系方式:
    验证码:
    在学习中进步 在进步中成长 教程中国相随您的成长之路
    华腾联合科技股份有限公司版权所有
    广告联系:Rosibo@163.com