I had this all fine and running last night with touch etc. but now I’m getting the following error when I try and assign anything to display.WpfWindow.Child
Using mainboard GHIElectronics-FEZSpider version 1.0
#### Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (1) ####
#### Message:
#### Microsoft.SPOT.Presentation.Media.MediaContext::RenderMessageHandler [IP: 00c5] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 004a] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001d] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 0024] ####
#### Bib_From_Space_Gadgeteer.Program::Main [IP: 0016] ####
A first chance exception of type 'System.NullReferenceException' occurred in Microsoft.SPOT.TinyCore.dll
It doesn’t break in the code but in Gadgeteer’s Run() method, the program still runs but this is printed to the console and nothing is shown on the screen.
Here is my very simple Canvas test code:
anvas c = new Canvas();
c.Width = 320;
c.Height = 240;
Rectangle r = new Rectangle(50, 50);
r.Fill = new SolidColorBrush(Colors.Cyan);
Canvas.SetLeft(r, 100);
Canvas.SetTop(r, 100);
c.Children.Add(r);
display.WPFWindow.Child = c;
display.WPFWindow.Child.Visibility = Visibility.Visible;
This was all working fine yesterday with many different canvases and touch events on rectangles and text.
Is there anything I could have done to cause this? All I added was a button to the designer and button handler. I’ve tried with the touch cable attached and with it detached and have swapped out the display for a spare one with and swapped out all of the cables.
The full Program.cs for the test Project I just created is:
public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
Canvas c = new Canvas();
c.Width = 320;
c.Height = 240;
Rectangle r = new Rectangle(100, 100);
SolidColorBrush scb = new SolidColorBrush(ColorUtility.ColorFromRGB(200, 200, 200));
r.Fill = scb;
c.Children.Add(r);
Canvas.SetTop(c.Children[0], 50);
Canvas.SetLeft(c.Children[0], 50);
display.WPFWindow.Child = c;
}
}
If you try that code it fails for me but if you comment out “r.Fill = scb;” it runs, theres nothing on the screen except a white background but it works.
Fill was working for yesterday
EDIT: Just tried stroke and getting the same problem.
I’ve tried with ImageBrush and LinearGradientBrush but the same happens with those.
I suppose I could revert to using Simple Graphics but that means losing all of the canvases/panels etc. I’ve set up so far. Also I’m assuming SimpleGraphics doesnt work with touch input right?