C#设计师错误 [英] C# designer error

查看:62
本文介绍了C#设计师错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目有很多种形式,但现在只有一个不能打开它的设计师。我已经尝试了很多次,但我仍然不知道为什么。





错误:Micorsoft visual studio 2010已停止

My project has many forms, but only one cann't open its designer now. I have try many times, but I still don't know why.


error: Micorsoft visual studio 2010 has stopped

推荐答案

这不是我们可以回答的问题 - 你可能有很多方法导致这类问题。

很可能是你在designer.cs文件中添加了一个控件或代码,这意味着InitializeComponent方法永远不会返回:无限循环或其他一些奇怪的东西! :笑:



但是我们无法帮助你。

首先考虑一下自上次以来你做了哪些改变它确实起作用并试图扭转它们。如果你有一个Source控制系统,找出你做了哪些确切的更改,如果没有,那么你最近的备份可能会有所帮助。



您可能需要手动编辑designer.cs文件,直到它将加载 - 所以先备份以防万一你完全破坏了东西!

我以前有过这个,它可以是一个PITA来追踪 - 但没有一个解决方案,没有人,但你可以做任何事情。

抱歉,你必须自己排序。
This isn't a question we can answer - there are far, far too many ways you could have caused this type of problem.
The most likely is that you have added a control or code to the designer.cs file which means that the InitializeComponent method never returns: an infinite loop, or some other weirdness! :laugh:

But we can't help you there.
So start by thinking about what changed you have made since the last time it did work and try reversing them. If you have a Source control system, find out what exactly changes you have made, if not then your most recent backup may help.

You may have to manually edit the designer.cs file until it will load - so backup first in case you completely wreck things!
I've had this before, and it can be a PITA to track down - but there is no one solution, and nobody but you can do anything about it.
Sorry, but you will have to sort it yourself.


崩溃的原因可能有几个。但最常见的原因之一是使用ctor或Load方法编写的代码。



跳过设计器运行代码的最简单方法是使用DesignMode属性。



例如

The reasons for the crash can be several. But one of the most common reason is the code written in either ctor or Load method.

The easiest way to skip the designer from running your code is by using DesignMode property.

E.g.
class MyForm : Form
{
 public MyForm()
 {
   InitializeComponents();

   if(DesignMode) return;

   // ... Rest of the code
 }

 protected override void OnLoad(EventArgs e)
 {
   base.OnLoad(e);

   if(DesignMode) return;

   // ... Rest of the code
 }
}





此外,如果您想知道导致错误的确切代码行,那么您可以附加你的VS(在设计时)到调试器(VS的另一个实例)并调试设计器。有关详细信息,请参阅此链接


这篇关于C#设计师错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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