ControlCollection.Add()

G

Graham McKechnie

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
 
S

Sergey Bogdanov

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.
 
G

Graham McKechnie

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 said:
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 said:
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
 
C

Chris Tacke, eMVP

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 said:
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 said:
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 said:
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
 
G

Graham McKechnie

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 said:
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 said:
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 said:
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 wrote:
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
 
C

Chris Tacke, eMVP

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 said:
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 said:
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 said:
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


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 wrote:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top