Could not find any resources appropriate for the specified culture or the neutral culture

后端 未结 30 1491
旧巷少年郎
旧巷少年郎 2020-11-28 20:15

I have two ASP.NET Web projects (ProjectA and ProjectB). When class in ProjectA is instantiating a class of ProjectB which uses a resource file Blah.resx, I get this error:

30条回答
  •  感情败类
    2020-11-28 20:57

    For me the problem was copying .resx files and associated .cs files from one project to another. Both projects had the same namespace so that wasn't the problem.

    Finally solved it when I noticed in Solution Explorer that in the original project the .resx files were dependent on the .cs files:

    MyResource.cs
    |_ MyResource.resx
    

    While in the copied project the .cs files was dependent on the .resx files:

    MyResource.resx
    |_ MyResource.cs
    

    It turned out that in the second project somehow the .resx files had been set to auto-generate the .cs files. The auto-generated .cs files were overwriting the .cs files copied from the original project.

    To fix the problem edit the properties of each .resx file in the copied project. The Custom Tool property will be set to something like ResXFileCodeGenerator. Clear the Custom Tool property of the .resx file. You will need to re-copy the .cs file from the original project as it will have been overwritten by the auto-generated file.

提交回复
热议问题