扩展用户控件后,Visual Studio 在设计模式下被阻止
我在 Visual Studio 2010(从 2008 转换而来)中有一个项目,我创建了一个用户控件,如下所示:
namespace Common.Controls
{
public partial class Panel_BaseMap : UserControl
{
public Panel_BaseMap()
{
//Some properties initialization here, just like = new X();
InitializeComponent();
}
private void BaseMapPanel_Load(object sender, EventArgs e) {
//Here, a new Thread is initialized and started.
}
}
}
我对此没有任何问题,它在设计模式下打开没有任何问题。但我创建了一个新的 UserControl,它扩展到第一个,如下所示:
using Common.Controls;
namespace BC.controls
{
public partial class MapPanel : Panel_BaseMap
{
public MapPanel()
{
InitializeComponent();
}
}
}
好吧,就在我尝试在设计模式下打开这个新控件的那一刻,Visual Studio 完全被阻止,我必须强制它关闭,因为它没有回应。我尝试了很多事情,例如:
public MapPanel()
{
if (!this.DesignMode)
InitializeComponent();
}
仍然被阻止。我打开了 Visual Studio 的第二个实例,然后在第一个实例上“调试 --> 附加到进程 --> devenv”,并在第二个实例的 Load 方法和两个构造函数上放置了一个断点。结果:两个实例都完全被阻止。
有人可以帮我吗?
预先非常感谢您!
I have a project in Visual Studio 2010 (converted from 2008), and I have created a User control, like this:
namespace Common.Controls
{
public partial class Panel_BaseMap : UserControl
{
public Panel_BaseMap()
{
//Some properties initialization here, just like = new X();
InitializeComponent();
}
private void BaseMapPanel_Load(object sender, EventArgs e) {
//Here, a new Thread is initialized and started.
}
}
}
I don't have any problem with this, it is opened in Design Mode without any problem. But I have created a new UserControl that extends to the first one, like this:
using Common.Controls;
namespace BC.controls
{
public partial class MapPanel : Panel_BaseMap
{
public MapPanel()
{
InitializeComponent();
}
}
}
Well, in the very moment I try to open this new control on design mode, Visual Studio gets totally blocked, and I have to force it to close because it doesn't respond. I have tried many things, like for example:
public MapPanel()
{
if (!this.DesignMode)
InitializeComponent();
}
Still blocked. I have opened a second instance of Visual Studio, then on the first one "Debug --> Attach to process --> devenv" and I have put a breakpoint on the Load method and on both constructors on the second instance. The result: both instances totally blocked.
Can anyone help me, please?
Thank you very much in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我找到了问题。
设计者执行了一些代码,这些代码导致应用程序崩溃。它位于 try-catch 中,在 catch 中,我使用尝试加载加密文件的方法记录了错误:Directory.GetFiles(Application.StartupPath, "*.xml")。问题是 Application.StartupPath 不是我的应用程序路径,而是“C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Microsoft.Data.ConnectionUI.xml”。因此,当我尝试解密它时,它抛出了另一个异常,该异常是用相同的方法记录的......如此无限循环!
Ok I've found the problem.
Some code was executed by the designer, and that code crashed the application. It was inside a try-catch, and inside the catch I logged the error with a method that tried to load an encripted file with this: Directory.GetFiles(Application.StartupPath, "*.xml"). The problem is that Application.StartupPath is not my application path, but "C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Microsoft.Data.ConnectionUI.xml". So, when I tried to decrypt it, it throwed another exception, that was logged with the same method... so infinite loop!