我开发了一些自定义控件,这些控件扩展了按钮、用户控件等。我有一个问题,VS2010会随机地完全删除调用自定义控件构造函数的代码行(由Windows Forms生成器编辑),因此无法查看设计视图。应用程序仍然可以完全构建和运行。
我已经测试并排除了以下问题:
Public constructor - evidently having a non public (internal, etc.) constructor can cause issues like this. I've checked 100 times - ALL the custom controls have public constructors.
Empty constructors - in addition to being public, it needs to be empty.
No calling anything that could fail in the constructor - I've reduced ALL constructors for custom controls to empty
calls. No luck there.Name() { }
Namespaces - evidently being in a different namespace can cause problems? I'm in the same one, and the files are IN THE SAME PROJECT.
Unload project. Close VS. Delete .suo intellisense file. Delete obj files. Open VS. Reload project. Rebuild project. Still no luck.
这真的非常令人沮丧。我已经到了想要放弃使用自定义控件并手动逐个设置每个控件皮肤的地步,以避免这种情况。有没有人知道是什么原因引起的?