473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

terrible annoying BUG in VS.NET 2005 with UserControl at DesignTime?!

Hi,

I'm getting a really terrible and anoying bug/problem in VS.NET 2005:

1. Create a new Windows Application.
2. Add a new class Class1.
3. Add a usercontrol UserControl1.
4. Add a public instance of Class1 to UserControl1 (with WithEvents):
"Public WithEvents ThisClass As New Class1".
5. Build the Solution, and put an instance of UserControl1 on Form1.
6. Rebuild the Solution, and open the Form1 in the Designer (View Designer)
-> Everything works fine, you can close it and open it again in the designer
as much as you want...

7. Change anything to Form1 in the Designer: for instance make it just a
tiny bit larger. Save the changes, and close the Form1.
-> When you nowwant to open Form1 in the Designer, you get some nasty
exception:
*****************
One or more errors encountered while loading the designer. The errors are
listed below. Some errors can be fixed by rebuilding your project, while
others may require code changes.

The type 'WindowsApplication1.UserControl1' has no field named 'ThisClass'.
Hide Edit

at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.Error(IDesignerSerializationManager
manager, String exceptionText, String helpLink)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeAssignStatement(IDesigne rSerializationManager
manager, CodeAssignStatement statement)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager
manager, CodeStatement statement)

****************

I noticed it added in the Form1.Designer.vb some lines in the
InitializeComponent():
"Dim Class11 As WindowsApplication1.Class1 = New WindowsApplication1.Class1"
and a little bit further "Me.UserControl11.ThisClass = Class11".
You can't open Form1 in the Designer if you don't remove the second line...

This behaviour doesn't happen if you declare the instance ThisClass as
Private, or without the WithEvents...

But I really would like to have it Public WithEvents. And I can't stand it
that I can't, hehe. Does anybody knows a solution for this? Is this a Bug?
Or is there a rule that a UserControl can't containt Public WithEvents
classes??

Any help, hints, or whatever would be really appreciated!
Thanks a lot in advance,

Pieter


Nov 25 '05 #1
5 1500

Hey Pieter,

you can best report this bug on the following link:

http://lab.msdn.microsoft.com/produc...k/default.aspx

you can also look if the same bug has already been reported and see if there
is a work around.

if this post is helpfull click on yes on the bottom of the post :-p
"Pieter" wrote:
Hi,

I'm getting a really terrible and anoying bug/problem in VS.NET 2005:

1. Create a new Windows Application.
2. Add a new class Class1.
3. Add a usercontrol UserControl1.
4. Add a public instance of Class1 to UserControl1 (with WithEvents):
"Public WithEvents ThisClass As New Class1".
5. Build the Solution, and put an instance of UserControl1 on Form1.
6. Rebuild the Solution, and open the Form1 in the Designer (View Designer)
-> Everything works fine, you can close it and open it again in the designer
as much as you want...

7. Change anything to Form1 in the Designer: for instance make it just a
tiny bit larger. Save the changes, and close the Form1.
-> When you nowwant to open Form1 in the Designer, you get some nasty
exception:
*****************
One or more errors encountered while loading the designer. The errors are
listed below. Some errors can be fixed by rebuilding your project, while
others may require code changes.

The type 'WindowsApplication1.UserControl1' has no field named 'ThisClass'.
Hide Edit

at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.Error(IDesignerSerializationManager
manager, String exceptionText, String helpLink)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeAssignStatement(IDesigne rSerializationManager
manager, CodeAssignStatement statement)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager
manager, CodeStatement statement)

****************

I noticed it added in the Form1.Designer.vb some lines in the
InitializeComponent():
"Dim Class11 As WindowsApplication1.Class1 = New WindowsApplication1.Class1"
and a little bit further "Me.UserControl11.ThisClass = Class11".
You can't open Form1 in the Designer if you don't remove the second line...

This behaviour doesn't happen if you declare the instance ThisClass as
Private, or without the WithEvents...

