Visual Studio and .NET Framework Home
Dataset Designer changes namespace in custom partial class
as By Design
6/19/2008 8:06:08 AM
User(s) can reproduce this bug
In VS2008, the dataset has a separate file (from the .designer.cs) where the user can use a partial class to write custom code. If this file contains more than one parital class for the dataset, the designer changes the namespace on the second partial class to the namespace of the table adapters.
I have 2 partial classes with the same namespace because one is code generated (custom system) and one is hand crafted code. Every time I save changes in the dataset (or run custom code), the designer changes the namespace from ProjectName to ProjectName.DataSetNameTableAdapters.
This caused a lot of problems to first diagnosis and causes continuing irration to remember to change the namespace back after generating.
Visual Studio 2008 (All Products and Editions)
Windows XP Professional
Operating System Language
Steps to Reproduce
1. Create a dataset with a couple tables
2. right-click, view code to create the partial class
3. copy all the code and paste below the code to end up with two different namespace and partial class blocks
4. Edit the dataset in visual editor and save (or run custom tool)
5. switch back to the .cs file and notice the second namespace block
.DataSetNameTableAdapters is added to the second namespace.
designer tool should not change any code in the .cs file
TAP Code (if applicable)
You can indicate your satisfaction with how Microsoft handled this issue by completing this quick
3 question survey
to post a comment.
Please enter a comment.
on 10/3/2008 at 4:18 AM
This is a problem for us too because now we've upgraded to VS2008 configuring our datasets screws up the namespaces and prevents successful compilation. We're now having to manually edit the dataset source whenever we've configured the datasets to correct the namespaces.
on 10/2/2008 at 2:41 PM
Thanks for your response.
Unfortunately when the issue was reported SP1 was in its very last stages and locked down for crit1 fixes only.
In your scenario the designer changes your namespace because it encounters a conflict that is not resolvable: When you click on 'View Code' a second time, where should the designer land the cursor?
One workaround is: Create a new file and copy the code there. That way the designer won't clobber the namespace.
on 9/22/2008 at 7:07 PM
When you create the code behind file for a dataset, it creates a stub of code that is only the namespace. If you copy the namespace section and paste it at the bottom of the file, you now have two namespace entries in the file. When you save the dataset, the second namespace gets changed by VS.
The reason I need two sets of namespace is because one set is generated my my customer code generation system and the other is hand crafted code.
You know it was 4 months ago when I reported the bug. I was hoping the fix would make it into SP1. Now I have to wait another year.
on 9/19/2008 at 4:59 PM
Thanks for providing this feedback. We are investigating this. To help us understand this better, I have a few questions.
1. In step 3 you wrote: "copy all the code and paste below the code to end up with two different namespace and partial class blocks" Can you clarify what code you copied and where specifically you pasted it?
2. Can you describe the goal? What are you hoping to accomplish with the copy-paste?
PM, Visual Studio
on 7/15/2008 at 2:48 AM
Thanks for your feedback. We are escalating this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.
Visual Studio Product Team
to post a workaround.
Please enter a workaround.
on 9/22/2008 at 7:08 PM
The manual work around is to remember to re-edit the namespace every time the dataset is edited. This gets old real quick.
© 2014 Microsoft