首先为VS安装上这2个插件ResXFileCodeGeneratorComment.msi ResXFileCodeGeneratorEx.msi
然后新建个Resx文件,例如 CarrierCode.Resx这个文件主要是记录些,错误代码以及说明.
右键该CarrierCode.Resx的属性将 在自定义工具这栏ResXFileCodeGenerator改为ResXFileCodeGeneratorComment.
原代码
namespace WcfServer.Common.Resource { using System; ////// 强类型资源类,用于查找本地化字符串等。 /// // 此类是由 StronglyTypedResourceBuilder // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // (以 /str 作为命令选项),或重新生成 VS 项目。 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resource1 { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resource1() { } ////// 返回此类使用的缓存 ResourceManager 实例。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WcfServer.Common.Resource.Resource1", typeof(Resource1).Assembly); resourceMan = temp; } return resourceMan; } } ////// 为使用此强类型资源类的所有资源查找 /// 重写当前线程的 CurrentUICulture 属性。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } } }
更改后的代码为
//------------------------------------------------------------------------------ // // 此代码由工具生成。 // 运行库版本:2.0.50727.1433 // // 对此文件的更改可能会导致不正确的行为,并且如果 // 重新生成代码,这些更改将会丢失。 // //------------------------------------------------------------------------------ namespace WcfServer.Common.Resource { using System; ////// A strongly-typed resource class, for looking up localized strings, formatting them, etc. /// // This class was auto-generated by the StronglyTypedResourceBuilderComment class via the ResXFileCodeGeneratorComment custom tool. // To add or remove a member, edit your .ResX file then rerun the ResXFileCodeGeneratorComment custom tool or rebuild your VS.NET project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("DMKSoftware.CodeGenerators.Tools.StronglyTypedResourceBuilderComment", "2.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public sealed class CarrierCode { private static global::System.Resources.ResourceManager _resourceManager; private static global::System.Globalization.CultureInfo _resourceCulture; public const string aaa = ((string)("1000")); private CarrierCode() { } ////// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(_resourceManager, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WcfServer.Common.Resource.CarrierCode", typeof(CarrierCode).Assembly); _resourceManager = temp; } return _resourceManager; } } ////// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Globalization.CultureInfo Culture { get { return _resourceCulture; } set { _resourceCulture = value; } } ////// Get value by name! /// public static object GetValue(string name) { return ResourceManager.GetObject(name, _resourceCulture); } } }