Namespace disappears from InitConnection(), DataSet.Designer.cs after dataset modification (renaming namespace)
-
Thursday, July 26, 2012 8:04 AM
hi
anybody could help me on this!!!
scenario:
there was a project named xyz.project1
i renamed it to xyz.project2i have a DataSet added to the project, what is the dilemma is that every time whenever i do any modifications in the DataSet and save it and then build the project, i get the following error
The type or namespace name 'project2' could not be found in the global namespace (are you missing an assembly reference?) ..\Documents\Visual Studio 2010\Projects\project2\Source\xyz.project2\DataSet.Designer.cs xyz.project2
could anybody shed some light on this
correct one (in bold)private void InitConnection() { this._connection = new global::System.Data.SqlClient.SqlConnection(); this._connection.ConnectionString = global::xyz.project2.Properties.Settings.Default.ConnectionString; }wrong one (in bold, gets created automatically when data set is modified)
private void InitConnection() { this._connection = new global::System.Data.SqlClient.SqlConnection(); this._connection.ConnectionString = global::project2.Properties.Settings.Default.ConnectionString; }
and then the generated error
The type or namespace name 'project2' could not be found in the global namespace (are you missing an assembly reference?) ..\Documents\Visual Studio 2010\Projects\project2\Source\xyz.project2\DataSet.Designer.cs xyz.project2
thanks!!!
All Replies
-
Thursday, July 26, 2012 3:09 PMModerator
Project name != assembly name != namespace name
Renaming a project simply renames the project file (after creation). The underlying assembly name remains the same as does the default namespace. Almost all the generated code (including properties) uses the default namespace of the project to generate code. Therefore to get everything in sync you need to open the project properties and change the assembly name and default namespace names to match your project name. Even then you'll need to also go into your solution and rename your namespaces in your code (for consistency). The easiest way to do that is to select Project1 in a namespace statement, right-click Refactor, Rename and change it to Project2.
Michael Taylor - 7/26/2012
http://msmvps.com/blogs/p3net
- Proposed As Answer by Lisa ZhuMicrosoft Contingent Staff, Moderator Friday, July 27, 2012 7:37 AM
- Unproposed As Answer by Lisa ZhuMicrosoft Contingent Staff, Moderator Thursday, August 02, 2012 8:13 AM
-
Saturday, July 28, 2012 5:41 AM
hi CoolDadTX
i have used the refactor method and also i have done all what you have mentioned above, but still when i modify the DataSet, i face the issue.
after refactoring and checking in properties window
Project name == assembly name == namespace namethanks
-
Saturday, July 28, 2012 4:14 PMModerator
Hmm. It would sound like something is out of sync because VS will normally fix everything up correctly. I verified it on a clean project and it is working properly. I suspect that because the rename was done piecemeal that VS doesn't know that some things should be updated. Let's step through this manually until the problem resolves.
1) Open the settings.designer.cs file and confirm that the namespace is correct for the file. If it is not then try adding and removing a setting in the designer to trigger a refresh. If that doesn't work then just fix the file manually.
2) Ensure there are no references to the old namespace.
3) Go to the dataset designer and make a change to force a refresh.
Michael Taylor - 7/28/2012
http://msmvps.com/blogs/p3net
- Proposed As Answer by Lisa ZhuMicrosoft Contingent Staff, Moderator Thursday, August 02, 2012 8:13 AM
- Marked As Answer by Lisa ZhuMicrosoft Contingent Staff, Moderator Thursday, August 02, 2012 8:13 AM

