Visual Studio 2010中不断改变我的WinForms控制 [英] Visual Studio 2010 keeps changing my winforms control

查看:150
本文介绍了Visual Studio 2010中不断改变我的WinForms控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS 2010中的表单设计不断变化我进入一个奇怪的情况与用户控件,然后告诉我它不存在!编译和运行的第一次,然后如果我改变的东西无关的,它给了我在designer.cs文件中的错误(无法解析符号SomeEntry 的)。

I have an odd situation with a user control in VS 2010. The form designer keeps changing my entry and then telling me it does not exist! It compiles and runs the first time, and then if I change something unrelated, it gives me an error in the designer.cs file (Cannot resolve symbol SomeEntry).

private SomeEntry someEntry;
// ...
this.someEntry = new **MyNameSpace**.SomeEntry();

如果我删除 myNameSpace对象。

this.someEntry = new SomeEntry();

它的工作,直到我做出改​​变了。如果我看一下类,当鼠标悬停在更改设计文件,SomeEntry节目 SomeEntry.SomeEntry() 而不是 MyNameSpace.SomeEntry()

基本上,这个定义是这样的:

Basically, the definition is something like this:

namespace MyNameSpace
{
    public partial class SomeEntry : FormValidatingUserControl
    {
        public SomeEntry()
        {
            InitializeComponent();
        }
    }
}

所以,我该怎么办?

So, what do I do?

推荐答案

事实证明,我应该张贴了我的code,正是因为它出现了,因为我相信有人会想通了这一点对我来说越快。

It turns out that I should have posted my code EXACTLY as it appeared, as I am sure someone would have figured this out for me sooner.

问题是,我正在努力简化为后,并改变了myNameSpace和SomeEntry的名字,以保持通用的。

The issue was that I was trying to simplify for the post, and changed the names of MyNameSpace and SomeEntry to keep it generic.

该项目的的东西的命名空间的的东西的(到目前为止,正常的),而且是从实体框架生成的类的的东西的。

The project is something the namespace is something (so far, normal) and there was a generated class something from the entity framework.

要重现该问题,我创建了一个名为 WinFormTestX 的新项目。所以,解决的办法是的 WinFormTestX 的,该项目的 WinFormTestX 的。我添加了一个名为WinFormTestX,但没有与它无关。

To reproduce the problem, I created a new project called WinFormTestX. So, the solution is WinFormTestX and the project WinFormTestX. I added a class called WinFormTestX, but did nothing with it.

namespace WinFormTestX
{
    public class WinFormTestX
    {
        public int ID { get; set; }
    }
}

现在,我创建了一个用户控件(的UserControl1)拖放就可以了简单的按钮。编译,工具箱增加了这种控制,符合市场预期。现在,我把它放在Form1上并编译它,并得到一个错误:

Now, I create a UserControl (UserControl1) and drop a simple button on it. Compile it, and the toolbox adds this control, as expected. Now, I drop it on Form1 and compile it and get an error:

错误1类型名称的UserControl1   在类型不存在   WinFormTestX.WinFormTestXD:\ DATA \项目\ TEMP \ WinFormTestX \ Form1.Designer.cs 31 51 WinFormTestX

Error 1 The type name 'UserControl1' does not exist in the type 'WinFormTestX.WinFormTestX' D:\Data\Projects\Temp\WinFormTestX\Form1.Designer.cs 31 51 WinFormTestX

当我右键单击类WinFormTestX和从项目中排除(或删除),一切正常。

As soon as I right click on the class WinFormTestX and Exclude From Project (or delete it), everything works.

所以,仅仅具有类相同的名称命名空间,即使不使用的项目,会导致一个问题。很明显,现在我知道原因,还有就是围绕这一个简单的方法。但是,就是这个东西,是应该被提交到微软一个错误?

So, just having the class in the project of the same name as the namespace, even when it is not used, causes an issue. Obviously, now that I know the cause, there is a simple way around this. But, is this something that is a "bug" that should be submitted to Microsoft?

这篇关于Visual Studio 2010中不断改变我的WinForms控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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