在另一个项目中,我有一些使用名称 Properties
的类,因此当预生成的“设置”和“资源”属性命名空间妨碍时,使用它们会变得很麻烦。有没有办法强制此命名空间在修改资源或设置后仍保持重命名?
以下是导致问题的文件。
Resources.Designer.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectNamespace.Properties {
using System;
Settings.Designer.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectNamespace.Properties {
如果还不清楚。我想重命名 Properties
,而不是 ProjectName
。
最佳答案
听起来您已经通过项目属性窗口的相应选项卡(您可以在其中添加这些项目的默认文件)添加了 Settings
和 Resources
文件。当您这样做时,名称 .Properties
将附加到命名空间,并且它们组织在 Solution Explorer< 中项目的
:Properties
节点下
相反,请尝试将它们添加为单独的项目项。为此,请右键单击您的项目,选择Add --> New Item
,选择Visual C# Items
下的General
标题,然后然后您可以添加新的资源文件
和/或设置文件
:
这些文件将像任何其他项目一样添加到您的项目中(不在 Properties
节点下),并将使用项目的默认命名空间,并且不会添加 .Properties
到它:
关于c# - 如何永久重命名 C# 项目的 Properties 命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47319295/