使得Visual Studio设计忽略的公共属性 [英] Making the Visual Studio designer ignore a public property

查看:290
本文介绍了使得Visual Studio设计忽略的公共属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用以下属性的公共财产一个用户控件:

I have a UserControl with a public property using the following attributes:

[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

我曾尝试删除所有者的形式,重新创建一个新的形成在Visual Studio 2010,并加入这个用户控件到窗体。它使加入像在设计文件中的以下行:

I have tried deleting the owner form, re-creating a fresh form in Visual Studio 2010, and adding this UserControl to the form. It keeps adding a line like the following in the Designer file:

this.vMyUserControl.MyProperty = ((MyNamespace.MyClass)(resources.GetObject("vMyUserControl.MyProperty")));

这崩溃我的应用程序,因为这个属性的目的不是要通过序列化创建。

This crashes my application because this property is not designed to be created by serialization.

推荐答案

我没能找到真正的解决办法,但有解决方法,而不是...

I failed to find a real solution, but a workaround instead...

我不得不进入Form.resx文件并找到数据/值密钥对,它正在反序列化到我的公共财产。我手动删除了对XML内容,然后我就能够运行应用程序。

I had to go into the Form.resx file and locate the data/value key pair that it was deserializing into my public property. I manually deleted the XML pair contents and then I was able to run the application.

这让我的应用程序构建和无差错运行。其他一切我试过(包括删除了我的用户,并多次重新创建它的容器的形式),没有工作。

This allowed my application to build and run without errors. Everything else I tried (including deleting the container form for my UserControl and re-creating it repeatedly) did not work.

这篇关于使得Visual Studio设计忽略的公共属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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