Why am I getting App_GlobalResources assembly generated? (Error = CS0433)

别来无恙 提交于 2019-11-28 10:00:49

问题


I'm working on a ASP.NET MVC2 project, for which I have configured the localisation as follows ...


I have a separate Resources assembly, containing all my resx files. The settings for each resx file are...
Build Action             = Embedded Resource
Copy to Output Directory = Do not copy
Custom Tool              = PublicResXFileCodeGenerator
Custom Tool Namespace    = Resources

I have a tool which exports the strings from a database into the resx files and calls the resgen.exe tool to recreate the designer.cs file.


This all worked great, even when I changed the language settings of my browser and refreshed the page. It would pick up the correct strings.

That was in a temporary working folder (I use subversion). I've now moved to working in my normal folder and am getting a rather odd error.

Compiler Error Message: CS0433: The type 'Resources.XXXX' exists in both 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\6c657d01\aaca70ae\assembly\dl3\a36dac65\78c87110_3724cb01\Resources.DLL' and 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\6c657d01\aaca70ae\App_GlobalResources.g6fehiio.dll'

I have deleted all of my temporary asp.net files, re-run the web app and it regenerates both of the above mentioned assemblies. The really odd thing is that this all worked before I moved to my usual working folder.

So, can anyone tell me what is generating this App_GlobalResources assembly, which I don't need or want, because all my resources are contained in the Resources assembly I've created.

PS - The reason I went with Resources.dll was to get around a problem I was having with generating the resources using my database extract tool. (see here)

PPS - I am using VS2010


回答1:


doh!

I think when I switched my "usual working folder" to the branch this was in, I had some files in a "App_GlobalResources" folder.

I just tried to create a new App_GlobalResources folder in VS2010 and it told me there was already one there, but it wasn't in the solution explorer.

I looked in windows explorer a number of times and just didn't see that folder.

Anyway, problem solved!

moral: don't trust solution explorer or svn switch to delete files that don't belong in the working copy :'(




回答2:


Although I do not know how to stop App_GlobalResources automatically generationg assemblies in Temporary ASP.NET files. I did figure out how to get rid of those annoying warnings.

As the warning says:

Compiler Error Message: CS0433: The type 'Resources.XXXX' exists in both 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\6c657d01\aaca70ae\assembly\dl3\a36dac65\78c87110_3724cb01\Resources.DLL' and 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\6c657d01\aaca70ae\App_GlobalResources.g6fehiio.dll'

The type Resources.XXXX exists in both assemblies. Change your Custom Tool Namespace to be something other than "Resources" and these warnings will dissappear.




回答3:


  1. Move the .resx to another folder (not App_GlobalResources)
  2. Keep the Custom Tool Namespace set to 'Resources'


来源:https://stackoverflow.com/questions/3263981/why-am-i-getting-app-globalresources-assembly-generated-error-cs0433

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!