![](/img/trans.png)
[英]c# properties/settings not defined after changing project name and namespace
[英]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
。
聽起來好像您已經通過項目屬性窗口的相應選項卡下添加了Settings
和Resources
文件(可以在其中為這些項目添加默認文件)。 當您以這種方式執行此操作時,名稱.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.