• 0

[VS2008] The designer loader did not provide a root component but...


Question

I have this application that's working perfectly fine, I mean, I can compile without any errors/warnings/whatever and run it just like any other and it just works.

However, every time I do (compile), the main form designer just disappears and instead I get the following:

vs2008bugrk2.th.jpg

I've searched Google a lot and found various links about it but couldn't find a way to solve it...

This is driving me nuts, every time it happens, I have to close the form and reopen and it's becoming very annoying...

Any ideas?

EDIT:

Something I forgot... I'm not sure if this is really the cause or not but, the main form inherits from a class named SkinnedForm and the problem I just described happens basically when the main form inherits from SkinnedForm. If I change the inheritance to the default (Form), it doesn't happen any more.

So, here's the whole SkinnedForm class:

http://paste.portugal-a-programar.org/pastebin.php?show=2266

Do you think there's something wrong with it?

Edited by Nazgulled
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0
Nobody can help me out?

Seeing how no stack trace is available and that you use native methods inside WndProc the error is likely due to Unmanaged code. Try making the WndProc code for runtime only by using the IsDesignMode property:

protected override void WndProc(ref Message m) 
{
  if(!IsDesignMode)
  {
	  //all the code here
  }
}

If that doesn't fix it, try it on every piece of code in the SkinnedForm class until you locate the problem.

Link to comment
Share on other sites

  • 0

Actually it's just DesignMode but I don't think it's working. I put that on every piece of code in the SkinnedForm class but it didn't help...

Anyway, that "if(!DesignMode)" suggestion actually makes sense, do you think I should keep it anyways? But I should have the "base.WndProc(ref m);" outside the if right?

Link to comment
Share on other sites

  • 0
Actually it's just DesignMode but I don't think it's working. I put that on every piece of code in the SkinnedForm class but it didn't help...

Anyway, that "if(!DesignMode)" suggestion actually makes sense, do you think I should keep it anyways? But I should have the "base.WndProc(ref m);" outside the if right?

I'm not even sure WndProc gets called in design mode, so it might be unnecessary. But if it does, then yes, base.WndProc should be outside the if statement.

Link to comment
Share on other sites

  • 0

I just added a message box to WndProc and yeah, it's called in design mode so I better add that if, it makes sense to have it there.

Anyway, I don't think the problem is fixed though... :(

Link to comment
Share on other sites

  • 0

Just for the record, the problem was related to Krypton Toolkit. I'll need to wait for the next release for the fix although it's easily fixable if one has the source code, which I don't.

Link to comment
Share on other sites

  • 0
I have this application that's working perfectly fine, I mean, I can compile without any errors/warnings/whatever and run it just like any other and it just works.

However, every time I do (compile), the main form designer just disappears and instead I get the following:

vs2008bugrk2.th.jpg

I've searched Google a lot and found various links about it but couldn't find a way to solve it...

This is driving me nuts, every time it happens, I have to close the form and reopen and it's becoming very annoying...

Any ideas?

EDIT:

Something I forgot... I'm not sure if this is really the cause or not but, the main form inherits from a class named SkinnedForm and the problem I just described happens basically when the main form inherits from SkinnedForm. If I change the inheritance to the default (Form), it doesn't happen any more.

So, here's the whole SkinnedForm class:

http://paste.portugal-a-programar.org/pastebin.php?show=2266

Do you think there's something wrong with it?

If you have not solved the problem,

The problem as far as I can see is in the initialization of the components in form X.designer.cs

I have, and many others have had the same issue and I discovered that the order in which the components are initialized will cause this problem.

for example, a data grid component may be dependent on some other component such as a binding source, if the initialization order of the binding source is after the data grid it may! cause this problem.

This was certainly the case for the issue I had, in my case, I had a custom data grid derived from a standard grid with additional properties, a custom control which was also dependent on another custom control.

One of the custom properties of the data grid triggered the initialization for first (very dependent) custom control which was not yet initialized (null), to make matters worse the first custom control needed to have its reference to the second (very dependent) custom control set before the data grid could be successfully initialized.

The solution was simple, move the initialization code for the vital components to before the initialization of the component which is causing the problem.

As the initialization order of the second custom control was before the first custom control and the data grid, this did not need to be moved, however the first controls initialization code needed to be moved to before the initialization code of the data grid.

// Before -----------------------------------------------------------------------------------------------------------------

