DCSIMG
"Could not find any resources appropriate for the specific culture (or neutral culture) in the given assembly" error - IronShay

"Could not find any resources appropriate for the specific culture (or neutral culture) in the given assembly" error

I had ran into this error a few days ago and spent a few hours until I figured out what the problem was. But eventually I did!

The problem
I had built a win form, added a few resources for different languages and tested it out. When trying to load this form, I realized that the InitializeComponents method had failed. The error was "Could not find any resources appropriate for the specific culture (or neutral culture) in the given assembly.".

The way to the solution
After hours of re-building, clearing, deleting, GACing, restarting and other headache-causing actions, I decided to look into the built resources file using the Reflector. I found out that the name of my resource was wrong...

The cause
When building the form, I added before the form's class another class (for my event args). The name of the resource was named after the event args class and not the UI class, resulting in the error mentioned above...

The solution
Moving the event args class below the UI class solved the problem. Why? I really don't know, but I guess that Microsoft assumes that the UI class is the first in the source file and they've just forgotten to tell us about it.

Conclusion
Keep the next structure in mind when developing win-forms:

class UIClass
{
    // ...
}

// All other classes below the UI class!
class MyEventArgs : EventArgs
{
    // ...
}
// ...

Take care,
Shay

Published Thursday, July 26, 2007 10:35 AM by shayf
תגים:, ,

Comments

# "Could not find any resources appropriate for the specific culture (or neutral culture) in the given assembly" error

"Could not find any resources appropriate for the specific culture (or neutral culture) in the given assembly" error

Saturday, February 14, 2009 9:44 AM by Shay Talks About .Net

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: