all groups > dotnet windows forms designtime > june 2004 >
You're in the

dotnet windows forms designtime

group:

Please help: Serious problems with code generation of user controls


Re: Please help: Serious problems with code generation of user controls Frank Hileman
6/25/2004 7:20:22 AM
dotnet windows forms designtime:
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

[quoted text, click to view]

Please help: Serious problems with code generation of user controls Bernd S
6/25/2004 11:02:07 AM
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

Re: Please help: Serious problems with code generation of user controls Bernd S
6/28/2004 10:23:26 AM
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]

Re: Please help: Serious problems with code generation of user controls Frank Hileman
6/28/2004 11:01:10 AM
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

[quoted text, click to view]

AddThis Social Bookmark Button