bug : hosting game in a form

Jan 12, 2010 at 1:41 AM

using Xen 1.6.3 I made an app that hosts a xen application in a winform, it work well.

Yesterday, I updated to XNA 3.1 and XEN 1.7. And now my app crashes with: 

 

public DrawTargetScreen(Application application, ICamera camera) : base(camera)
{
	...
	if (!application.IsInitailised)
		throw new InvalidOperationException("Application instance has not had Initalise() called yet");
	...
}

I've looked at your tutorials and if I check the "WinForm host (BETA)" radio button for any tutorial, I get the same exception. Maybe I made an error when integrating the new code drop, but I don't think so.

 


After looking some more, I believe it's a bug in xen 1.7 (or a version after 1.6.3).

in XNALogic.Initialize() you used to call parent.SetGraphicsDevice(GraphicsDevice); , but now you moved it to XNAGameAppWrapper.Initialize()

but now if a XNAWinFormsHostAppWrapper is used instead, it's never called. so I added the call in the constructor

 

internal XNAWinFormsHostAppWrapper(XNALogic logic, Application parent, WinFormsHostControl host)
{
	...

	host.BeginInvoke((EventHandler)delegate
	{
		parent.SetGraphicsDevice( GraphicsDevice );

		logic.Initialise();
		logic.LoadContent();
	});
}

It seams to be working now.

Jan 12, 2010 at 11:14 PM

I think a bug ticket already was opened back in december exposing this issue. Maybe you could create the patch file and submit it to StatusUnknown for him to merge with the current code ;)

[workitem:4837]

Coordinator
Jan 14, 2010 at 11:27 PM
Edited Jan 14, 2010 at 11:28 PM

Hi. I'm not sure how this bug has crept in,

However I did do exactly this fix myself. I've been meaning to commit it, with some other fixes, but I've been *totally* snowed under with work. I'll make sure I get my current bug fixes committed very soon.

Thanks