窗体frmbase2,继承该窗体新建窗体 frmprogress,打开新窗体时提示
“加载文档时出错
未将对象引用设置到对象的实例。 ”,请帮忙看看应如何解决,谢谢! 
frmprogress与frmbase2的命名空间是一致的,frmprogress有引用frmbase2。frmbase2窗体代码如下:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms; using System.Data ; using CostingData;namespace CostingClient.Class
{
/// <summary>
/// Summary description for frmBase2.
/// </summary>
public class frmBase2 : System.Windows.Forms.Form
{ private DevExpress.XtraEditors.Repository.PersistentRepository persistentRepository1;
private DevExpress.XtraEditors.Repository.RepositoryItemTextEdit repositoryItemTextEdit1;
public DevExpress.XtraGrid.GridControl dgShowData;
public DevExpress.XtraGrid.Views.Grid.GridView gridView;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null; public frmBase2()
{ InitializeComponent(); } #region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.persistentRepository1 = new DevExpress.XtraEditors.Repository.PersistentRepository();
this.repositoryItemTextEdit1 = new DevExpress.XtraEditors.Repository.RepositoryItemTextEdit();
this.dgShowData = new DevExpress.XtraGrid.GridControl();
this.gridView = new DevExpress.XtraGrid.Views.Grid.GridView();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemTextEdit1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dgShowData)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.gridView)).BeginInit();
this.SuspendLayout();
// 
// persistentRepository1
// 
this.persistentRepository1.Items.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
 this.repositoryItemTextEdit1});
// 
// repositoryItemTextEdit1
// 
this.repositoryItemTextEdit1.AllowFocused = false;
this.repositoryItemTextEdit1.AutoHeight = false;
this.repositoryItemTextEdit1.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.repositoryItemTextEdit1.Name = "repositoryItemTextEdit1";
// 
// dgShowData
// 
this.dgShowData.Dock = System.Windows.Forms.DockStyle.Fill;
// 
// dgShowData.EmbeddedNavigator
// 
this.dgShowData.EmbeddedNavigator.Name = "";
this.dgShowData.Location = new System.Drawing.Point(0, 0);
this.dgShowData.MainView = this.gridView;
this.dgShowData.Name = "dgShowData";
this.dgShowData.Size = new System.Drawing.Size(712, 273);
this.dgShowData.TabIndex = 0;
this.dgShowData.Text = "gridControl1";
// 
// gridView
// 
this.gridView.GridControl = this.dgShowData;
this.gridView.Name = "gridView";
this.gridView.OptionsView.ColumnAutoWidth = false;
this.gridView.DataSourceChanged += new System.EventHandler(this.gridView_DataSourceChanged);
// 
// frmBase2
// 
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(712, 273);
this.Controls.Add(this.dgShowData);
this.Name = "frmBase2";
this.Text = "frmBase2";
((System.ComponentModel.ISupportInitialize)(this.repositoryItemTextEdit1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dgShowData)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gridView)).EndInit();
this.ResumeLayout(false); }
#endregion
frmprogress窗体代码如下; using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;namespace CostingClient
{
public class frmProgress : CostingClient.Class.frmBase2
{ public static frmProgress thisform;
private System.ComponentModel.IContainer components = null; public frmProgress()
{ InitializeComponent(); }
#region Designer generated code private void InitializeComponent()
{ ((System.ComponentModel.ISupportInitialize)(this.dgShowData)).BeginInit(); this.dgShowData.Name = "dgShowData";
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(328, 273);
this.Name = "frmProgress";
this.Text = "进度报告";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.frmProgress_Load);
this.Closed += new System.EventHandler(this.frmProgress_Closed);
((System.ComponentModel.ISupportInitialize)(this.dgShowData)).EndInit(); }
#endregion

解决方案 »

  1.   

    代码没看
    按你的中文解释 frmbase2 是基类
    frmprogress 继承与 frmbase2 类(窗口)你把 frmbase2 设计/代码编辑 保存/关闭
    然后编译一下,相信就解决了
    2003 的窗体继承确实有很多缺陷
    2005 就好多了
      

  2.   

    再有 如果你是新建了一个窗口然后修改form::frmbase2 的话可能问题就复杂了,我搞不定我的方法仅限于 新建了 继承窗体(Inherited form)
      

  3.   

    我编辑保存、重新打开、关闭、重启都试过的。 
    编译没有问题,但编辑时打开继承窗体提示“未将对象引用设置到对象的实例”; 
    运行时打开继承窗体,提示:
    未处理的“System.OutofMemoryException”类型的异常出现在system.windows.forms.dll中。
    其他信息:创建窗口句柄时出错。 请各位指点。 谢谢!
      

  4.   

    哦,private DevExpress.XtraEditors.Repository.PersistentRepository persistentRepository1;日了,你用了  DevExpress 这个控件你安装了这个控件码?你引用了吗?
      

  5.   

    DevExpress我也用过的,安装就可以了,记得除了用里面的报表类,其余的不需要引用的
      

  6.   

    回复人: cooljw(风之谷) 兄弟,你自己写一个控件在使用的时候也得引用阿
    不引用怎么可以呢?
      

  7.   

    把DevExprees的控件拖上去后,.Net会自动引用的
      

  8.   

    CmUpDate: 你后来是如何解决的? 谢谢!
      

  9.   

    !!!!!!!
    **************************************
    是你那个基类里,可能某个自定义属性返回为null,就会未将对象引用设置到对象的实例
    CCCCCCCCCCCCCCCCCcccc