Today, when you join ImageList, you have encountered such a run error: unable to find any resources suitable for specified regional (or non-specific) in a given program. Make sure "frmmain.resources" has been properly embedded or linked to the assembly "XXX". BaseName: YYY LocationInfo: xxx.Yyy Resource File Name: YYY.Resources Assembly: xxx, version = 1.0.1698.16471, culture = neutral, publickeyToken = NULL actually encountered the main window of this program Custom ICON The same problem, just did not pay attention. Find information, found in Microsoft's support site found as follows: 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: 318603last Review: August 7, 2003Revision: 2.0
This Article Was previously distribLished Under Q318603
On this Page
SymptomscauseresolutionStatusmore 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 INE 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, 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 what 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 anImageList control. Although the error message may refer to a different control, notice that
Resources.getObject APPEARS ON THATLIN OF CODE IN The Error Message:
This.imagelist1.imagestream = ((System.Windows.Forms.imageListStreame))))));
Cause
This Problem Occurs Because
Form Class Is Not The First Class in The Code Module of The Form.
.
Resolution
To Resolve this Problem, Move All of the Other Class Definitions So That The 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 search for the
FORM_NAME.Resources File in the assembly. Because the initial
FORM_NAME.Resources File Was Never created or Linked 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 Success. 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
Reperse the class of the main form to the forefront, the problem is solved. ^ _ ^