"找不到类型和QUOT;错误加载在Windows窗体设计器的一种形式找不到、窗体、加载、形式

由网友(张:张大嘴巴、张开双臂,开张大吉)分享简介:我有一个.net 2.0 Windows窗体应用程序,这使得大量使用的ListView 的控制。我的子类的的ListView 类成模板 SortableListView< T> 类,所以它可以是一个聪明一点关于如何显示的东西,和排序本身。不幸的是,这似乎打破了Visual Studio的窗体设计,在这两个V...

我有一个.net 2.0 Windows窗体应用程序,这使得大量使用的ListView 的控制。

我的子类的的ListView 类成模板 SortableListView< T> 类,所以它可以是一个聪明一点关于如何显示的东西,和排序本身。

不幸的是,这似乎打破了Visual Studio的窗体设计,在这两个VS2005和2008年。

该程序编译并运行良好,但是当我尝试查看设计所属的形式,我得到这些错误:

在找不到类型'MyApp.Controls.SortableListView。请确保包含此类型的程序集被引用。如果这种类型是开发项目的一部分,确保该项目已顺利建成。

没有可用于该错误

没有堆栈跟踪或错误行信息 变量listViewImages'要么是未声明或从未分配。

目前MyApp.Main.Designer.cs行:XYZ列:1

 调用堆栈:
在System.ComponentModel.Design.Serialization。codeDomSerializerBase.Error(IDesignerSerializationManager经理,字符串exceptionText,字符串HELPLINK)
在System.ComponentModel.Design.Serialization.$c$cDomSerializerBase.DeserializeEx$p$pssion(IDesignerSerializationManager经理,字符串名称,codeEX pression EX pression)
在System.ComponentModel.Design.Serialization.$c$cDomSerializerBase.DeserializeEx$p$pssion(IDesignerSerializationManager经理,字符串名称,codeEX pression EX pression)
在System.ComponentModel.Design.Serialization.$c$cDomSerializerBase.DeserializeStatement(IDesignerSerializationManager经理,codeStatement语句)
 

的code有问题的行是它实际上是添加到窗体,并为

  this.imagesTab.Controls.Add(this.listViewImages);
 
提示错误3系统找不到指定路径怎么解决

listViewImages被声明为

 私人MyApp.Controls.SortableListView<图像> listViewImages;
 

和实例化的的InitializeComponent 的方法如下:

  this.listViewImages =新MyApp.Controls.SortableListView<图像>();
 

正如前面提到的,程序编译和运行完美,我已经试过了 SortableListView 类移出到一个单独的组件,因此它可以被单独编译,但是这没有什么区别。

我不知道在哪里,从这里去。任何帮助将是AP preciated!

解决方案   

当您添加在ListView,你把它添加到工具箱中,然后将其添加到窗体?

没有,我只是修改 Main.Designer.cs System.Windows.Forms.ListView 改了以 MyApp.Controls.SortableListView<图像>

怀疑这可能是由于仿制药使我真正找到一个解决方案。

有关,我需要做一个SortableListView为每个类,我定义了一个stub类像这样

 类ImagesListView:SortableListView<图像> {}
 

遂作出上述 Main.Designer.cs 文件引用这些存根类,而不是 SortableListView

现在的作品,万岁!

值得庆幸的是,我能够做到这一点,因为我所有的类型是已知的前面,而我只使用了 SortableListView 为减少重复code的方法

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:

Could not find type 'MyApp.Controls.SortableListView'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built.

There is no stack trace or error line information available for this error

The variable 'listViewImages' is either undeclared or was never assigned.

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!

解决方案

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.

阅读全文

相关推荐

最新文章