Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / June 2004

Tip: Looking for answers? Try searching our database.

Please help: Serious problems with code generation of user controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bernd S - 25 Jun 2004 10:02 GMT
Hi,

we have a big problem with re-using a user control as component inside
another user control. The Visual Studio designer often generates code for
the *inner* user control in InitializeComponent of the *outer* user control.
But this code was already generated in the InitializeComponent method of the
*inner* user control. Because of this code is generated and executed *twice*
(once in the inner, once in the outer user control), there are errors in
design mode. Often the code cannot even be compiled!

And worst, when the Visual Studio designer has thrown an exception, project
assemblies are locked and we must restart the whole solution. In our very
big solution, together with a version control system, this means that there
are several minutes lost until we can continue to work.

So I have to come to the conclusion that it is not practicable to use Visual
Studio with large projects which are extensively re-using user controls as
component of another user control!???

Please help!

Thanks,
Bernd
Frank Hileman - 25 Jun 2004 15:20 GMT
Post an example of the generated code, and the usercontrol code -- perhaps
for a single property. You may save yourself some grief by using separate
solutions for the usercontrol and the users of the usercontrol. In a post
build event copy the user control output to a separate folder, then
reference from there.

This is more work,  but you can still debug the usercontrol by having the
debug mode for the usercontrol project set to application, the application
being devenv.exe, and have it start up with a test project using the
usercontrol by passing the path to the project on the command-line. This is
the only reliable way to debug design-time behavior.

It should be possible to eliminate your code serialization problems. Look
closely at ShouldSerialize and Reset methods, if you are not using the
DefaultValue attribute for properties.

Regards,
Frank Hileman

check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor

> Hi,
>
[quoted text clipped - 19 lines]
> Thanks,
> Bernd
Bernd S - 28 Jun 2004 09:23 GMT
Following is an excerpt of the code generated by Visual Studio in the
InitializeComponent method of the outer user control 'this', after the inner
user control (called 'smfSerialEventUserControl1') has been dragged and
dropped onto it and then changing from design view to code view:

   //
  // smfSerialEventUserControl1
  //
  ...

this.smfSerialEventUserControl1.Controls.Add(this.smfPopupContainerControl);

this.smfSerialEventUserControl1.Controls.Add(this.smfBusinessObjectPopupCont
ainerEdit);
  this.smfSerialEventUserControl1.Controls.Add(this.cbRepeat);
  ...

At the same time two error messages appear in the task list which say that
code generation failed for property 'Controls' because of the object
reference was not set to an object instance.

This generated code is not correct because the three controls
'smfPopupContainerControl', 'smfBusinessObjectPopupContainerEdit' and
'cbRepeat' are not members of the outer user control 'this' but are
(private) members of the inner user control 'smfSerialEventUserControl1'.

Can you imagine what's going wrong here?

> Post an example of the generated code, and the usercontrol code -- perhaps
> for a single property. You may save yourself some grief by using separate
[quoted text clipped - 48 lines]
> > Thanks,
> > Bernd
Frank Hileman - 28 Jun 2004 19:01 GMT
It appears that the "inner" child controls somehow were added to the root
designer container for the outer control "this". This is not automatic --
there is some custom code written somewhere that gets the IContainer and
explicitly adds them, or they are added to the component tray, perhaps. Are
these inner controls exposed in some other way? I would look at the custom
control designer code.

Frank

> Following is an excerpt of the code generated by Visual Studio in the
> InitializeComponent method of the outer user control 'this', after the inner
[quoted text clipped - 5 lines]
>    //
>    ...

this.smfSerialEventUserControl1.Controls.Add(this.smfPopupContainerControl);

this.smfSerialEventUserControl1.Controls.Add(this.smfBusinessObjectPopupCont
> ainerEdit);
>    this.smfSerialEventUserControl1.Controls.Add(this.cbRepeat);
[quoted text clipped - 10 lines]
>
> Can you imagine what's going wrong here?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.