//

// data grid

//

this.gvWidgets.AltRowColor = System.Drawing.Color.Empty;

this.gvWidgets.ColWidths = null;

this.gvWidgets.Connect = true; --------> this line triggered the initialization of the first custom control.

this.gvWidgets.ControlLabel = null;

this.gvWidgets.DefaultRowColor = System.Drawing.Color.Empty;

this.gvWidgets.FieldList = "description,price,stock";

this.gvWidgets.FillControl = false;

this.gvWidgets.Location = new System.Drawing.Point(6, 59);

this.gvWidgets.LookUpFields = null;

this.gvWidgets.Name = "gvWidgets";

this.gvWidgets.OrderByPart = null;

this.gvWidgets.PrettyName = "Widgets";

this.gvWidgets.RecordIdFieldName = "id";

this.gvWidgets.SelectedRow = 0;

this.gvWidgets.Size = new System.Drawing.Size(463, 150);

this.gvWidgets.SqlDataSource = this.sqWGrid; ----------> this is the first custom control not yet initialized

this.gvWidgets.SwitchRowColors = false; this needed to be moved to above the line that triggered

this.gvWidgets.TabIndex = 0; the initialization

this.gvWidgets.TableName = "widget";

this.gvWidgets.TotalFields = null;

this.gvWidgets.TotalsRowColor = System.Drawing.Color.Empty;

this.gvWidgets.WantRecordId = false;

this.gvWidgets.WherePart = "";

//

// first custom control

//

this.sqWGrid.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("sqWGrid.BackgroundImage")));

this.sqWGrid.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;

this.sqWGrid.Location = new System.Drawing.Point(86, 278);

this.sqWGrid.Name = "sqWGrid";

this.sqWGrid.ServerSource = this.Server;

this.sqWGrid.Size = new System.Drawing.Size(20, 22);

this.sqWGrid.sqlConnect = true;

this.sqWGrid.SqlStatement = "SELECT description,price,stock FROM widget";

this.sqWGrid.TabIndex = 49;

this.sqWGrid.Text = "lizardSQLSource1";

this.sqWGrid.Visible = false;

// After --------------------------------------------------------------------------------------------------------------------

//

// first custom control

//

this.sqWGrid.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("sqWGrid.BackgroundImage")));

this.sqWGrid.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;

this.sqWGrid.Location = new System.Drawing.Point(86, 278);

this.sqWGrid.Name = "sqWGrid";

this.sqWGrid.ServerSource = this.Server;

this.sqWGrid.Size = new System.Drawing.Size(20, 22);

this.sqWGrid.sqlConnect = true;

this.sqWGrid.SqlStatement = "SELECT description,price,stock FROM widget";

this.sqWGrid.TabIndex = 49;

this.sqWGrid.Text = "lizardSQLSource1";

this.sqWGrid.Visible = false;

//

// data grid

//

this.gvWidgets.AltRowColor = System.Drawing.Color.Empty;

this.gvWidgets.ColWidths = null;

this.gvWidgets.SqlDataSource = this.sqWGrid;

this.gvWidgets.Connect = true;

this.gvWidgets.ControlLabel = null;

this.gvWidgets.DefaultRowColor = System.Drawing.Color.Empty;

this.gvWidgets.FieldList = "description,price,stock";

this.gvWidgets.FillControl = false;

this.gvWidgets.Location = new System.Drawing.Point(6, 59);

this.gvWidgets.LookUpFields = null;

this.gvWidgets.Name = "gvWidgets";

this.gvWidgets.OrderByPart = null;

this.gvWidgets.PrettyName = "Widgets";

this.gvWidgets.RecordIdFieldName = "id";

this.gvWidgets.SelectedRow = 0;

this.gvWidgets.Size = new System.Drawing.Size(463, 150);

this.gvWidgets.SwitchRowColors = false;

this.gvWidgets.TabIndex = 0;

this.gvWidgets.TableName = "widget";

this.gvWidgets.TotalFields = null;

this.gvWidgets.TotalsRowColor = System.Drawing.Color.Empty;

this.gvWidgets.WantRecordId = false;

this.gvWidgets.WherePart = "";

//----------------------------------------------------------------------------------------------------------

I think that Microsoft needs to fix this problem by setting the initialization code in order of a components dependents not in order of which they are placed on a form.

I hope this helps you and others having the same problem.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.