473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Runtime exception System.Resources.MissingManifestResourceExceptio

I have found a strange resource problem, but luckily I have also found the
solution which was not obvious from the runtime exception. I really think
that the compiler should pick up this problem and fix it. What do you people
think? Try the following:

1. Create a new c# windows application called MyTestApp
2. Create a notifyIcon on the form
3. Attach any icon you wish to the notifyIcon
4. Build and run the program to confirm that it works.

*** Causing the problem ***

5. In Form1.cs change the namespace to MyNewNamespace
6. Let's say that your form class needs to use an enum definition. If your
from a C/C++ background you would define this before the Form1 Class
defintion therefore, just after the namespace line and before the Form1 class
definition type the following

public enum eTest
{
Test1,
Test2
};

This enum and its contents are not critical to producing the problem just
the fact that it is before the form definition is enough. Adding a class here
also cuases the problem.

7. Compile and run the program again. The following exception is thrown:

Unhandled Exception: System.Resources.MissingManifestResourceException:
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 "MyTestApp".
baseName: Form1 locationInfo: MyNewNamespace.Form1 resource file name:
Form1.resources assembly: MyTestApp, Version=1.0.1796.23855,
Culture=neutral, PublicKeyToken=null
at System.Resources.ResourceManager.InternalGetResour ceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.InternalGetResour ceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.InternalGetResour ceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo
culture)
at System.Resources.ResourceManager.GetObject(String name)
at MyNewNamespace.Form1.InitThe program '[3376] MyTestApp.exe' has exited
with code 0 (0x0).
ializeComponent() in c:\projects\testapps\mytestapp\form1.cs:line 64
at MyNewNamespace.Form1..ctor() in
c:\projects\testapps\mytestapp\form1.cs:line 29
at MyNewNamespace.Form1.Main() in
c:\projects\testapps\mytestapp\form1.cs:line 85

*** Fixing the problem ***

8. To fix the problem either:
a) Change the namespace in the form1.cs file back to MyTestApp.
b) Move the enum definition AFTER the form1 class definition.
c) Go to the project properties under Project->Properties on the menus.
Select Common Properties/General and set the default namespace to
MyNewNamespace and click OK
compile and run the program again and it works!

I believe that the compiler should be able to see this problem and ask you
to change the Default namespace under the project settings or it says it can
change it for you if you click OK. The above exception is a little misleading
to the actual problem that has occured. In many cases people from a C or C++
background will want to declare the enum definition before the class
definition if the class was to use it as this is the way C & C++ likes to do
things.

It seems that if the Enum was place after the form class definition then the
namespace that is defined in the Form1.cs file is used otherwise it uses the
one from the project settings!

Is there a reason for this? Would anyone like to comment?
Jul 21 '05 #1
1 4380
This is a known "feature":
http://support.microsoft.com/default...b;en-us;318603

Regards, Jakob.
"DelboyJay" wrote:
I have found a strange resource problem, but luckily I have also found the
solution which was not obvious from the runtime exception. I really think
that the compiler should pick up this problem and fix it. What do you people
think? Try the following:

1. Create a new c# windows application called MyTestApp
2. Create a notifyIcon on the form
3. Attach any icon you wish to the notifyIcon
4. Build and run the program to confirm that it works.

*** Causing the problem ***

5. In Form1.cs change the namespace to MyNewNamespace
6. Let's say that your form class needs to use an enum definition. If your
from a C/C++ background you would define this before the Form1 Class
defintion therefore, just after the namespace line and before the Form1 class
definition type the following

public enum eTest
{
Test1,
Test2
};

This enum and its contents are not critical to producing the problem just
the fact that it is before the form definition is enough. Adding a class here
also cuases the problem.

7. Compile and run the program again. The following exception is thrown:

Unhandled Exception: System.Resources.MissingManifestResourceException:
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 "MyTestApp".
baseName: Form1 locationInfo: MyNewNamespace.Form1 resource file name:
Form1.resources assembly: MyTestApp, Version=1.0.1796.23855,
Culture=neutral, PublicKeyToken=null
at System.Resources.ResourceManager.InternalGetResour ceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.InternalGetResour ceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.InternalGetResour ceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo
culture)
at System.Resources.ResourceManager.GetObject(String name)
at MyNewNamespace.Form1.InitThe program '[3376] MyTestApp.exe' has exited
with code 0 (0x0).
ializeComponent() in c:\projects\testapps\mytestapp\form1.cs:line 64
at MyNewNamespace.Form1..ctor() in
c:\projects\testapps\mytestapp\form1.cs:line 29
at MyNewNamespace.Form1.Main() in
c:\projects\testapps\mytestapp\form1.cs:line 85

*** Fixing the problem ***

8. To fix the problem either:
a) Change the namespace in the form1.cs file back to MyTestApp.
b) Move the enum definition AFTER the form1 class definition.
c) Go to the project properties under Project->Properties on the menus.
Select Common Properties/General and set the default namespace to
MyNewNamespace and click OK
compile and run the program again and it works!

I believe that the compiler should be able to see this problem and ask you
to change the Default namespace under the project settings or it says it can
change it for you if you click OK. The above exception is a little misleading
to the actual problem that has occured. In many cases people from a C or C++
background will want to declare the enum definition before the class
definition if the class was to use it as this is the way C & C++ likes to do
things.

It seems that if the Enum was place after the form class definition then the
namespace that is defined in the Form1.cs file is used otherwise it uses the
one from the project settings!

Is there a reason for this? Would anyone like to comment?

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: VinnieT | last post by:
I have a load balanced system that consists of 3 production servers. There are about 20 different applications that are used on these boxes. One of my applications in particular is used more than...
3
by: Shailaja Kulkarni | last post by:
hi All, This problem is for C# windows application. I have a user control whcih contains one picture box along with other controls. Depending on certain conditions I want to change images on the...
0
by: Joe | last post by:
Reposting here as there were no useful replies in the dotnet.framework NG... What is the correct pattern for handling exceptions in IDisposable.Dispose, especially in a class that manages...
1
by: Samuel R. Neff | last post by:
We just started getting NullReferenceException in one of our applications on our demo server. This is occuring in a .NET Windows Service that is using binary remoting over TCP to talk to another...
4
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server...
1
by: DelboyJay | last post by:
I have found a strange resource problem, but luckily I have also found the solution which was not obvious from the runtime exception. I really think that the compiler should pick up this problem...
7
by: Martin Robins | last post by:
I am currently looking to be able to read information from Active Directory into a data warehouse using a C# solution. I have been able to access the active directory, and I have been able to return...
2
by: Steve | last post by:
This is a weird one. I have a series of "SmartParts" which are CAB (Composite Application Block) Views which are finally just UserControls (99% of the time) Anyway, I layout my UserControl in...
1
by: Phill W. | last post by:
Can anyone supply me with the code (C# or VB) that lies within the Exception.ToString() method? I'm writing Custom Exception classes and want to ensure that mine will be consistent (as far as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.