Form not displaying

SleepingTroll

Newcomer
Joined
Feb 14, 2012
Messages
12
(sorry about the repost, just realized the original was in the wrong place)
I create a form and it displays fine, however as soon as I create my directX device the form stops displaying!

Here is my code, please note that I can eliminate all of the DirectX code and the form displays, however just the line 'private Device device = null;' will prevent my form from displaying.


Code:
using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace Model
{
	public partial class MainForm : Form
	{
		private Device device = null;
		public MainForm()
		{
			InitializeComponent();
			InitializeDevice();
		}
		
		private void InitializeDevice()
		{
			PresentParameters pp = new PresentParameters();
			pp.Windowed = true;
			pp.SwapEffect = SwapEffect.Discard;
			
			device = new Device(0, DeviceType.Reference, this, CreateFlags.SoftwareVertexProcessing, pp);
		}
		
		protected override void OnPaint(PaintEventArgs e)
		{
			device.Clear(ClearFlags.Target, Color.CornflowerBlue, 0, 1);
			device.Present();
		}

	}
}
I am new at directX and will likely stay that way if I can't get by this!
 
Is there a reason why you are creating a reference device? I can't how this could cause a problem, but it seems unusual.

The problem might be related to the fact that you are creating the device before your form creates its handle. Try calling the InitializeDevice method from the OnLoad event method rather than the constructor.
 
I do have more info, although it is not encouraging... It would seem that the compiler is having a problem with the DirectX framework, when it references it, it goes into limbo! I am redownloading the framework, somehow though... I don't expect that this is a solution, any ideas greatly appreciated!

AHA! When searching for the DirectX download I was directed(no pun intended) to DirectX 11! Downloading Version 9 now... I can't imagine all the trouble this is going to cause for nubes like myself...
 
Last edited:
I found my solution! app.cfg needs to read like this...
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
 
Back
Top