0
Answer

Double definition of namespace when using VS2008 designer with dataset

Marc

Marc

14y
3.2k
1

Hello Everybody,
I'm preparing a WinForm application accessing SQL server tables with VS2008 standard edition.
I setted up a data set and then dragged and dropped a table to a form as a "detail view".
So I got all the usual objects (data set, BindingSource, TableAdapter, TableAdapterManager and BindingNavigator) on the form.
It works correctly as far as I make a correction in the code generated by the designer otherwise it doesn't compile ! This looks due to a double definition of the namespace.
Explanation:
In the designer generated file of the form (MyForm.Designer.cs) I have something like this:
namespace MySolution
partial class MyForm
{
...
private void InitializeComponent()
{
...
this.myDataSet = new MySolution.MyDataSet();
this.tempProfile1BindingSource = new System.Windows.Forms.BindingSource(this.components );
this.myTableAdapter = new MySolution.MyDataSetTableAdapters.MyTableAdapter();
this.tableAdapterManager = new MySolution.MyDataSetTableAdapters.TableAdapterManager();
...
}
...
}
With the 3 lines of code containing "new MySolution. ..." I get error message like (for the 1st line):
The type name 'MyDataSet' does not exist in the type 'MySolution.MySolution' ... and similar for the 2 next lines.
When removing the string "MySolution. " of the 3 lines I can then build the solution. The problem is each time I just move a bit a component of the form MyForm, the designer regenerates the code and I have to delete again the 3 strings to be able to build. For example this works:   this.myDataSet = new MyDataSet();   but when the code is regenerated by the designer it becomes again   this.myDataSet = new MySolution.MyDataSet();

Any comment welcome... :-)   Many thanks for the attention.
Marc