Getting “Could not find any resources “error while using some resource files to make the internationalization of a ASP.NET application

If you getting this error “Could not find any resources appropriate for the specified culture (or the neutral culture) in the given assembly. Make sure …” while trying to load Resources using ResourceManager from multi language assemblies it’s usually caused by loading the Resource file with this code:

 

<code>

ResourceManager resources = new ResourceManager(

                "<ResName>",

                Assembly.GetExecutingAssembly(),

                null );

 

</code>

 

While this code is suggested by MSDN : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemResourcesResourceManagerClassctorTopic4.asp, it’s missing the <WebProjectName>. So it should be like this:

 

ResourceManager resources = new ResourceManager(

    "<WebProjectName>.<ResName>",

     Assembly.GetExecutingAssembly(),

     null );

 

Where the resx files are named: <ResName>.<Culture>.resx

 

It’s also recommended to create only a single instance of the ResourceManager for your web app and to keep ResourceManager in a static class member or the Application object.  This causes the resources to be loaded only once per application.

28 Comments

  • I've also looked into the Microsoft localization toolkit, which adds some significant ease of use to localization issues. Recommended.

  • dear sir

    i ahve created two res file one for german and one for french, and added these two files in my project ,

    but its getting an error

    error is



    Could not find any resources appropriate for the specified culture (or the neutral culture) in the given assembly. Make sure &quot;TextRes.fr.resx.resources&quot; was correctly embedded or linked into assembly &quot;VBLocalLization&quot;. baseName: TextRes.fr.resx locationInfo: &lt;null&gt; resource file name: TextRes.fr.resx.resources assembly: VBLocalLization, Version=1.0.1495.16943, Culture=neutral, PublicKeyToken=null



    This is my code





    Public Function InitializeResources()

    assembly1 = [Assembly].GetExecutingAssembly()

    _resourceManager = New ResourceManager(&quot;TextRes.fr.resx&quot;, assembly1) _resourceManager.IgnoreCase = True

    End Function

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    'Put user code to initialize the page here

    InitializeResources()



    Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(&quot;fr-FR&quot;)

    Thread.CurrentThread.CurrentUICulture = New CultureInfo(&quot;fr-FR&quot;)

    Label1.Text = _resourceManager.GetString(&quot;Client Name&quot;)

    Label1.Text = Label1.Text + _resourceManager.GetString(&quot;holiday name&quot;)

    End Sub

  • You are missing the &lt;WebProjectName&gt; in front of resource file name :

    _resourceManager = New ResourceManager(&quot;MyAssembly.TextRes.fr.resx&quot;, assembly1)

  • Thanks for this Blog!



    I looked everwhere for this fix!



    Cheers.

    Stonie.

  • I copy this code in a new project it work fine but with old project it still have error.

    Any help is appreciate.

  • Thanks,



    It really helped me. It worked instantly after some frustrating letter by letter checking of the 'sacred MSDN' (and other samples from gotdotnet) code...

  • Thank you, I finally got my multilingual web app working.



    Something to note is that &lt;WebProjectName&gt; needs to be the complete namespace to the project



    E.g.:



    namespace A.B.C

    {

    public class MyForm

    {

    protected ResourceManager gResourceManager = new ResourceManager(&quot;A.B.C.&lt;ResName&gt;&quot;,typeof(MyForm).Assembly);

    .

    .

    .

    }

    }



    Cheers,



    Eusebio

  • Great post! You just answered a problem I was having in a Windows application. It's not multilingual or anything special at all. I just created a control that needed a form inside it. In the InitializeComponents() method is a line similar to this:



    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(&lt;ControlName&gt;));



    All I had to do, and your post is what answered it for me, was this:



    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(&lt;Full.Namespace&gt;.&lt;ControlName&gt;));



    Thanks again

  • I got the same problem, eventually I found out you need to right click on your project in VS and find your &quot;default namespace&quot;. Insert the name before the resource name as &quot;MyDefaultNamSpace.stringtable.resx&quot;.

  • i had this problem and solved it
    the problem staarted after i wrote in Interface for the class i was using

    hard to belive but
    what caused the error was actually writing the interface over the class in the code file
    after copy and pasting the code for the interface and replacinh it under the code for the class i didnt get this error any more.

    hope it helps

  • EXCELLENT! Thank you. This problem cropped up when I converted a VS 2003 project to a VS 2005 project. The code:


    ResourceManager resources = new ResourceManager(
    "",
    Assembly.GetExecutingAssembly(),
    null );


    worked fine in VS 2003, but not in VS 2005. NONE of the other forums, blogs, etc. I searched had the answer. THANKS AGAIN!!

  • Hi,
    I'm not using any localization and any ResourceManager stuff. but i'm getting it when i deploy the application, "sdkerrors.resource" was correctly embedded ... i never seen this error before, can anyone help me?
    thanks

  • use
    new ResourceManager(Resources._string.ResourceManager.BaseName, Assembly.GetExecutingAssembly())

    instaed of
    New ResourceManager("TextRes.fr.resx", Assembly.GetExecutingAssembly())

    it works for me....

  • Hi I have done the same but not resolve my problem.
    It is comming in the same way.

  • I am getting the exception like
    Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "SatelliteAssemblies.string.resources" was correctly embedded or linked into assembly "App_Web__c7iornx" at compile time, or that all the satellite assemblies required are loadable and fully signed.

  • i am gettting the same problem

  • pleaze someone POST CODE THAT WORKED FOR HIM>HER.

  • This is my code

    public partial class MultilingualPage : System.Web.UI.Page
    {
    public ResourceManager rm;
    protected void Page_Load(object sender, EventArgs e)
    {
    CultureInfo ci;
    if (!IsPostBack)
    {
    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
    rm = new ResourceManager("TheWorks.UI.MultilingualPage.aspx.en.resx",Assembly.GetExecutingAssembly(),null);
    ci = Thread.CurrentThread.CurrentCulture;
    LoadData(ci);
    }
    else
    {
    rm = new ResourceManager("TheWorks.UI.MultilingualPage.aspx.en.resx", Assembly.GetExecutingAssembly(),null);
    ci = Thread.CurrentThread.CurrentCulture;
    LoadData(ci);

    }
    }
    protected void LinkEnglish_Click(object sender, EventArgs e)
    {
    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
    LoadData(Thread.CurrentThread.CurrentCulture);
    //Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
    //LoadData(Thread.CurrentThread.CurrentUICulture);
    }
    protected void LinkFrench_Click(object sender, EventArgs e)
    {
    Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
    LoadData(Thread.CurrentThread.CurrentCulture);
    //Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
    //LoadData(Thread.CurrentThread.CurrentUICulture);
    }

    public void LoadData(CultureInfo ci)
    {
    lblName.Text = rm.GetString("lblNameResource1", ci);

    }


    }




    getting the same error .
    Please help anyone

  • Excelente, estoy con este problema hace horas y he probado varias cosas que dicen por Internet pero esta fue la que realmente funcionó. Gracias!!

  • i included resoource files (In /obj folder
    those are excluded earlier )then i got error. so i excuded those files now application is working

  • I got the same error once because I included the debug and obj folders to the project. When the debug and obj folders are excluded project became normal

  • This Solution is a sure shot.
    Great.
    Thanks

  • I have converted from vs 2003 to 2010 after am getting some exception message.
    {"Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Infrature.Learning.CourseBuilder.SplashForm.resources" was correctly embedded or linked into assembly "Infrature.Learning.CourseBuilder" at compile time, or that all the satellite assemblies required are loadable and fully signed."}, please help me

  • Great article! We will be linking to this particularly great article on our website.
    Keep up the great writing.

  • Greetings from Ohio! I'm bored to death at work so I decided to check out your site on my iphone during lunch break. I really like the information you present here and can't wait to take a look when I get home.
    I'm amazed at how quick your blog loaded on my cell phone .. I'm not even using
    WIFI, just 3G .. Anyways, amazing site!

  • Now I am going away to do my breakfast, after having my breakfast
    coming over again to read other news.

  • SAY THANKS A LOT for returning this to my eyes, my children
    will benefit a lot.

  • My family all the time say that I am wasting my time here at net, but
    I know I am getting experience everyday by reading thes fastidious articles.

Comments have been disabled for this content.