相关疑难解决方法(0)

虚拟成员在构造函数中调用

我从ReSharper收到一条关于从我的对象构造函数调用虚拟成员的警告.

为什么不做这件事?

c# resharper constructor warnings virtual-functions

1270
推荐指数
11
解决办法
17万
查看次数

x64中的Visual Studio设计器不起作用

在Visual Studio 2010 64位中,我无法设计我的表单.
我一直收到这个警告(和错误):

Warning 18  
The designer could not be shown for this file because none of the classes within it can be designed.  The designer inspected the following classes in the file: 
MainForm --- The base class 'Blah' could not be loaded.  Ensure the assembly has been referenced and that all projects have been built.
Run Code Online (Sandbox Code Playgroud)

这只发生在我为x64编译时......在x86中,设计师运行良好.

只是想明确我需要项目在x64上工作,因为很多项目的组件都是用x64编译的,如果表单是在x86中则无法工作.

有没有其他人遇到这个并找到了解决方案?

c# 64-bit designer visual-studio-2010

29
推荐指数
3
解决办法
2万
查看次数

得到错误变量<变量名称>未声明或从未分配

我使用Visual Studio 2008在winforms C#中实现了一个大表单.在对话的大部分工作正常后,当我尝试打开设计器时,它开始显示很多错误masseges.

"该变量要么未声明,要么从未分配过"

我得到了很多以前运行良好的控件.我认为它发生在我使用的自定义控件上

.net c# visual-studio-2008 winforms

6
推荐指数
2
解决办法
1万
查看次数

变量未声明或从未分配警告

我有这样的代码:

这是基类:

public class BaseClass : UserControl
{
     protected ListView list;
     protected TreeView tree;

     public BaseClass()
     {
         //...
     }
     //...
}
Run Code Online (Sandbox Code Playgroud)

儿童班

public partial class MyClass : BaseClass
{
     public MyClass()
     {
         InitializeComponent();
         this.BackColor = VisualStyleInformation.TextControlBorder;
         this.Padding = new Padding(1);
     }
     //...
}

partial class MyClass
{
    //...

    private void InitializeComponent()
    {
         this.tree = new System.Windows.Forms.TreeView();
         this.list = new System.Windows.Forms.ListView();
         //...
         this.tree.Location = new System.Drawing.Point(0, 23);
         this.tree.Name = "blablabla";
    }
}
Run Code Online (Sandbox Code Playgroud)

并警告:

Warning 1 The variable 'tree' is either undeclared …
Run Code Online (Sandbox Code Playgroud)

.net c# winforms

5
推荐指数
1
解决办法
1万
查看次数

如何区分用户控件在窗体上加载和运行时加载

我使用Windows窗体应用程序的C#创建了一个用户控件。此用户控件具有一些属性。在运行时,如果用户未输入此属性的值,我想显示一个消息框并退出应用程序。

问题是当我在用户控件的Load事件中编写检查代码时。当我将其拖放到窗体上时,将出现消息框。

private void UserControl1_Load(Object sender, EventArgs e) 
{
    if (_getFirstPageArgument==null || _getFirstPageArgument.Length==0) 
    { 
        throw new Exception("Some Message"); 
    }
}
Run Code Online (Sandbox Code Playgroud)

如何区分表单上的负载和运行时上的负载?

c# user-controls winforms c#-4.0

2
推荐指数
1
解决办法
1935
查看次数