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?
"Frank Hileman" <frankhil@no.spamming.prodigesoftware.com> schrieb im
Newsbeitrag news:%237z6M%23rWEHA.1764@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view] > 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
>
> "Bernd S" <nospam@nospam7428012.de> wrote in message
> news:%230IU8KpWEHA.1764@TK2MSFTNGP10.phx.gbl...
> > 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
> >
> >
>
>