But I really would like to have it Public WithEvents. And I can't stand it
that I can't, hehe. Does anybody knows a solution for this? Is this a Bug?
Or is there a rule that a UserControl can't containt Public WithEvents
classes??

Any help, hints, or whatever would be really appreciated!
Thanks a lot in advance,

Pieter


Nov 25 '05 #2
Didn't find a similar bug, and posted it :-)

"interwanderer" <in***********@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...

Hey Pieter,

you can best report this bug on the following link:

http://lab.msdn.microsoft.com/produc...k/default.aspx

you can also look if the same bug has already been reported and see if
there
is a work around.

if this post is helpfull click on yes on the bottom of the post :-p

Nov 25 '05 #3
On Fri, 25 Nov 2005 09:23:08 +0100, Pieter wrote:
Hi,

I'm getting a really terrible and anoying bug/problem in VS.NET 2005:

1. Create a new Windows Application.
2. Add a new class Class1.
3. Add a usercontrol UserControl1.
4. Add a public instance of Class1 to UserControl1 (with WithEvents):
"Public WithEvents ThisClass As New Class1".
5. Build the Solution, and put an instance of UserControl1 on Form1.
6. Rebuild the Solution, and open the Form1 in the Designer (View Designer)
-> Everything works fine, you can close it and open it again in the designer
as much as you want...

7. Change anything to Form1 in the Designer: for instance make it just a
tiny bit larger. Save the changes, and close the Form1.
-> When you nowwant to open Form1 in the Designer, you get some nasty
exception:
*****************
One or more errors encountered while loading the designer. The errors are
listed below. Some errors can be fixed by rebuilding your project, while
others may require code changes.

The type 'WindowsApplication1.UserControl1' has no field named 'ThisClass'.
Hide Edit

at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.Error(IDesignerSerializationManager
manager, String exceptionText, String helpLink)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeAssignStatement(IDesigne rSerializationManager
manager, CodeAssignStatement statement)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager
manager, CodeStatement statement)

****************

I noticed it added in the Form1.Designer.vb some lines in the
InitializeComponent():
"Dim Class11 As WindowsApplication1.Class1 = New WindowsApplication1.Class1"
and a little bit further "Me.UserControl11.ThisClass = Class11".
You can't open Form1 in the Designer if you don't remove the second line...

This behaviour doesn't happen if you declare the instance ThisClass as
Private, or without the WithEvents...

But I really would like to have it Public WithEvents. And I can't stand it
that I can't, hehe. Does anybody knows a solution for this? Is this a Bug?
Or is there a rule that a UserControl can't containt Public WithEvents
classes??

Any help, hints, or whatever would be really appreciated!
Thanks a lot in advance,

Pieter


Well, it does appear to be a bug or confusion by the designer for VB.Net,
but it's also a rather messy way of doing things.

A more correct way to implement this type of feature is to use something
like:
Public Class UserControl1
Private _ThisClass As New Class1()
Public ReadOnly Property ThisClass() As Class1
Get
Return _ThisClass
End Get
End Property
End Class

There is no point in having WithEvents on the declaration unless you plan
to handle the events in the usercontrol itself. If so, just add WithEvents
to the definition of _ThisClass and add 'Handles _ThisClass.xxx' in your
UserControl.
If you want to intercept Class1's events from outside of the UserControl
then you have to use something like:

Private Sub Form1_Load(...) Handles MyBase.Load
AddHandler (Me.UserControl11.ThisClass).TestClick, AddressOf doit
:
:

Private Sub doit()
MessageBox.Show("Hi!")
End Sub

but it's better to add your own events to the UserControl and ripple them
down from the embedded object.

The reason you have to wrap the Class1 object in a ReadOnly property is to
prevent it being serialized and initialised in the Form1.Designer.vb class.

Cheers,
Jason
Nov 25 '05 #4
On Fri, 25 Nov 2005 09:23:08 +0100, Pieter wrote:
Hi,

