Home > Enterprise >  How do I stop Visual Studio from Inserting Namespaces into the Designer Code
How do I stop Visual Studio from Inserting Namespaces into the Designer Code

Time:07-24

This is driving me to distraction and I can't stop it from happening.

I have a class called MultiColumnCombo and use it as a tool I drag onto forms. The problem I have is the Designer code is being changed to include the NameSpace 'ACUITY_DATA', generating an error ('ACUITY_DATA' is the name of the project). When I delete ACUITY_DATA, it works fine. But every time I adjust something on the form, Visual Studio reinserts ACUITY_DATA again, breaking the application:

MyControls.MultiColumnCombo() = Works Fine

ACUITY_DATA.MyControls.MultiColumnCombo() = error (visual studio keeps changing it back to this)

I have tried creating my own Name Space 'MyControls' in an attempt to fix it but it didn't work.

It's driving me crazy. Any ideas would be appreciated...

The error is receive is "ACUITY_DATA.MyControls.MultiColumnCombo() is not defined"

Although I have mentioned this above, I use the class object by dragging it from the Components area of the Toolbox onto a form. It is this that is causing the problems.

The class looks like this:

Namespace MyControls
    Public Class MultiColumnCombo
        Inherits ComboBox

                CODE...

    End Class    
End Namespace 

This is in the designer:

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class frmStaffAllocations
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()>
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()>
    Private Sub InitializeComponent()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmStaffAllocations))
      
        Me.mcboPts = New ACUITY_DATA.MyControls.MultiColumnCombo()
        Me.cboEnterUser = New ACUITY_DATA.MyControls.MultiColumnCombo()
        Me.lblPC_Name = New System.Windows.Forms.Label()
        Me.lblPC_User = New System.Windows.Forms.Label()
        
        lots of other code...
        
End Class

CodePudding user response:

I still have no idea why the issue occurred, however, I moved my project from VS 2017 to VS 2022 and it fixed it. Go figure!

  • Related