|
 |
 |
 |
 |
Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms
of Use |
Trademarks
Article ID: 839861 - Last Review: May 18, 2007 - Revision: 1.11 A System.Resources.MissingManifestResourceException exception occurs when you try to access a localized resourceIn a Microsoft ASP.NET application, when you try to access a
localized resource, a System.Resources.MissingManifestResourceException exception may occur, and your Web browser may display an error
message that is similar to the following error message: Server Error in '/MyApp'
Application.
Could not find any resources appropriate for the
specified culture (or the neutral culture) in the given assembly. Make sure
"MyApp.strings.resources" was correctly embedded or
linked into assembly "MyApp". baseName:
MyApp.strings locationInfo: <null> resource
file name: MyApp.strings.resources assembly:
MyApp,
Version=VersionNumber, Culture=neutral,
PublicKeyToken=null
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Resources.MissingManifestResourceException: Could not find
any resources appropriate for the specified culture (or the neutral culture) in
the given assembly. Make sure
"MyApp.strings.resources" was correctly embedded or
linked into assembly "MyApp". baseName:
MyApp.strings locationInfo: <null> resource
file name: MyApp.strings.resources assembly:
MyApp,
Version=VersionNumber, Culture=neutral,
PublicKeyToken=null
Notes- In the error message, MyApp is a
placeholder for the name of your ASP.NET application.
- In the earlier error information,
VersionNumber is a placeholder for the version
number of the primary assembly for your application.
This problem occurs if you use a localized resource that
exists in a satellite assembly that you created by using a .resources file that
has an inappropriate file name. This problem typically occurs if you manually
create a satellite assembly. To manually create a satellite assembly,
you must first run the Resource File Generator (Resgen.exe), and then you must
run the Assembly Linker (Al.exe). When you run Resgen.exe, if you do not
specify the file name of the output file while you convert an XML-based
resource format (.resx) file to a .resources file, Resgen.exe creates a
.resources file that has the same file name as the input file. If the file name
of your XML-based resource format file does not start with the namespace name
of your application, the file name of the .resources file will not contain this
namespace name either. You may run Al.exe to create a satellite assembly that
contains the localized resources that exist in the .resources file. However,
when you try to access a localized resource that exists in the satellite
assembly, the behavior that is mentioned in the "Symptoms" section
occurs. To work around this problem, specify the file name of the
.resources file when you run Resgen.exe. While you specify the file name of the
.resources file, make sure that the file name starts with the namespace name of
your application. For example, run the following command at the Microsoft
Visual Studio .NET command prompt to create a .resources file that has the
namespace name of your application at the beginning of the file name: Resgen
strings.CultureIdentifier.resx
MyApp.strings.CultureIdentifier.resources Notes- In this example,
CultureIdentifier is a placeholder for an identifier
(such as "ja") that you can use to specify the culture for your
resources.
- In the earlier command, MyApp is
a placeholder for the namespace name of your application.
This
behavior is by design. Steps to reproduce the behavior- Create an ASP.NET Web Application project that uses a
localized resource. To do this, follow these steps:
- Start Visual Studio .NET.
- Use Microsoft Visual Basic .NET or Microsoft Visual C#
.NET to create an ASP.NET Web Application project that is named MyApp. By
default, a Web form that is named WebForm1.aspx is created.
- In Solution Explorer, right-click
WebForm1.aspx, and then click View Code. The
code window opens.
- If you are using Visual Basic .NET, add the following
code at the top of the code window:
Imports System.Reflection
Imports System.Diagnostics
Imports System.Resources
Imports System.Threading
Imports System.Globalization If you are using Visual C# .NET, add the following code at the top of
the code window:using System.Reflection;
using System.Diagnostics;
using System.Resources;
using System.Threading;
using System.Globalization; - If you are using Visual Basic .NET, add the following
code to the Page_Load event handler to try to access your localized resource:
Thread.CurrentThread.CurrentUICulture = New CultureInfo("ja")
Dim rm As ResourceManager = New ResourceManager("MyApp.strings", System.Reflection.Assembly.Load("MyApp"))
Response.Write("Hello: " + rm.GetString("myVar")) If you are using Visual C# .NET, add the following code to the Page_Load event handler to try to access your localized resource:Thread.CurrentThread.CurrentUICulture = new CultureInfo("ja");
ResourceManager rm = new ResourceManager("MyApp.strings",Assembly.Load("MyApp"));
Response.Write("Hello: " + rm.GetString("myVar")); - On the Build menu, click Build
MyApp.
- Create an XML-based resource format file that contains a
localized resource. To do this, follow these steps:
- On the Project menu, click Add
New Item. The Add New Item - MyApp dialog box
appears.
- Under Templates, click
Assembly Resource File.
- In the Name box, replace the existing
text with strings.ja.resx, and then click
Open. The Data view of the strings.ja
XML-based resource format file appears.
- In the Data view, under
name, type myVar.
- In the Data view, under
value, type Japanese.
- On the File menu, click Save
strings.ja.resx.
- Create a satellite assembly that contains a localized
resource. To do this, follow these steps:
- In Solution Explorer, right-click
strings.ja.resx, and then click Exclude From
Project.
- In the root folder of drive C on your computer, create
a folder that is named MyTemp.
- Move the strings.ja XML-based resource format file that
you saved in step 2f to the MyTemp folder.
Note The strings.ja XML-based resource format file typically exists in
the MyApp folder where your other project files exist. - Start a Visual Studio .NET command prompt.
- At the Visual Studio .NET command prompt, run the
following command to create a .resources file:
Resgen
strings.ja.resx - At the Visual Studio .NET command prompt, run the
following command to create the MyApp.resources.dll satellite assembly that
contains your localized resources:
Al.exe /t:lib
/embed:strings.ja.resources /culture:ja
/out:MyApp.resources.dll
- Try to access the localized resource. To do this, follow
these steps:
- In the Bin folder of the MyApp folder where you created
your project files, create a folder that is named JA.
- Move the MyApp.resources.dll satellite assembly that
you created in step 3f to the JA folder.
- Switch to Visual Studio .NET.
- On the Debug menu, click
Start. Your Web browser opens, and the behavior that is
mentioned in the "Symptoms" section occurs.
For more information, visit the following Microsoft
Developer Network (MSDN) Web sites:
APPLIES TO- Microsoft ASP.NET 1.1
- Microsoft ASP.NET 1.0
| kblocalization kbresource kbsample kberrmsg kbcode kbprb KB839861 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
|
 |
 |
 |
 |
 |
 |
 |
| |