变量“ variable_name”未声明或从未分配 [英] The variable 'variable_name' is either undeclared or was never assigned

查看:198
本文介绍了变量“ variable_name”未声明或从未分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与标题错误有关的问题。我使用c#和Visual Studio 2010。

I have a question related to the error on the title. Im working with c# and Visual Studio 2010.

我有一个声明为 public class FormularioGeneral:Form的表单,这是我其余表单的基础应用。当我尝试访问Designer视图时,多次出现此错误,如您在图像中看到的:

I have a form declared as "public class FormularioGeneral : Form", which is the base for the rest of the forms in my application. When i try to access the Designer View i get this error several times, as you can see in the image:


所有错误都引用InitializeComponent方法中的行,其中,值分配给这样的属性:

All the errors references lines inside the InitializeComponent method, where the value is assigned to a property like this one:

[...]            
this.PanelMargenIzquierdoCapaBase.BackColor = m_ColorCapaBase;
[...]

但是所有变量都在与read相同的类中声明仅属性,并且所有属性均在构造函数中调用的方法内分配。

But all the variables are declared in the same class as read-only properties and all of them are assigned inside a method which is called in the constructor.

属性声明:

    protected Color m_VariableName;
    public Color VariableName
    {
        get { return m_VariableName; }
        set { }
    }

构造函数代码:

    public FormularioGeneral()
    {
        ConfigurarUI();
        AccionesConstructor();
        InitializeComponent();
        PostInicializacionComponentes();
        EstablecerIcono();
        InicializarLocalizacionFormulario();
    }

ConfigurarUI方法:

ConfigurarUI method:

public virtual void ConfigurarUI()
{
        [...]

        m_AltoBordeSuperiorCapaBase = 30;
        m_AltoBordeInferiorCapaBase = 7;
        m_AnchoBordesLateralesCapaBase = 7;

        m_ColorCapaBase = Color.FromArgb(50, 100, 150);
        m_ColorTextoCapaBase = Color.White;
        m_ColorTextoBotonAplicacion = Color.Black;

        m_FuenteTextoIzquierdoCapaBase = new System.Drawing.Font("Verdana", 11.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        m_FuenteTextoCentroCapaBase = new System.Drawing.Font("Verdana", 14.0F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        [...]
}

据我所知,所有给出错误的变量均已正确声明,并在调用InitilizeComponent函数之前已分配了一个值。

So, as far as i know, all the variable which are giving the errors are correctly declared and have a value assigned before the InitilizeComponent function is called.

此时我被困住了,不知道该怎么办解决问题。希望你们中的一些人可以帮助我解决这个问题。

Im stuck at this point and dont know what to do to solve the problem. Hope some of you can help me with this issue.

推荐答案

所以,过去我遇到过同样的问题,需要修复我做了以下事情:

So, I have had the same problem in the past, for fix I did the following:


  • 解决方案→清洁解决方案;

  • 构建→重建解决方案;
  • 关闭Visual Studio,重新打开。

非常感谢马歇尔·贝鲁(Marshall Belew)!

这篇关于变量“ variable_name”未声明或从未分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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