R
Rob
Hi everyone
This is my situation. I have a main Form where i call a Form with a
VisioDrawingControl object (I call it the visioForm) included. When I
call the visioForm for the first time it doesn't give a problem. When
i close the visioForm and then try to create a new one. I get the
following error : "object reference not set to an instanve of an
object".
When i don't create a Application object it works but when i include
it it doens't work anymore. This is very strange because the first
time i call the visioform everything works fine. Could somebody give
me a solution for my problem.
Here is my c# code.
For the calling of my visioForm
-------------------------------
private void button1_Click(object sender, System.EventArgs e) {
VisioApplication test = new VisioApplication();
test.Show();
}
The VisioForm
-------------
public class VisioApplication : System.Windows.Forms.Form {
private AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl
axDrawingControl1;
private Microsoft.Office.Interop.Visio.Application app;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public VisioApplication()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//I think the major problem is in here but i don't know where.
app = this.axDrawingControl1.Window.Application;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
This is my situation. I have a main Form where i call a Form with a
VisioDrawingControl object (I call it the visioForm) included. When I
call the visioForm for the first time it doesn't give a problem. When
i close the visioForm and then try to create a new one. I get the
following error : "object reference not set to an instanve of an
object".
When i don't create a Application object it works but when i include
it it doens't work anymore. This is very strange because the first
time i call the visioform everything works fine. Could somebody give
me a solution for my problem.
Here is my c# code.
For the calling of my visioForm
-------------------------------
private void button1_Click(object sender, System.EventArgs e) {
VisioApplication test = new VisioApplication();
test.Show();
}
The VisioForm
-------------
public class VisioApplication : System.Windows.Forms.Form {
private AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl
axDrawingControl1;
private Microsoft.Office.Interop.Visio.Application app;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public VisioApplication()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//I think the major problem is in here but i don't know where.
app = this.axDrawingControl1.Window.Application;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}