I use Nuclex Framework and XNA Framework in my project.
Handling user input by using Nuclex Input.
Periodically NullReferenceException:
at Nuclex.UserInterface.Controls.Control.ProcessKeyRelease(Keys keyCode)
at Nuclex.UserInterface.Screen.InjectKeyRelease(Keys keyCode)
at Nuclex.UserInterface.Input.DefaultInputCapturer.keyReleased(Keys key)
at Nuclex.Input.Devices.BufferedKeyboard.OnKeyReleased(Keys key)
at Nuclex.Input.Devices.BufferedKeyboard.Update()
at Nuclex.Input.InputManager.Update()
at Nuclex.Input.InputManager.Microsoft.Xna.Framework.IUpdateable.Update(GameTime gameTime)
at Microsoft.Xna.Framework.Game.Update(GameTime gameTime)
at SkyShoot.Game.SkyShootGame.Update(GameTime gameTime) in D:\sky-shoot\SkyShoot\SkyShoot.Game\SkyShootGame.cs:line 63
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
at Microsoft.Xna.Framework.Game.Run()
at SkyShoot.Game.Program.Main(String[] args) in D:\sky-shoot\SkyShoot\SkyShoot.Game\Program.cs:line 10
What is the problem and how to solve it?

file attachments


inlinevoid wrote Jan 2, 2012 at 5:05 AM

I'm getting this error as well. See the discussion post about what exactly is happening in my program: http://nuclexframework.codeplex.com/discussions/284702

LordIkon wrote Jan 14, 2012 at 4:36 AM

I am now seeing this crash as well. Not sure why it is happening, but I am guessing if you go into Control.Input.cs, line 450, you change this:
if(this.activatedControl != this) {

to this, to prevent the crash (which stems from attempting to access a null activatedControl on line 451):
if( null != this.activatedControl && this.activatedControl != this) {

wrote Jan 14, 2012 at 5:15 AM

LordIkon wrote Jan 14, 2012 at 5:15 AM

I have fixed this problem using the recommendation in my last comment. I've attached a .zip file with the two .dll files you will need to fix this.

NOTE: I have made customizations to WindowDialog, Control, ButtonControl, and DraggableControl, specifically for the QuickStart Game Engine. If I upload my .dlls, it will include those customizations. If you don't want these then you'll just need to compile your own .dlls using my instructions from my last comment.

Cygon wrote Jan 14, 2012 at 10:34 PM

Have you tried this with the nightlz builds from my CI server (https://devel.nuclex.org/jenkins/job/Nuclex%20Foundation%20%28~Release%29/)?

If this is indeed the problem I that I've already fixed, just adding a null check could have side effects - namely not sending the key/mouse release messages to the activated control because this.activeControl shouldn't be null in the first place.

Unless this bug also occurs with the nightly builds, in which case I'll have to investigate again =)

LordIkon wrote Jan 14, 2012 at 10:42 PM

I never tried the nightly builds because, ironically, I wanted something very stable since the GUI is being released with the game engine. Is there any word when the next milestone release will be happening?

Shiho wrote Feb 20, 2012 at 7:29 PM

Have you tried this with the nightlz builds from my CI server (https://devel.nuclex.org/jenkins/job/Nuclex%20Foundation%20%28~Release%29/)?
I not found the new UserInterface.dll.
How to compile the nightly builds? Solution Framework.Build from this https://devel.nuclex.org/framework/browser is out of date.
Can you say the correct order of assembly, or to provide updated UserInterface.dll?

wrote Feb 21, 2013 at 11:26 PM