Hi I'm havind this problem: An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll
Additional information: Referencia a objeto no establecida como instancia de un objeto.
I know is a common error but I just don't know what to 2!!!
so If somebody could helpe that would be really great!!
this is the code:::::::
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace DirectX_Tutorial{
publicclass WinForm : System.Windows.Forms.Form{
private Device device;
private System.ComponentModel.Container components = null;
public WinForm()
{
InitializeComponent();
}
publicbool InitializeDevice()
{
try
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Reference, this, CreateFlags.SoftwareVertexProcessing, presentParams);
returntrue;
}
catch (DirectXException)
{
returnfalse;
}
}
protectedoverridevoid OnPaint(System.Windows.Forms.PaintEventArgs e)
{
device.Clear(ClearFlags.Target, Color.DarkSlateBlue , 1.0f, 0);
device.Present();
}
protectedoverridevoid Dispose (bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
privatevoid InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(500,500);
this.Text = "DirectX Tutotial";
}
staticvoid Main()
{
using (WinForm our_dx_form = new WinForm())
{
our_dx_form.InitializeDevice();
Application.Run(our_dx_form);
}
}
}
}
Additional information: Referencia a objeto no establecida como instancia de un objeto.
I know is a common error but I just don't know what to 2!!!
so If somebody could helpe that would be really great!!
this is the code:::::::
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace DirectX_Tutorial{
publicclass WinForm : System.Windows.Forms.Form{
private Device device;
private System.ComponentModel.Container components = null;
public WinForm()
{
InitializeComponent();
}
publicbool InitializeDevice()
{
try
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Reference, this, CreateFlags.SoftwareVertexProcessing, presentParams);
returntrue;
}
catch (DirectXException)
{
returnfalse;
}
}
protectedoverridevoid OnPaint(System.Windows.Forms.PaintEventArgs e)
{
device.Clear(ClearFlags.Target, Color.DarkSlateBlue , 1.0f, 0);
device.Present();
}
protectedoverridevoid Dispose (bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
privatevoid InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(500,500);
this.Text = "DirectX Tutotial";
}
staticvoid Main()
{
using (WinForm our_dx_form = new WinForm())
{
our_dx_form.InitializeDevice();
Application.Run(our_dx_form);
}
}
}
}