简体   繁体   English

Winforms Designer错误“解析EntityName时发生错误”

[英]Winforms Designer Error “An error occured while parsing EntityName”

I'am using a custom control code for my winforms application to create a custom colored progressbar. 我正在为winforms应用程序使用自定义控件代码来创建自定义彩色进度条。 I can build it, and it works fine, BUT everytime I try to use designer, it crashes. 我可以构建它,它工作正常,但每次我尝试使用设计师,它崩溃。 "An error occured while parsing EntityName" “解析EntityName时发生错误”

  • If I add from the toolbox, this is what I get . 如果我从工具箱中添加, 这就是我得到的

  • If I insert a progressbar, then rewerite the code for my control (replace progressBar with progressBarEx ), then this is what I get . 如果我插入一个进度条,然后重新使用我的控件的代码(用progressBar替换progressBarEx ),那么这就是我得到的

The code: 编码:

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);
    }
}

} }

Dominik aka galaris provided his answer in his own question. Dominik aka galaris在他自己的问题中提供了他的答案。 I cleaned it up and moved it here: 我把它清理干净并移到这里:

The solution can be found here . 解决方案可以在这里找到 The problem is that one of my folders contained a & character . 问题是我的一个文件夹包含一个&字符 Moving the project to the desktop folder solved the problem. 将项目移动到桌面文件夹解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM