Adding a User Control closes VS.NET

  • Thread starter Thread starter joelcochran
  • Start date Start date
J

joelcochran

I am running VS.NET 2005. I have created a UserControl and added it to
my toolbox. When I try to drag it onto a Form, Visual Studio closes
immediately with no reported errors.

I've added the UC to a new solution, I have the project in the
solution, and am referencing the Project output in the Form. Where can
I go from here?

Thanks,

Joel
 
Joel,

With VS 2005 this happens sometimes when something throws an unahndled
exception when the control is in the designer. Attach a debugger to break on
the place where exceptions are thrown.
 
Actually, I solved the problem last night: I was referencing the UC
type instead of the actual instance in a Property:

public MapConfig MapConfig
{
get { return this.MapConfig; }
set
{
this.resetControl();
this.MapConfig = value;
if (this.MapConfig != null)
{
// etc

SHOULD have been:
public MapConfig MapConfig
{
get { return this.config; }
set
{
this.resetControl();
this.config = value;
if (this.config != null)
{

Thanks for the response though!

I am confused about two things though: first of all, why would this
even compile? Second of all, why would it cause VS to shut down?

Joel
 
Well, the second would be because of the infinite loop while trying to read
(or write) your control's values...
It copes with exceptions OK (message-boxing them), but this? tricky...

The first would be because it isn't illegal? Very inadvisable, definately,
but not illegal. There should maybe (as a suggestion for a tweak) be a
recursion warning about properties invoking themselves, though - i.e. the
setter calling the same setter on the "this" instance (or similar with
static); that might be a nice feature...

Marc
 
ar right, /now/ I see your question about not compiling; you /weren't/ using
the UC type; you were referencing the MapConfig property on the current
instance. In this scenario, you can get at the UC type only by using more of
the namespace.

Marc
 
Back
Top