I'm getting a really terrible and anoying bug/problem in VS.NET 2005:

1. Create a new Windows Application.
2. Add a new class Class1.
3. Add a usercontrol UserControl1.
4. Add a public instance of Class1 to UserControl1 (with WithEvents):
"Public WithEvents ThisClass As New Class1".
5. Build the Solution, and put an instance of UserControl1 on Form1.
6. Rebuild the Solution, and open the Form1 in the Designer (View Designer)
-> Everything works fine, you can close it and open it again in the designer
as much as you want...

7. Change anything to Form1 in the Designer: for instance make it just a
tiny bit larger. Save the changes, and close the Form1.
-> When you nowwant to open Form1 in the Designer, you get some nasty
exception:
*****************
One or more errors encountered while loading the designer. The errors are
listed below. Some errors can be fixed by rebuilding your project, while
others may require code changes.

The type 'WindowsApplication1.UserControl1' has no field named 'ThisClass'.
Hide Edit

at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.Error(IDesignerSerializationManager
manager, String exceptionText, String helpLink)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeAssignStatement(IDesigne rSerializationManager
manager, CodeAssignStatement statement)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager
manager, CodeStatement statement)

****************

I noticed it added in the Form1.Designer.vb some lines in the
InitializeComponent():
"Dim Class11 As WindowsApplication1.Class1 = New WindowsApplication1.Class1"
and a little bit further "Me.UserControl11.ThisClass = Class11".
You can't open Form1 in the Designer if you don't remove the second line...

This behaviour doesn't happen if you declare the instance ThisClass as
Private, or without the WithEvents...

But I really would like to have it Public WithEvents. And I can't stand it
that I can't, hehe. Does anybody knows a solution for this? Is this a Bug?
Or is there a rule that a UserControl can't containt Public WithEvents
classes??

Any help, hints, or whatever would be really appreciated!
Thanks a lot in advance,

Pieter


Well, it does appear to be a bug or confusion by the designer for VB.Net,
but it's also a rather messy way of doing things.

A more correct way to implement this type of feature is to use something
like:
Public Class UserControl1
Private _ThisClass As New Class1()
Public ReadOnly Property ThisClass() As Class1
Get
Return _ThisClass
End Get
End Property
End Class

There is no point in having WithEvents on the declaration unless you plan
to handle the events in the usercontrol itself. If so, just add WithEvents
to the definition of _ThisClass and add 'Handles _ThisClass.xxx' in your
UserControl.
If you want to intercept Class1's events from outside of the UserControl
then you have to use something like:

Private Sub Form1_Load(...) Handles MyBase.Load
AddHandler (Me.UserControl11.ThisClass).TestClick, AddressOf doit
:
:

Private Sub doit()
MessageBox.Show("Hi!")
End Sub

but it's better to add your own events to the UserControl and ripple them
down from the embedded object.

The reason you have to wrap the Class1 object in a ReadOnly property is to
prevent it being serialized and initialised in the Form1.Designer.vb class.

Cheers,
Jason
Nov 25 '05 #5
On Fri, 25 Nov 2005 09:23:08 +0100, Pieter wrote:
Hi,

I'm getting a really terrible and anoying bug/problem in VS.NET 2005:

1. Create a new Windows Application.
2. Add a new class Class1.
3. Add a usercontrol UserControl1.
4. Add a public instance of Class1 to UserControl1 (with WithEvents):
"Public WithEvents ThisClass As New Class1".
5. Build the Solution, and put an instance of UserControl1 on Form1.
6. Rebuild the Solution, and open the Form1 in the Designer (View Designer)
-> Everything works fine, you can close it and open it again in the designer
as much as you want...

7. Change anything to Form1 in the Designer: for instance make it just a
tiny bit larger. Save the changes, and close the Form1.
-> When you nowwant to open Form1 in the Designer, you get some nasty
exception:
*****************
One or more errors encountered while loading the designer. The errors are
listed below. Some errors can be fixed by rebuilding your project, while
others may require code changes.

