Vb.net 类型';用户控制';未定义(Visual Studio 2015)
我在VS2015的项目中添加了一个自定义winforms用户控件。当我将控件拖动到窗体并编译时,得到的错误类型“xxx”未定义。如果我从控件名中删除了名称空间,但对用户控件的任何更改都会覆盖我的更改,我可以进行修复。 有没有办法防止这种情况发生 这是自动生成的控件(称为“ctrlTestStatus”): 不幸的是,这造成了更多的问题,并且CtrlTestStatus1实例的属性和事件不可用(我得到了扭曲的线条) 由于64位/32位的问题(VS仍然是32位!),我从MS那里发现了一个问题,即将编译设置为任何CPU(项目构建总是设置为这个),但也没有乐趣Vb.net 类型';用户控制';未定义(Visual Studio 2015),vb.net,winforms,visual-studio-2015,user-controls,Vb.net,Winforms,Visual Studio 2015,User Controls,我在VS2015的项目中添加了一个自定义winforms用户控件。当我将控件拖动到窗体并编译时,得到的错误类型“xxx”未定义。如果我从控件名中删除了名称空间,但对用户控件的任何更改都会覆盖我的更改,我可以进行修复。 有没有办法防止这种情况发生 这是自动生成的控件(称为“ctrlTestStatus”): 不幸的是,这造成了更多的问题,并且CtrlTestStatus1实例的属性和事件不可用(我得到了扭曲的线条) 由于64位/32位的问题(VS仍然是32位!),我从MS那里发现了一个问题,即将编
关于如何解决这个问题,有什么想法(设置、我做错的事情)吗?旧帖子,但对于其他有这个问题的人 我在一个项目中遇到过这种情况,在这个项目中,我定义了一个子命名空间,其名称与我的项目(根命名空间)相同(在OP的例子中是“QBI”)。当您的项目中的某个地方有这样的代码时,就会发生这种情况:
Namespace[项目名称/根命名空间]
[...]
结束命名空间
这样做的结果是,您的项目同时包含一个“QBI”命名空间和一个“QBI.QBI”命名空间(如果您查看项目的对象浏览器,您可以自己看到)。这种情况会导致设计器文件中出现解析冲突,从而导致它在自定义控件的错误命名空间下查找
解决此问题的几种可能方法:
选项3是最乏味的,因为您必须使用Find和Replace解析对根命名空间的所有设计器文件引用,小心不要错误地替换对子QBI命名空间的合法引用。我删除了QBI。然而,从QBI.ctrlTestStatus开始,对控件的任何更改都将覆盖我(将来)所做的代码更改。这将工作到现在为止,因为我在智囊团结束,将只需要手动代码更改从这里开始-MS需要修复这个错误(它是从VS2008开始的,从我在其他帖子上看到的-这,也没有工作的解决方案)擦掉它!没用!啊!!!!
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class ctrlTestStatus
Inherits System.Windows.Forms.UserControl
'UserControl 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()
Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel()
Me.prgLocalDatabase = New System.Windows.Forms.ProgressBar()
Me.prgRemoteDatabase = New System.Windows.Forms.ProgressBar()
Me.lblLocalDatabaseStatus = New System.Windows.Forms.Label()
Me.lblRemoteDatabaseStatus = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
Me.prgAmazon = New System.Windows.Forms.ProgressBar()
Me.Label6 = New System.Windows.Forms.Label()
Me.lblAmazonStatus = New System.Windows.Forms.Label()
Me.prgEbay = New System.Windows.Forms.ProgressBar()
Me.lblEbayStatus = New System.Windows.Forms.Label()
Me.Label1 = New System.Windows.Forms.Label()
Me.lbStatus = New System.Windows.Forms.ListBox()
Me.TableLayoutPanel1.SuspendLayout()
Me.SuspendLayout()
'
'TableLayoutPanel1
'
Me.TableLayoutPanel1.BackColor = System.Drawing.SystemColors.Window
Me.TableLayoutPanel1.ColumnCount = 3
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25.30766!))
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 58.95527!))
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 15.73707!))
Me.TableLayoutPanel1.Controls.Add(Me.prgLocalDatabase, 1, 0)
Me.TableLayoutPanel1.Controls.Add(Me.prgRemoteDatabase, 1, 1)
Me.TableLayoutPanel1.Controls.Add(Me.lblLocalDatabaseStatus, 2, 0)
Me.TableLayoutPanel1.Controls.Add(Me.lblRemoteDatabaseStatus, 2, 1)
Me.TableLayoutPanel1.Controls.Add(Me.Label4, 0, 0)
Me.TableLayoutPanel1.Controls.Add(Me.Label5, 0, 1)
Me.TableLayoutPanel1.Controls.Add(Me.prgAmazon, 1, 2)
Me.TableLayoutPanel1.Controls.Add(Me.Label6, 0, 2)
Me.TableLayoutPanel1.Controls.Add(Me.lblAmazonStatus, 2, 2)
Me.TableLayoutPanel1.Controls.Add(Me.prgEbay, 1, 3)
Me.TableLayoutPanel1.Controls.Add(Me.lblEbayStatus, 2, 3)
Me.TableLayoutPanel1.Controls.Add(Me.Label1, 0, 3)
Me.TableLayoutPanel1.Location = New System.Drawing.Point(8, 7)
Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
Me.TableLayoutPanel1.RowCount = 4
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle())
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle())
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle())
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle())
Me.TableLayoutPanel1.Size = New System.Drawing.Size(425, 107)
Me.TableLayoutPanel1.TabIndex = 8
'
'prgLocalDatabase
'
Me.prgLocalDatabase.Location = New System.Drawing.Point(110, 3)
Me.prgLocalDatabase.Name = "prgLocalDatabase"
Me.prgLocalDatabase.Size = New System.Drawing.Size(244, 20)
Me.prgLocalDatabase.TabIndex = 0
'
'prgRemoteDatabase
'
Me.prgRemoteDatabase.Location = New System.Drawing.Point(110, 29)
Me.prgRemoteDatabase.Name = "prgRemoteDatabase"
Me.prgRemoteDatabase.Size = New System.Drawing.Size(244, 20)
Me.prgRemoteDatabase.TabIndex = 1
'
'lblLocalDatabaseStatus
'
Me.lblLocalDatabaseStatus.Anchor = System.Windows.Forms.AnchorStyles.Left
Me.lblLocalDatabaseStatus.AutoSize = True
Me.lblLocalDatabaseStatus.Location = New System.Drawing.Point(360, 6)
Me.lblLocalDatabaseStatus.MinimumSize = New System.Drawing.Size(40, 13)
Me.lblLocalDatabaseStatus.Name = "lblLocalDatabaseStatus"
Me.lblLocalDatabaseStatus.Size = New System.Drawing.Size(40, 13)
Me.lblLocalDatabaseStatus.TabIndex = 3
'
'lblRemoteDatabaseStatus
'
Me.lblRemoteDatabaseStatus.Anchor = System.Windows.Forms.AnchorStyles.Left
Me.lblRemoteDatabaseStatus.AutoSize = True
Me.lblRemoteDatabaseStatus.Location = New System.Drawing.Point(360, 32)
Me.lblRemoteDatabaseStatus.MinimumSize = New System.Drawing.Size(40, 13)
Me.lblRemoteDatabaseStatus.Name = "lblRemoteDatabaseStatus"
Me.lblRemoteDatabaseStatus.Size = New System.Drawing.Size(40, 13)
Me.lblRemoteDatabaseStatus.TabIndex = 4
'
'Label4
'
Me.Label4.Anchor = System.Windows.Forms.AnchorStyles.Right
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(4, 6)
Me.Label4.MinimumSize = New System.Drawing.Size(100, 13)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(100, 13)
Me.Label4.TabIndex = 6
Me.Label4.Text = "Local Database:"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.TopRight
'
'Label5
'
Me.Label5.Anchor = System.Windows.Forms.AnchorStyles.Right
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(4, 32)
Me.Label5.MinimumSize = New System.Drawing.Size(100, 13)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(100, 13)
Me.Label5.TabIndex = 7
Me.Label5.Text = "Remote Database:"
Me.Label5.TextAlign = System.Drawing.ContentAlignment.TopRight
'
'prgAmazon
'
Me.prgAmazon.Location = New System.Drawing.Point(110, 55)
Me.prgAmazon.Name = "prgAmazon"
Me.prgAmazon.Size = New System.Drawing.Size(244, 20)
Me.prgAmazon.TabIndex = 9
'
'Label6
'
Me.Label6.Anchor = System.Windows.Forms.AnchorStyles.Right
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(4, 58)
Me.Label6.MinimumSize = New System.Drawing.Size(100, 13)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(100, 13)
Me.Label6.TabIndex = 8
Me.Label6.Text = "Amazon:"
Me.Label6.TextAlign = System.Drawing.ContentAlignment.TopRight
'
'lblAmazonStatus
'
Me.lblAmazonStatus.Anchor = System.Windows.Forms.AnchorStyles.Left
Me.lblAmazonStatus.AutoSize = True
Me.lblAmazonStatus.Location = New System.Drawing.Point(360, 58)
Me.lblAmazonStatus.MinimumSize = New System.Drawing.Size(40, 13)
Me.lblAmazonStatus.Name = "lblAmazonStatus"
Me.lblAmazonStatus.Size = New System.Drawing.Size(40, 13)
Me.lblAmazonStatus.TabIndex = 5
'
'prgEbay
'
Me.prgEbay.Location = New System.Drawing.Point(110, 81)
Me.prgEbay.Name = "prgEbay"
Me.prgEbay.Size = New System.Drawing.Size(244, 20)
Me.prgEbay.TabIndex = 11
'
'lblEbayStatus
'
Me.lblEbayStatus.Anchor = System.Windows.Forms.AnchorStyles.Left
Me.lblEbayStatus.AutoSize = True
Me.lblEbayStatus.Location = New System.Drawing.Point(360, 86)
Me.lblEbayStatus.MinimumSize = New System.Drawing.Size(40, 13)
Me.lblEbayStatus.Name = "lblEbayStatus"
Me.lblEbayStatus.Size = New System.Drawing.Size(40, 13)
Me.lblEbayStatus.TabIndex = 12
'
'Label1
'
Me.Label1.Anchor = System.Windows.Forms.AnchorStyles.Right
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(4, 86)
Me.Label1.MinimumSize = New System.Drawing.Size(100, 13)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(100, 13)
Me.Label1.TabIndex = 10
Me.Label1.Text = "Ebay:"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.TopRight
'
'lbStatus
'
Me.lbStatus.FormattingEnabled = True
Me.lbStatus.Location = New System.Drawing.Point(7, 120)
Me.lbStatus.Name = "lbStatus"
Me.lbStatus.Size = New System.Drawing.Size(425, 56)
Me.lbStatus.TabIndex = 9
'
'ctrlTestStatus
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.Controls.Add(Me.TableLayoutPanel1)
Me.Controls.Add(Me.lbStatus)
Me.Name = "ctrlTestStatus"
Me.Size = New System.Drawing.Size(440, 185)
Me.TableLayoutPanel1.ResumeLayout(False)
Me.TableLayoutPanel1.PerformLayout()
Me.ResumeLayout(False)
End Sub
Friend WithEvents TableLayoutPanel1 As TableLayoutPanel
Friend WithEvents prgLocalDatabase As ProgressBar
Friend WithEvents prgRemoteDatabase As ProgressBar
Friend WithEvents lblLocalDatabaseStatus As Label
Friend WithEvents lblRemoteDatabaseStatus As Label
Friend WithEvents Label4 As Label
Friend WithEvents Label5 As Label
Friend WithEvents prgAmazon As ProgressBar
Friend WithEvents Label6 As Label
Friend WithEvents lblAmazonStatus As Label
Friend WithEvents prgEbay As ProgressBar
Friend WithEvents lblEbayStatus As Label
Friend WithEvents Label1 As Label
Friend WithEvents lbStatus As ListBox
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class frmTestStart
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()
Me.SuspendLayout()
'
'frmTestStart
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(468, 206)
Me.Name = "frmTestStart"
Me.Text = "Test Connections"
Me.ResumeLayout(False)
End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class frmTestStart
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()
Me.CtrlTestStatus1 = New QBI.ctrlTestStatus()
Me.SuspendLayout()
'
'CtrlTestStatus1
'
Me.CtrlTestStatus1.Location = New System.Drawing.Point(13, 13)
Me.CtrlTestStatus1.Name = "CtrlTestStatus1"
Me.CtrlTestStatus1.Size = New System.Drawing.Size(440, 185)
Me.CtrlTestStatus1.TabIndex = 0
'
'frmTestStart
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(468, 206)
Me.Controls.Add(Me.CtrlTestStatus1)
Me.Name = "frmTestStart"
Me.Text = "Test Connections"
Me.ResumeLayout(False)
End Sub
Friend WithEvents CtrlTestStatus1 As QBI.ctrlTestStatus
End Class
Namespace QBI
Public Class ctrlTestStatus
Private Sub ctrlTestStatus_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
End Namespace