修复VB.NET项目

修复VB.NET项目,vb.net,Vb.net,我在将多项目解决方案重新创建为单个项目解决方案时遇到了巨大的麻烦,因为我的程序无法使用 我保存了所有代码文件,问题是在IDE中显示设计器以及与之连接的错误 情境: 所有表单都使用一个名为cls_transform的类进行子类化,该类使表单在移动时透明 Public Class cls_transform Inherits System.Windows.Forms.Form Private _OpacityMove As Double = 0.5 Private _OpacityO

我在将多项目解决方案重新创建为单个项目解决方案时遇到了巨大的麻烦,因为我的程序无法使用

我保存了所有代码文件,问题是在IDE中显示设计器以及与之连接的错误

情境:
所有表单都使用一个名为cls_transform的类进行子类化,该类使表单在移动时透明

Public Class cls_transform
       Inherits System.Windows.Forms.Form

Private _OpacityMove As Double = 0.5
Private _OpacityOriginal As Double = 1
Private Const WM_NCLBUTTONDOWN As Long = &HA1
Private Const WM_NCLBUTTONUP As Long = &HA0
Private Const WM_MOVING As Long = &H216
Private Const WM_SIZE As Long = &H5

Private Sub cls_transform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Protected Overrides Sub DefWndProc(ByRef m As System.Windows.Forms.Message)
    Static LButtonDown As Boolean

    If CLng(m.Msg) = WM_NCLBUTTONDOWN Then
        LButtonDown = True
    ElseIf CLng(m.Msg) = WM_NCLBUTTONUP Then
        LButtonDown = False
    End If

    If LButtonDown Then
        If CLng(m.Msg) = WM_MOVING Then
            If Me.Opacity <> _OpacityMove Then
                _OpacityOriginal = Me.Opacity
                Me.Opacity = _OpacityMove
            End If
        End If
    ElseIf Not LButtonDown Then
        If Me.Opacity <> _OpacityOriginal Then Me.Opacity = _OpacityOriginal
    End If
    MyBase.DefWndProc(m)
End Sub

Public Property OpacityMove() As Double
    Get
        Return _OpacityMove
    End Get
    Set(ByVal Value As Double)
        _OpacityMove = Value
    End Set
End Property

Private Sub InitializeComponent()
    Me.SuspendLayout()
    Me.ClientSize = New System.Drawing.Size(284, 262)
    Me.Name = "cls_transform"
    Me.ResumeLayout(False)
End Sub
End Class
这是该表单的设计器代码:

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frm_myForm
        Inherits cls_transform

'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()
    '
    'frm_myForm
    '
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
    Me.ClientSize = New System.Drawing.Size(284, 262)
    Me.Name = "frm_myForm"
    Me.Text = "frm_myForm"
    Me.ResumeLayout(False)

End Sub
End Class
_
部分类frm_-myForm
继承cls_变换
'窗体覆盖dispose以清理组件列表。
_
受保护的重写子处置(ByVal作为布尔值处置)
尝试
如果处理AndAlso组件不是什么,那么
components.Dispose()
如果结束
最后
MyBase.Dispose(Dispose)
结束尝试
端接头
'是Windows窗体设计器所必需的
作为System.ComponentModel.IContainer的专用组件
'注意:Windows窗体设计器需要以下过程
'可以使用Windows窗体设计器对其进行修改。
'不要使用代码编辑器修改它。
_
私有子初始化组件()
Me.SuspendLayout()
'
“frm_myForm”
'
Me.AutoScaleDimensions=新系统.Drawing.SizeF(6.0!13.0!)
Me.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize=新系统.Drawing.Size(284262)
Me.Name=“frm\u myForm”
Me.Text=“frm\u myForm”
Me.ResumeLayout(错误)
端接头
末级
当我尝试从IDE中“查看设计器”而不是查看表单时,会出现白色屏幕,并出现错误:

无法为此文件显示设计器,因为无法设计其中的任何类。设计器检查了文件中的以下类:frm_myForm--无法加载基类“noviprog.cls_transform”。确保部件已被引用,并且已生成所有项目

从cls_变换继承的所有形式都会发生这种情况

当cls_转换位于单独的库(同一解决方案的单独项目)中时,该库被引用到实际工作的项目中


当代码文件和该类在同一个项目中时,是否有可能使其工作?如何使其工作?

从您的代码中,应该不会有任何问题。你能解释一下你使用的文件结构吗?(所有的类都写在同一个文件中吗?如果不是在哪些文件中?)在这种情况下,该类位于名为cls_transform.vb的单独文件中,该文件与其他文件位于同一项目中。我试图通过将文件从旧解决方案一个接一个地包含到新解决方案中来重新创建可行的项目。只要您正确添加了给定的文件,就不会有任何问题。示例:在“解决方案资源管理器”中,右键单击项目名称“添加”、“现有项”(或“新项”)并在其中写入所有内容。一个个文件。这几天我在IDE上遇到了非常奇怪和无法解释的事情,所以也许我需要重新安装VB/VS?我不知道你说的无法解释的事情是什么意思,但是如果你打开一个新项目,在发布时编写引用主窗体的代码,将所有与cls_转换相关的代码放在另一个文件中(并正确地将其添加到项目中),应该没什么问题。如果发现问题,可能必须查看Visual Studio/您的计算机。
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frm_myForm
        Inherits cls_transform

'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()
    '
    'frm_myForm
    '
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
    Me.ClientSize = New System.Drawing.Size(284, 262)
    Me.Name = "frm_myForm"
    Me.Text = "frm_myForm"
    Me.ResumeLayout(False)

End Sub
End Class