修复VB.NET项目

时间:2013-10-10 07:18:17

标签: vb.net

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

我保存了所有代码文件,问题在于在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

这是一个空表单“frm_myForm”的代码如下所示:

Public Class frm_myForm
       Inherits cls_transform

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

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

当我尝试从IDE中“查看设计器”而不是看到表单时,我会看到错误的白色屏幕:

  

无法为此文件显示设计器,因为其中的所有类都无法设计。设计者检查了文件中的以下类:frm_myForm ---无法加载基类'noviprog.cls_transform'。确保已引用程序集并且已构建所有项目。

所有从cls_transform继承的表单都会发生这种情况。

当cls_transform位于单独的库(同一解决方案的单独项目)中时,该库被引用到可行的实际项目中。

当代码文件和那个类在同一个项目中以及如何使它工作时,是否可以使这个工作?

0 个答案:

没有答案