我需要 resx Designer.cs 文件吗? [英] Do I need the resx Designer.cs file?

查看:23
本文介绍了我需要 resx Designer.cs 文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司使用一些数据库表、网页前端和导出"应用程序的组合来处理我们网站中的字符串资源.

当我们使用 VS2008 时,导出应用程序过去可以正常工作,但自从切换到 VS2010 后,资源现在在解决方案资源管理器中的下方"有一个 Designer.cs 文件.

问题是导出"应用程序只生成 .resx 文件,而不是底层的 Designer.cs 文件.

那么,有没有办法不让那些designer.cs文件,或者某种方式自动重新生成(或者甚至是导出应用程序可以调用的一些命令来重新生成它们)

解决方案

从 MSDN 我们有:

将资源编译成程序集<块引用>

当您构建应用程序时,Visual Studio 会调用resgen.exe 用于转换应用程序的工具资源成内部的类称为资源.这门课是包含在 Resources.Designer.cs 中嵌套在解决方案中的 Resources.resx 文件探险家.资源类封装您的所有项目资源变成静态只读获取属性作为提供的一种方式运行时的强类型资源.当您通过 Visual C# 构建时IDE,所有封装的资源数据,包括资源嵌入到 .resx 文件中的那些和链接的文件,被编译直接进入应用程序集(.exe 或 .dll 文件).其他话说,Visual C# IDE 总是使用/resource 编译器选项.如果你从命令行构建,你可以指定/linkresource 编译器使您能够部署的选项资源在一个单独的文件中主要应用程序集.这是一高级场景并且只是在某些罕见的情况下是必要的.

My company uses a combination of some database tables, a web page front end and an "export" application to handle our string resources in our web sites.

The export application used to work just fine when we used VS2008, but since switching to VS2010 the resources now have a designer.cs file "beneath" them in the solution explorer.

The problem is that the "export" application only generates the .resx files and not the underlying designer.cs files.

So, is there a way to not have those designer.cs files, or alternatively some way to automatically re-generate (or even some command the export application could call to re-generate them)

解决方案

From MSDN we have:

Compiling Resources into Assemblies

When you build your application, Visual Studio invokes the resgen.exe tool to convert your application resources into an internal class called Resources. This class is contained in the Resources.Designer.cs file which is nested under the Resources.resx file in Solution Explorer. The Resources class encapsulates all your project resources into static readonly get properties as a way of providing strongly-typed resources at run-time. When you build through the Visual C# IDE, all the encapsulated resource data, including both the resources that were embedded into the .resx file and the linked files, is compiled directly into the application assembly (the .exe or .dll file). In other words, the Visual C# IDE always uses the /resource compiler option. If you build from the command line, you can specify the /linkresource compiler option that will enable you to deploy resources in a separate file from the main application assembly. This is an advanced scenario and is only necessary in certain rare situations.

这篇关于我需要 resx Designer.cs 文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