Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ControlCollection.Add()

6 views
Skip to first unread message

Graham McKechnie

unread,
Dec 12, 2005, 8:18:09 PM12/12/05
to
Hi,

I've come across a problem while converting a project to 2005. I've been
struggling with this for the last couple of days and was wondering if anyone
can shed any light on the following exception.

System.ArgumentException was unhandled
Message="An error message cannot be displayed because an optional resource
assembly containing it cannot be found"
StackTrace:
at Microsoft.AGL.Common.MISC.HandleAr()
at System.Windows.Forms.Control._SetParent()
at System.Windows.Forms.Control.set_Parent()
at ControlCollection.Add()
at TTG.Forms.RoundWizardForm.InitializeWizardForms()
at TTG.Forms.RoundWizardForm..ctor()
at TTG.Forms.MainForm.menuItemNewRoundWizard_Click()
at System.Windows.Forms.MenuItem.OnClick()
at System.Windows.Forms.Menu.ProcessMnuProc()
at System.Windows.Forms.Form.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at TTG.TTGMain.Main()

In 2003 I had a wizard setup that would allow a number of windows to be
displayed forward/back in sequence. It consisted of a holding window which
just contained a single panel and a toolbar. The forms of the wizard to be
displayed inside the panel were inherited from a single form. The base form
was a form with Border style set to none. It had a show method that set the
text property of the holding window to the caption property of each window.
These forms were part of a collection and as they were instantiated in the
holding window they were added to the collection with the following

public WizardForm Add(WizardForm wizardForm)
{
// get the location and size from the panel
Point location = hostPanel.Location;
Size size = hostPanel.Size;

// make the new page ( window ) the dimensions of the panel
wizardForm.Location = location;
wizardForm.Size = size;

// Add the new page to our list
this.List.Add(wizardForm);

// Add the page to the host panel's controls.
hostPanel.Controls.Add(wizardForm); // this is the line that
fails

return wizardForm;
}

In 2005 this is giving the above exception when executing
hostPanel.Controls.Add(wizardForm).

It would appear that Controls.Add has some additional checking in VS2005
that is causing this to fail, but I'm having a hard time trying to guess
what it doesn't like.

I also use this type of code in a custom tab control in another project,
where the panel is not full screen, so I guess it is also going to fail at
the same point.

I was hoping someone would have a workaround or suggestion, to overcome
this.

Graham


Sergey Bogdanov

unread,
Dec 13, 2005, 7:27:46 AM12/13/05
to
Hosting forms in panels/tab controls/etc. was allowed in CF1.0. But for
CF2.0 you have to redesign your application and replace a form with a
user control; otherwise HandleAr will throw the ArgumentException that
you've got.

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

Graham McKechnie

unread,
Dec 13, 2005, 3:26:19 PM12/13/05
to
Sergey,

Thanks for your reply. I eventually figured that out yesterday and tried a
UserControl which worked. Not so seemless this transition to CF2.0! This
conversion has had major hassles all the way. I now wondering how many of
these gotchas I'm going to hit before I'm done.

I'm now more interested in where you got that information from. I searched
all over the place, but couldn't find anything that states what you've just
stated - not that I don't believe you.

Graham


"Sergey Bogdanov" <sergey....@gmail.com> wrote in message
news:%231BhgC%23$FHA....@tk2msftngp13.phx.gbl...

Chris Tacke, eMVP

unread,
Dec 13, 2005, 5:04:29 PM12/13/05
to
Pure experience - I don't think it's documented at all.

--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate


"Graham McKechnie" <gmkn...@bigpond.net.au> wrote in message
news:OuxO6NCA...@TK2MSFTNGP11.phx.gbl...

Graham McKechnie

unread,
Dec 13, 2005, 6:15:11 PM12/13/05
to
Chris,

I hope there are not too many more of them.

I would have thought the compiler could have caught that one eg
panel.controls.Add( not a form ).

Graham


"Chris Tacke, eMVP" <cta...@spamfree-opennetcf.org> wrote in message
news:eKcMyEDA...@TK2MSFTNGP14.phx.gbl...

Chris Tacke, eMVP

unread,
Dec 13, 2005, 6:24:24 PM12/13/05
to
Yeah, one would think. I've passed it on to the CF team and they've said
they'll take look at it.

--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate


"Graham McKechnie" <gmkn...@bigpond.net.au> wrote in message

news:u3UvRsD...@TK2MSFTNGP11.phx.gbl...

0 new messages