Visual Studio Designer中的错误:“类型...未标记为可序列化" [英] Error in Visual Studio Designer: "Type ... is not marked as serializable"

查看:110
本文介绍了Visual Studio Designer中的错误:“类型...未标记为可序列化"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个带有通用gridview控件的项目,该控件在每种形式中都使用.

Hi,

I''ve created a project with a generic gridview control which I use in every form.

public partial class _GenericGridViewControl<T> : UserControl


public partial class tblMerk_GridViewControl : _GenericGridViewControl<tblMerk>, IGenericGridViewControl


对于类型< T>我只使用Linq数据类.一切工作都很好,直到我在笔记本电脑上以意外安全的方式签出了项目文件并格式化了笔记本电脑.作为修复,我不得不撤消检出计算机上的项目文件,而这正是奇怪的东西开始的地方;

当我尝试在设计器中调整自定义控件的大小(任何形式的任何自定义控件)时,都会弹出以下错误:


For type<T> I only use Linq dataclasses. It all worked great, until I accedently checked-out the project file in sourcesafe on my laptop and formatted my laptop. As a fix I had to undo-checkout the project-file on my computer and that''s where the weird stuff began;

When I try to resize a custom control in the designer(any custom control in any form) the following error pops-up:

<br />
Type ''DataAccess.tblMerk'' in Assembly ''DataAccess, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'' is not marked as serializable.<br />


现在,我已经在Google上搜索了此问题,发现与设计师想对控件进行序列化以进行某种类型的缓存有关,但是它不能,因为我的自定义控件无法序列化,并且会永远不可序列化.我还发现它可能与某些设计器文件中的其他错误有关,但该错误掩盖了该错误,但是我不确定这是我的项目编译和运行良好的原因.

请帮助我让设计师重新开始为我工作.

在此先感谢Willem


Now I''ve searched google for this problem and I found out it has something to do with the designer wanting to serialize the control for some kind of caching, but it can''t, cause my custom controls are not serializable, and will never be serializable. I also found out it might has something to do with a different error in some designer file which is masked by this error, but I don''t know for sure that this is the cause here as my project compiles and workes great.

Please help me get my designer to start working for me again.

Thanks in advance, Willem

推荐答案

您可以尝试以下解决方法:
http://stackoverflow.com/questions/4973506/未能创建为可序列化的组件类型 [
can you try the following workaround:
http://stackoverflow.com/questions/4973506/failed-to-create-component-type-is-not-marked-as-serializable[^]

thanks,
Hemant


我建​​议不要使用通用控件.将成员标记为泛型是可以的,但是将整个类标记为泛型听起来像是设计者会遇到很多问题...

如果您确实要使用通用控件,则无需考虑设计器,然后将其手动添加到您的.cs文件中.
I suggest not to use generic controls. Marking a member as generic is OK, but marking the whole class as generic sounds like you will have lots of problems with the designer...

If you really want to use a generic control, then forget about the designer and add it manually in your .cs file.


这篇关于Visual Studio Designer中的错误:“类型...未标记为可序列化"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