I encountered the following problem as I continued my testing. Since my knowledge of DotNet is extremely limited, the following account may be verbose.
First, I created a custom class in the class library project that inherits from System.Windows.Forms.Form because I want forms in WinForm applications to have the same behavior and presentation in some common areas.
Code: Select all
Using System
Using System.Collections.Generic
Using System.ComponentModel
Using System.Text
Using System.Windows.Forms
Begin Namespace myTest
Public Class myForm Inherit System.Windows.Forms.Form
Public Constructor()
This.Text = "myForm"
This.Deactivate += myForm_Deactivate
This.Activated += myForm_Activated
Return
End Constructor
Private Method myForm_Deactivate(sender As System.Object, e As System.EventArgs) As Void Strict
MessageBox("Deactivate")
End Method
Private Method myForm_Activated(sender As System.Object, e As System.EventArgs) As Void Strict
MessageBox("Activated")
End Method
End Class
End Namespace
Then I added the Windows Forms Application project to the same solution,And, add myTest.ll to the project's references.
I changed the form generated when I created the project so that it inherits from the previous myForm class.
Code: Select all
Using System
Using System.Collections.Generic
Using System.ComponentModel
Using System.Data
Using System.Drawing
Using System.Text
//using System.Windows.Forms
Using myTest
Begin Namespace myWinFormApp.Forms
Public Partial Class Form1 Inherit myForm
Public Constructor() Strict
Self:InitializeComponent()
Return
End Constructor
End Class
End Namespace
I closed the code editing window and form designer。
VS IDE gives a message box when I double click the prg file again to open the form: the service microsoft.visualstudio.shell.interop.iselectioncontainer already exists in the service container
I thought there was something wrong with my code or design approach, so I redid it using C#. However, I did not encounter any problems.
I'm guessing this is an X# bug, but I'm not sure.
I expect a definite answer.
P.S. if I remove the subscribe from the constructor and include “This.Size = Size(200, 200)” in the constructor, then VS IDE gives the same message when I try to open the form inherited from myForm.