簡體   English   中英

如何永久重命名C#項目的Properties命名空間

[英]How to permanently rename C# project's Properties namespace

在另一個項目中,我有使用名稱Properties類,因此當預生成的Settings和Resources的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

聽起來好像您已經通過項目屬性窗口的相應選項卡下添加了SettingsResources文件(可以在其中為這些項目添加默認文件)。 當您以這種方式執行此操作時,名稱.Properties會附加到命名空間中,並且它們會組織在“ Solution Explorer ”中項目的“ Properties節點下:

在此處輸入圖片說明

而是嘗試將它們添加為單獨的項目。 為此,請右鍵單擊您的項目,選擇“ Add --> New Item ,在“ Visual C# Items下選擇“ General標題,然后可以添加新的Resources File和/或Settings File

在此處輸入圖片說明

這些文件將像其他任何項一樣添加到您的項目中(不在“ Properties節點下),並且將使用項目的默認名稱空間,並且不會向其中添加.Properties

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM