开发者

Windows Forms Designer - automatically adds namespace in front of class

开发者 https://www.devze.com 2023-04-02 14:25 出处:网络
I have problem with Visual Studio Designer. When I display design of a form, designer automatically adds namespace in front of class, which is used as datasource.

I have problem with Visual Studio Designer.

When I display design of a form, designer automatically adds namespace in front of class, which is used as datasource. But this class is in the same namespace as the form.

It is annoying.

Example:

namespace Editor
{
    partial class AddSignalForm
    {
      ...
      this.signalsBS.DataSource = typeof(Signal);

    }
}

Signal is in namespace Editor.

But after I open designer, code is开发者_JAVA技巧 changed to:

namespace Editor
{
    partial class AddSignalForm
    {
      ...
      this.signalsBS.DataSource = typeof(Editor.Signal);

    }
}

Problem is that compiler can not find class Editor.Editor.Signal.


You seem to have another class or property named Editor which conflicts with the namespace.


For any others who have this problem.... I discovered that in one file, I had inadvertently put the namespace declaration in the code file twice:

as in :

namespace MyCompany.MyApplication
{
     namespace MyCompany.MyApplication
     {
          //class definitions
     }
}

This caused the designer to mess up and add the namespace to the name in the Binding Source DataSource.

0

精彩评论

暂无评论...
验证码 换一张
取 消