The type 'WindowsApplication1.UserControl1' has no field named 'ThisClass'.
Hide Edit

at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.Error(IDesignerSerializationManager
manager, String exceptionText, String helpLink)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeAssignStatement(IDesigne rSerializationManager
manager, CodeAssignStatement statement)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager
manager, CodeStatement statement)

****************

I noticed it added in the Form1.Designer.vb some lines in the
InitializeComponent():
"Dim Class11 As WindowsApplication1.Class1 = New WindowsApplication1.Class1"
and a little bit further "Me.UserControl11.ThisClass = Class11".
You can't open Form1 in the Designer if you don't remove the second line...

This behaviour doesn't happen if you declare the instance ThisClass as
Private, or without the WithEvents...

But I really would like to have it Public WithEvents. And I can't stand it
that I can't, hehe. Does anybody knows a solution for this? Is this a Bug?
Or is there a rule that a UserControl can't containt Public WithEvents
classes??

Any help, hints, or whatever would be really appreciated!
Thanks a lot in advance,

Pieter


Well, it does appear to be a bug or confusion by the designer for VB.Net,
but it's also a rather messy way of doing things.

A more correct way to implement this type of feature is to use something
like:
Public Class UserControl1
Private _ThisClass As New Class1()
Public ReadOnly Property ThisClass() As Class1
Get
Return _ThisClass
End Get
End Property
End Class

There is no point in having WithEvents on the declaration unless you plan
to handle the events in the usercontrol itself. If so, just add WithEvents
to the definition of _ThisClass and add 'Handles _ThisClass.xxx' in your
UserControl.
If you want to intercept Class1's events from outside of the UserControl
then you have to use something like:

Private Sub Form1_Load(...) Handles MyBase.Load
AddHandler (Me.UserControl11.ThisClass).TestClick, AddressOf doit
:
:

Private Sub doit()
MessageBox.Show("Hi!")
End Sub

but it's better to add your own events to the UserControl and ripple them
down from the embedded object.

The reason you have to wrap the Class1 object in a ReadOnly property is to
prevent it being serialized and initialised in the Form1.Designer.vb class.

Cheers,
Jason
Nov 26 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: João Santa Bárbara | last post by:
Hi all, i´m doing a user control, and one of my public properties is a collection, but in designtime, i´m adding a few objects of my type, but none of them are saved in the form, everytime i go to...
0
by: stew_mclean | last post by:
Hi, I've developed a class that derives from component (rather than a control), and am trying to license it at design time. I've set the license attributes etc. to my custom license provider: ...
2
by: Jim | last post by:
I have some complex (fairly) user controls that I have created. Some of those user controls host other user controls. When I host one of these on a WinForm, I sometimes run into problems where...
2
by: Able | last post by:
Dear friends I have placed a Listbox on a Usercontrol. How do I move the Listbox to upper left corner and make the listbox same size as usercontrol when resizing usercontrol in designtime? ...
5
by: Pieter | last post by:
Hi, I'm getting a really terrible and anoying bug/problem in VS.NET 2005: 1. Create a new Windows Application. 2. Add a new class Class1. 3. Add a usercontrol UserControl1. 4. Add a public...
2
by: Steve | last post by:
This is a weird one. I have a series of "SmartParts" which are CAB (Composite Application Block) Views which are finally just UserControls (99% of the time) Anyway, I layout my UserControl in...
1
by: bonk | last post by:
I have a very simple UserControl (derived from System.Windows.Forms.UserControl) that contains several ListViews. The UserControl exposes a single public property: public...
7
by: Coleen | last post by:
Does anyone have any good detailed information on the conversion process? We are in the process of converting 2 projects from 2003 to 2005 and have some conversion errors that I can not find...
5
by: billsahiker | last post by:
I saw one post here that basically said no way, but not sure which vs version was being discussed. Using vs 2005 I develped a user control in a vb project and would like to use that usercontrol in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.