当前位置:网站首页>C migration project record: modify namespace and folder name
C migration project record: modify namespace and folder name
2022-04-23 20:24:00 【First code】
C# To modify the file name and namespace of the project, it seems that Java IDE Modifying the package name is as simple as , Directly modifying the local folder and other operations to migrate the project will cause the solution to not open or namespace configuration and other errors after opening and running .
Recently, it is often necessary to migrate the project framework , Occasionally, you need to rename the project namespace , According to the online information and after successful operation , Record the following actions , For memory and learning :
To be modified C# Namespace and file name , Need experience Change solution name -> Project name -> Change namespace name -> Folder name several steps , The specific operation is as follows :
1) Change solution name
This simple , open VS after , Directly on the solution , Right click - rename
2) Modify project name
This is also simple , Similar to the above , Just select the specific project name under the solution , Right click - Just rename . The key to this local problem is , We go through VS After modifying the project name, it is generally assumed that the name of the local folder will also change , There is no , It just changed VS The displayed item name , The corresponding folder name and namespace name are unchanged .( Therefore, the namespace and folder name will be modified later )
3) Modify namespace name
3-1 Modify code namespace name
Namespace name modification is critical , think .cs The code starts with a namespace index , If the namespace is incorrect , That can't run directly , This operation is also a bit confusing , Even if it's a trick .
Open one .cs Program files , Found namespace namespace, Change it to the name you want , After modification, a small red box with an error will appear in the namespace , Here's the picture
There is an error , Obviously not yet , Click on the... Box , There will be a selection that allows you to duplicate all namespaces under this project , You click on it , The namespaces of program files that already exist in all projects have been renamed , The namespace is automatically modified .
3-2 Modify the default namespace name in the project properties
3-1 although , Complete the modification of namespace , however C# It's still a pit ,( Not as good as java The same package name has been modified , It's all right ). We also need to change the default namespace name in the project properties , In this way, after creating a new program file, you can ensure that the namespace name is correct .
Right click the project name -> attribute , Change your name to what you want , And the previous namespace , It's better to have the same name as the folder , This is more convenient .(ctrl+s preservation )
4 Modify the name of the folder
The front by VS Complete namespace and other changes , however VS The folder name will not be changed automatically ( Generally, we will match the namespace name with the folder name ), We need to modify it manually .
close VS, Find the location where the item is stored on the computer , Click on the solution name .sln Solution file for , Configure the local folder name , If we want to change the folder name , This place should also be modified synchronously and manually , Otherwise, the program cannot be opened .
Solution name .sln, Right click Notepad to open ,
After the save , You can change the name of the local folder , Then reopen the project .
follow-up :
When it's done , The new project can basically run , I don't have a request to jump in, but I won't , In fact, you can't enter the specified back-end service , Printed through the browser console log It can be seen that it is 500 error , The error you see after clicking is as follows :
This error is that the corresponding request service cannot be found , As you can see from the above, there is conflict , Make the code overwhelmed , I don't know which one to use , The reason for this is that we changed the namespace , There are also some sequelae of file namespaces , For example .ashx Of xml The original namespace remains in :
The solution is , Make a complete replacement of the solution :
At the same time, the solution bin Under the folder , Delete the project package left by the previous namespace compilation :
reference :C# How to modify the project file name and namespace after the form project is established
版权声明
本文为[First code]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210551268053.html
边栏推荐
- WordPress plug-in: WP CHINA Yes solution to slow domestic access to the official website
- LeetCode 994、腐烂的橘子
- Cadence OrCAD capture batch change component packaging function introduction graphic tutorial and video demonstration
- Tensorflow 2 basic operation dictionary
- 上海回應“面粉官網是非法網站”:疏於運維被“黑”,警方已立案
- JDBC database addition, deletion, query and modification tool class
- 6-5 字符串 - 2. 字符串复制(赋值) (10 分)C语言标准函数库中包括 strcpy 函数,用于字符串复制(赋值)。作为练习,我们自己编写一个功能与之相同的函数。
- 三十一. `prototype`显示原型属性和`__proto__`隐式原型属性
- Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization
- What is the difference between a host and a server?
猜你喜欢
LeetCode 542、01 矩阵
Click an EL checkbox to select all questions
After route link navigation, the sub page does not display the navigation style problem
DNS cloud school | analysis of hidden tunnel attacks in the hidden corner of DNS
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
ArcGIS JS version military landmark drawing (dovetail arrow, pincer arrow, assembly area) fan and other custom graphics
[target tracking] pedestrian attitude recognition based on frame difference method combined with Kalman filter, with matlab code
16MySQL之DCL 中 COMMIT和ROllBACK
Recommend an open source free drawing software draw IO exportable vector graph
[graph theory brush question-5] Li Kou 1971 Find out if there is a path in the graph
随机推荐
16MySQL之DCL 中 COMMIT和ROllBACK
Scripy tutorial - (2) write a simple crawler
Numpy sort search count set
Es error: request contains unrecognized parameter [ignore_throttled]
bounding box iou
The construction and use of Fortress machine and springboard machine jumpserver are detailed in pictures and texts
Cadence Orcad Capture 批量更改元件封装功能介绍图文教程及视频演示
WordPress plug-in: WP CHINA Yes solution to slow domestic access to the official website
DNS cloud school | quickly locate DNS resolution exceptions and keep these four DNS status codes in mind
redis 分布式锁
【栈和队列专题】—— 滑动窗口
. Ren -- the intimate artifact in the field of vertical Recruitment!
Paper writing 19: the difference between conference papers and journal papers
Experience of mathematical modeling in 18 year research competition
【问题解决】‘ascii‘ codec can‘t encode characters in position xx-xx: ordinal not in range(128)
Numpy Index & slice & iteration
论文写作 19: 会议论文与期刊论文的区别
[PTA] get rid of singles
JDBC tool class jdbcconutil gets the connection to the database
PCA based geometric feature calculation of PCL point cloud processing (52)