The variable 'variable_name' is either undeclared or was never assigned

前端 未结 16 942
甜味超标
甜味超标 2020-12-15 03:14

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

I have a form declared as \"public class FormularioGeneral : Form\",

相关标签:
16条回答
  • 2020-12-15 03:36

    In my Solution i had wrong Reference paths which i fixed in the .csproj files. After fixing that i could finally load the Form again.

    0 讨论(0)
  • 2020-12-15 03:39

    I had the same problem and cleaning and rebuilding did not work for me.

    In my case the problem was caused by the Visual Studio designer loading referenced DLLs from the GAC instead of loading them from the <HintPath> directory specified in the .csproj file. The DLLs in the GAC did not have the same version as the locally stored DLLs.

    When I updated the DLLs in the GAC to have the same version everything worked OK again.

    0 讨论(0)
  • 2020-12-15 03:39

    User Controls were caused problem and after trying all suggestions, (Focus solution then Alt+Enter) changing solution's Platform Target from x64 to Any CPU solved the problem.

    0 讨论(0)
  • 2020-12-15 03:41

    I have had the same problem and I fixed it. Actually Visual Studio only works with X86 controls and you can't create a user control in X64 mode and use it.

    You should add a new class library in Any CPU mode and build the class library. then you can add its DLL in your project. Done.

    If it doesn't you must go to the Configuration manager and set the Active solution platform to X64 also do that for all subprojects. Remember that build option has to be checked. and go to the properties of the class library and click on the build tab. then set the platform target to Any CPU.

    0 讨论(0)
  • 2020-12-15 03:42

    I ran into this error because my project is x64 only. Apparently Visual Studio, being a 32bit application, cannot load any forms or controls compiled to 64bit in the designer. It makes total sense, but the error gives you no indication that is the problem.

    See the answer to Visual studio designer in x64 doesn't work.

    The workaround is to change your project to Any CPU when designing, then back when building.

    0 讨论(0)
  • 2020-12-15 03:46

    I had this issue when my user control had some code in the constructor which was related to runtime resource. I added null check and it fixed.

            InitializeComponent();
            if (MyConfig!= null)
            {
                this.label2.Text = MyConfig.text1;
                this.label3.Text = MyConfig.text2;
                this.label1.Text = MyConfig.text3;
            }
    
    0 讨论(0)
提交回复
热议问题