使得Visual Studio设计忽略的公共属性

编程入门 行业动态 更新时间:2024-10-20 03:44:51
本文介绍了使得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设计忽略的公共属性

本文发布于:2023-11-14 00:14:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585690.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   Visual   Studio

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!