【问题标题】:Winforms Designer Error "An error occured while parsing EntityName"Winforms 设计器错误“解析 EntityName 时发生错误”
【发布时间】:2010-09-30 07:24:29
【问题描述】:

我正在为我的 winforms 应用程序使用自定义控制代码来创建自定义彩色进度条。我可以构建它,它工作正常,但每次我尝试使用设计器时,它都会崩溃。 "解析 EntityName 时出错"

  • 如果我从工具箱中添加,this is what I get

  • 如果我插入一个进度条,然后重写我的控件的代码(将progressBar替换为progressBarEx),然后this is what I get

代码:

using System.Drawing;
using System.Windows.Forms;

namespace Crystal
{
public class ProgressBarEx : ProgressBar
{
    private SolidBrush brush = null;

    public ProgressBarEx()
    {
        this.SetStyle(ControlStyles.UserPaint, true);
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        if (brush == null || brush.Color != this.ForeColor)
            brush = new SolidBrush(this.ForeColor);

        Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);
        if (ProgressBarRenderer.IsSupported)
            ProgressBarRenderer.DrawHorizontalBar(e.Graphics, rec);
        rec.Width = (int)(rec.Width * ((double)Value / Maximum)) - 4;
        rec.Height = rec.Height - 4;
        e.Graphics.FillRectangle(brush, 2, 2, rec.Width, rec.Height);
    }
}

}

【问题讨论】:

  • 您是否尝试过重建解决方案然后打开设计器?
  • 是的,几次,删除bin文件夹,关闭,重新打开sln。还搜索了“&”符号,因为我在谷歌上搜索了这个问题,有人说这是由这个字符引起的,但我没有找到。
  • 尝试读取 XML 时出现轰炸,这到底是怎么回事?您还没有提供所有代码,至少缺少 Value 和 Maximum 属性。那里还有什么?是否使用任何应用程序设置?
  • 嗯我不知道那个 xml 读取的东西是什么,我什至没有在我的程序中使用任何 XML。我不知道当我通过工具箱插入控件时自动创建的 :O 最小值和最大值是什么。因为它是进度条的子类,它具有所有属性,就像普通的进度条一样,所以它有最小值和最大值。这是我这个自定义进度条的全部代码。没有应用设置。
  • 表单资源是xml格式,可能有问题?

标签: c# winforms designer


【解决方案1】:

Dominik aka galaris 在他自己的问题中提供了答案。我把它清理干净并移到这里:

解决方案可以是found here。问题是我的一个文件夹包含& 字符。将项目移至桌面文件夹即可解决问题。

【讨论】:

    猜你喜欢
    • 2011-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多