Reputation: 123642
I have a .NET 2.0 windows forms app, which makes heavy use of the ListView
control.
I've subclassed the ListView
class into a templated SortableListView<T>
class, so it can be a bit smarter about how it displays things, and sort itself.
Unfortunately this seems to break the Visual Studio Forms Designer, in both VS2005 and 2008.
The program compiles and runs fine, but when I try view the owning form in the designer, I get these Errors:
There is no stack trace or error line information available for this error
At MyApp.Main.Designer.cs Line:XYZ Column:1
Call stack:
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)
The line of code in question is where it is actually added to the form, and is
this.imagesTab.Controls.Add( this.listViewImages );
listViewImages is declared as
private MyApp.Controls.SortableListView<Image> listViewImages;
and is instantiated in the InitializeComponent
method as follows:
this.listViewImages = new MyApp.Controls.SortableListView<Image>();
As mentioned earlier, the program compiles and runs perfectly, and I've tried shifting the SortableListView
class out to a seperate assembly so it can be compiled seperately, but this makes no difference.
I have no idea where to go from here. Any help would be appreciated!
Upvotes: 43
Views: 34862
Reputation: 1
In my case the problem was the folder's name of my project! Why I think this: I use SVN and in the 'trunk\SGIMovel' works perfectly. But in a branch folder named as 'OS#125\SGIMovel' I can't open the designer for a form that uses a custom control and works in the trunk folder.
Just get off the # and works nice.
Upvotes: -3
Reputation: 22797
It happened to me because of x86 / x64 architecture.
Since Visual Studio (the development tool itself) has no x64 version, it's not possible to load x64 control into GUI designer.
The best approach for this might be tuning GUI under x86, and compile it for x64 when necessary.
Upvotes: 43
Reputation: 4448
I have had the same problem. After removing some of my own controls of the *.Designer.cs-File the problem was solved. After going back to the original code the problem still was solved. So it seems to be a problem with the Visual Sudio cache. At the moment I cannot reproduce this problem.
If you have the problem try to emtpy the folder
C:\Users\YOURNAME\AppData\Local\Microsoft\VisualStudio\VERSION\Designer\ShadowCache
Did it work?
Upvotes: 2
Reputation: 20838
I had this problem too, related to merging massive SVN changes (with conflicts) in the *.Designer.cs file. The solution was to just open up the design view graphically, edit a control (move it to the left then right) and resave the design. The *.Designer.cs file magically changed, and the warning went away on the next compilation.
To be clear, you need to fix all of the code merge problems first. This is just a work around to force VS to reload them.
Upvotes: 8
Reputation: 37
I had the same issue. In my case this issue was due to resource initialization. I moved the following code from InitializeComponent
method to ctor(After calling InitializeComponent
). After that this issue was resolved:
this->resources = (gcnew System::ComponentModel::ComponentResourceManager(XXX::typeid));
Upvotes: 1
Reputation: 123642
when you added the listview, did you add it to the toolbox and then add it to the form?
No, I just edited Main.Designer.cs
and changed it from System.Windows.Forms.ListView
to MyApp.Controls.SortableListView<Image>
Suspecting it might have been due to the generics led me to actually finding a solution.
For each class that I need to make a SortableListView for, I defined a 'stub class' like this
class ImagesListView : SortableListView<Image> { }
Then made the Main.Designer.cs
file refer to these stub classes instead of the SortableListView
.
It now works, hooray!
Thankfully I am able to do this because all my types are known up front, and I'm only using the SortableListView
as a method of reducing duplicate code.
Upvotes: 9
Reputation: 21
Perhaps you forgot to add that:
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Release all resources used.
/// </summary>
/// <param name="disposing">true if managed resources should be removed otherwise; false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
// ...
this.components = new System.ComponentModel.Container(); // Not necessarily, if You do not use
// ...
}
Upvotes: 2
Reputation: 10552
I had something similar - a user control was referring to a remote serice (which I couldn't guarantee being available at design time).
This post on MSDN suggested that I add
if (this.DesignMode) return;
to the Load function of the control, or in my case to the point before the WCF client was initialised. That did the trick.
So
private readonly Client _client = new Client();
becomes
private Client _client;
public new void Load()
{
if(DesignMode) return;
_client = new Client();
}
Upvotes: 1
Reputation: 115773
when you added the listview, did you add it to the toolbox and then add it to the form?
Upvotes: 2
Reputation: 115773
The assembly that contains MyApp.Controls.SortableListView isn't installed in the GAC by any chance is it?
Upvotes: 2
Reputation: 115773
I've had a problem like this (tho not the same) in the past where my control was in a different namespace to my form even tho it was in the same project. To fix it I had to add a
using My.Other.Namespace;
to the top of the designer generated code file. The annoying thing was it kept getting blown away when the designer regenerated the page.
Upvotes: 6