1

I'm doing a WindowsPhone/Universall App based on a HupPage Template.

I'm pretty far developing this app and have implemented lately some app wide changes. So I don't know anymore what I've did to cause this error. It's my first WP project and kind of chaotic :-)

First I thought it was implementing a UserControl which really is a major part of the app. I gain some help in this post.

Now, I've noticed that every button I push, the Click_EventHandler function doesn't receive the sender object correctly. First I thought it was this UserControl implementation but then I've added a BasicPage1 (just a single Button in xaml) to the HupTemplate project and referenced it in the APP.xaml file.

Here is the code and screenshot:

app.xaml.cs

 if (!rootFrame.Navigate(typeof(BasicPage1), e.Arguments))
            {
                throw new Exception("Failed to create initial page");
            }

Basicpage1

 <Grid Grid.Row="1" x:Name="ContentRoot" Margin="19,9.5,19,0">
            <Button x:Name="button" Content="Button" HorizontalAlignment="Left"  
                Grid.Row="1" VerticalAlignment="Top" Click="button_Click"/>
        </Grid>

And the BasicPage1 error:

enter image description here

What could possibly cause this error?

Idea #1: While implementing the UserControl I've added the behavioural SDK to the project.

Idea #2: Is it the change from HubPage --> BasicPage1 in the app.xaml.cs? I've added the BasicPage1 to both projects (WP & Store).

Cheers,

Chris

Community
  • 1
  • 1
Ulpin
  • 179
  • 1
  • 14
  • 1
    Not an answer to the question. Just a tip. Use SVN or GIT even if you are working alone. You can then go back to older versions very easily and find out what caused the problem. – Divisadero Apr 07 '16 at 10:44
  • 1
    The debugger is not supposed to display "internal error". The VS2015 debugger is quite buggy, use connect.microsoft.com to report an issue like this. And keep going. – Hans Passant Apr 07 '16 at 10:51
  • Yes. I will. Still a bloddy beginner :-) – Ulpin Apr 07 '16 at 10:51
  • @HansPassant Ok. I can report this issue. But I wont get a quick response from them, or do I? What could I do in the meantime? – Ulpin Apr 07 '16 at 10:56

1 Answers1

0

I would say that the problem is that sender is of another type. Debug to know, who is the sender.

Divisadero
  • 895
  • 5
  • 18
  • I did. You'll see in the screenshota above. Even when the debugger just setps into the function the sender object reference is already missing. – Ulpin Apr 07 '16 at 10:50
  • set break on the first line, pls and look what value the sender has – Divisadero Apr 07 '16 at 10:51
  • 1
    as it was mentioned already, that internal error is not ok :D It was caused by exception when casting to button I guess – Divisadero Apr 07 '16 at 10:54
  • 1
    try ImmediateWindow, it is really weird :D – Divisadero Apr 07 '16 at 10:55
  • 1
    I think its debugger internal issue. Do you get any exception while casting into button? If not you can go ahead with that. – Archana Apr 07 '16 at 10:55
  • @Archana Thats the problem. I cant access any sender object in the entire app. Something like `(Button)sender.Name` will always throw a null pointer exception – Ulpin Apr 07 '16 at 10:59
  • @Divisadero what you mean with ImmediateWindow? – Ulpin Apr 07 '16 at 11:00
  • where exactly have you put the event handler? inside usercontrol.cs? – Archana Apr 07 '16 at 11:04
  • 1
    ImmiediateWindow is very useful thing... Debug>Windows>Immediate Window - there you can do some 'immediate' stuff. For example '?a' will return the value of the 'a' variable :D 'a = 10' will change the a value to 10 – Divisadero Apr 07 '16 at 11:07
  • @Archana I have to correct myself. I can access the i.e. the `Button.Name` this just worked on my BasicPage1. Let me check the Buttons inside the UserControl. – Ulpin Apr 07 '16 at 11:09
  • @Archana I have no idea. It works now. Still debugger showing the error. But last night there were definitetly nothing in that sender objects. I've always got an NullPointer when acccessing. Now, I can click all the buttons inside the UserControl etc. Probably solved it while changing a lot of stuff around the entire app and then got mislead by the debugger issue... Thanks for the help, Even the question was nonsense, I've leaned something out of it, so dont vote me down :-) – Ulpin Apr 07 '16 at 11:20