0

I got an issue which already cost me some evenings to resolve. I migrated a ASP.NET Web Project to a Web Application.

My main issue are the .resx files below App_GlobalResources. Let's say that I have MyStrings.resx (= default culture) and MyStrings.en.resx (yes, english is not my default).

If I create the files in the solution in Solution Explorer with "Add...", I am getting the following settings: * Build Action: Content * Custom Tool: GlobalResourceProxyGenerator

I would guess that the default setting is fine for most cases but I already have two issues with that: a) If I leave the Build Action as "Content", I will get a MissingManifestResourceException when using ResourceManager.GetString in code. Solution: Change it to "EmbeddedResource". b) The GlobalResourceProxyGenerator seems to missing on my computer. If I choose "Run Custom Tool" on the .resx I get the error message "Cannot find custom tool '...' on this system. Great. Solution: Change it to "PublicResXFileCodeGenerator". This works.

Now, if I leave the setting at PublicResXFileCodeGenerator, everything compiles but when I run the solution (IIS and VS Express 2013 for Web) I get the friendly message that I got "Resources.MyStrings" both in MyWebSite.dll and in App_GlobalResources.dll.

OK, I change the Custom Tool to "ResXFileCodeGenerator". Now, everything's working fine. I am now deploying the solution to the webserver. There I get CS0122: Resources.MyStrings is inaccessible due to its protection level. That's probably due to it's "internal" declaration.

By now I am completely lost. Any help to clean up the situation?

Environment: IIS locally and online VS Express 2013 for Web Two languages. For both the settings are: Build Action: Embedded Resource Copy to Output Directory: Do not copy Custom Tool: ResXfileCodeGenerator Custom Tool Namespace: Resources

For the generated designer files (only default language) the settings are: Build Action: Compile Copy to Output Directory: Do not copy

Any help is appreciated

4

1 回答 1

0

我并没有真正找到我的麻烦的根源,但我找到了一个很好的解决方法。核心问题可能是在 MyWebsite.dll 和 App_GlobalResoures.dll 中都存在 Resources.MyStrings 类。我没有找到确保您只获得一次的预期设置。

我的解决方案:我创建了一个“资源”文件夹,复制了我所有的 .resx 文件并删除了 App_GlobalResources。也适用于不同的语言。

为什么有一个“App_Globalresources”文件夹?

于 2015-01-24T21:52:51.577 回答