Patrick
September 9, 2012, 5:22pm
#1
Till today I was mainly focussing on the hardware part of my project. I’m using the fez spider kit with software 4.1.8.0 and gadgeteer. On top of that I’m using glide 1.0.4 to create an GUi.
I have a simple screen with two buttons. When I press one button (doesn’t matter which) I get the following error:
Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (4)
#### Message:
#### Microsoft.SPOT.Application::OnEvent [IP: 0098] ####
#### Microsoft.SPOT.EventSink::ProcessEvent [IP: 0023] ####
#### Microsoft.SPOT.EventSink::EventDispatchCallback [IP: 0014] ####
A first chance exception of type ‘System.NullReferenceException’ occurred in Microsoft.SPOT.TinyCore.dll
An unhandled exception of type ‘System.NullReferenceException’ occurred in Microsoft.SPOT.TinyCore.dll
I can’t figure out what i’m doing wrong. Can anybody help me?
Mike
September 9, 2012, 5:32pm
#2
Reduce your program to the smallest size that recreates the problem and post the code. If you are using XML to specify the GUI post that too.
My SWAG, with the minimum info you have provided, is you have not registered for events from the buttons.
Patrick
September 9, 2012, 5:43pm
#3
Sorry for the lack of info: this is the simplified code I’m using:
MainWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.MainWindow));
GlideTouch.Initialize();
Glide.MainWindow = MainWindow;
Button btnSettings = (Button)MainWindow.GetChildByName("btnISettings");
btnSettings.TapEvent += new OnTap(btnSettings_TapEvent);
Button btnSystem = (Button)MainWindow.GetChildByName("btnSystem");
btnSystem.TapEvent += new OnTap(btnSystem_TapEvent);
DebugPrint("Program Started");
And the corresponding methods:
void btnSystem_TapEvent(object sender)
{
DebugPrint("Button System pressed");
}
void btnSettings_TapEvent(object sender)
{
DebugPrint("Button settings pressed");
}
and the xml:
<Glide Version="1.0.4">
<Window Name="Main" Width="320" Height="240" BackColor="A0A0A0">
<Image Name="imgMain" X="3" Y="3" Width="314" Height="197" Alpha="255"/>
<Button Name="btnSettings" X="214" Y="204" Width="100" Height="32" Alpha="255" Text="Settings" Font="4" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
<Button Name="btnSystem" X="3" Y="204" Width="100" Height="32" Alpha="255" Text="System" Font="4" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
</Window>
</Glide>
[Edit]
As I did some additional testing: pressing the touch screen results in the mentioned error. Not only the buttons…
Mike
September 9, 2012, 10:33pm
#4
What board are you using>
Are you using Glide with Gadgeteer?
What version of the SDK are using? If it is 4.2 have you recompiled Glide to get a 4.2 DLL?
I have to ask… Does the version of the SDK and your firmware level match?
Dear Patrick, Please try to match up resource names; To me it seems having issues while matchtching the event.
MainWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.xmlMainWindow));
and the xml
Patrick
September 10, 2012, 5:05am
#6
I’m using fez spider. SDK and firmware match 4.1.8.0. SDK is 4.1.
I’ll check the resource names. I’ll do it this evening. Thx for the quick responses!!
Patrick
September 10, 2012, 2:03pm
#7
Changing resource names as Chris suggested doesn’t change anything. The error appears when screen is touched somewhere
The same error exists:
Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (4)
#### Message:
#### Microsoft.SPOT.Application::OnEvent [IP: 0098] ####
#### Microsoft.SPOT.EventSink::ProcessEvent [IP: 0023] ####
#### Microsoft.SPOT.EventSink::EventDispatchCallback [IP: 0014] ####
A first chance exception of type ‘System.NullReferenceException’ occurred in Microsoft.SPOT.TinyCore.dll
An unhandled exception of type ‘System.NullReferenceException’ occurred in Microsoft.SPOT.TinyCore.dll
Patrick
September 10, 2012, 2:20pm
#8
Lol, I solved my own question.
The solution to this is that before using glideloader.loadwindow you have to call glidetouch.initialize() first:
So call:
GlideTouch.Initialize();
MainWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.MainWindow));
Instead of:
MainWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.MainWindow));
GlideTouch.Initialize();
@ Gus: I can’t mark my own answer as the answer. So maybe one of you guys can do it?