locked
Silverlight Embedded - "Access violation reading location 0x00000000" when calling GoToVisualState RRS feed

  • Question

  • Hello guys,

    I don't know if I'm posting in the correct forum, but I have an issue with an "Access violation reading location 0x00000000", when I am calling GoToVisualState(L"RunningProgramView", true) for a custom control.

    I am using Silverlight for Windows embedded.

    The scenario is like this: I am changing the state of an control, at a button press. This control has two states. The first time I press the button , I am transitioning from the initial state, I am calling GoToVisualState(L"RunningProgramView", true) and I am going to the "running mode" state. After I stop it, I am returning to the initial state. If I press again the button and calling GoToVisualState(L"RunningProgramView", true), I receive an error that:
    "First-chance exception at 0x42839090 in Application.exe: 0xC0000005: Access violation reading location 0x00000000."

    It is weird why first time is working, but second time is not. Do you have any hint, what can I follow? Why the method is trying to read a NULL pointer?

    Thanks :)

    Thursday, July 20, 2017 2:32 PM

All replies

  • Hi symonna_v,

    According to the error message, it means you are calling a null point or a variable initialised to NULL or set to NULL.

    Please check the control and all its related property and other parameter that used by GoToVisualState method after you stop your control from "running mode" to "initial state". You need to make sure all properties, parameters are not null.

    I suggest you use Watch window in Visual Studio to watch the properties and parameters.

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 21, 2017 2:14 AM
    Moderator
  • Hi, 

    I checked the parameters, properties and I don't see any anomalies. I set the second parameter of the method to false, to not use visual transitions, and it is working. So there is something in the transitions. But why the second time, and only for this state? 

    Is there a possibility to debug into the GoToVisualState method?

    Thanks, 

    Simona

    Friday, July 21, 2017 7:04 AM
  • Hi symonna_v,

    The second parameter of GoToVisualState method is false, means whether to use visual transitions that are defined in the control to transition between states. If it is false, the visual transitions will not be used.

    So please check how do you change your control to initial state. Make sure you are not change the object of GoToVisualState to initial state. If possible, please share some code snippet to help us reproduce this issue.

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 24, 2017 1:29 AM
    Moderator
  • Here is some code from the xaml regarding VisualStateManager and transitions, hope it helps:

     <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="WorkingState">
                    <VisualStateGroup.Transitions>
                        <VisualTransition GeneratedDuration="0" To="SelectProgramToRunView">
                            <Storyboard>
                                <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)"
                                                              Storyboard.TargetName="ctrlProgrammSelection">
                                    <EasingPointKeyFrame KeyTime="0" Value="0.5,0.5" />
                                    <EasingPointKeyFrame KeyTime="0:0:0.8" Value="0.5,0.5" />
                                </PointAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames
                                    Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)"
                                    Storyboard.TargetName="ctrlProgrammSelection">
                                    <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames
                                    Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.LocalOffsetX)"
                                    Storyboard.TargetName="ctrlProgrammSelection">
                                    <EasingDoubleKeyFrame KeyTime="0" Value="-800" />
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0" />
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualTransition>
                        <VisualTransition GeneratedDuration="0" To="RunningProgramView">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                               Storyboard.TargetName="ctrlProgrammSelection">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Collapsed</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                               Storyboard.TargetName="ctrlPressureSelection">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Visible</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)"
                                                              Storyboard.TargetName="ctrlPressureSelection">
                                    <EasingPointKeyFrame KeyTime="0" Value="0.5,0.5" />
                                    <EasingPointKeyFrame KeyTime="0:0:0.8" Value="0.5,0.5" />
                                </PointAnimationUsingKeyFrames>

                                <DoubleAnimationUsingKeyFrames
                                    Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)"
                                    Storyboard.TargetName="ctrlPressureSelection">
                                    <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0" />
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames
                                    Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.LocalOffsetX)"
                                    Storyboard.TargetName="ctrlPressureSelection">
                                    <EasingDoubleKeyFrame KeyTime="0" Value="-800" />
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0" />
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualTransition>
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="SelectProgramToRunView" />
                    <VisualState x:Name="RunningProgramView">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000"
                                                           Storyboard.TargetName="ctrlProgrammSelection"
                                                           Storyboard.TargetProperty="(UIElement.Visibility)">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000"
                                                           Storyboard.TargetName="ctrlPressureSelection"
                                                           Storyboard.TargetProperty="(UIElement.Visibility)">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>

    and in the code I am calling the one or the other state, depending on the "running state":

    if (Settings::GetIsProgrammRunning())
    {
             GoToVisualState(L"RunningProgramView", false);
    }
    else
    {
             GoToVisualState(L"SelectProgramToRunView", true);
    }

    Thx

    Tuesday, July 25, 2017 7:06 AM
  • Hi symonna_v,

    According to the code you provided, you are developing with XAML for Windows Embedded, not a Silverlight application, is it right?

    As far as I know, if we want to debug the encapsulated code, we need the debug file (in C++, the debug file is .cpp and .h file). So if we don't have the .cpp and .h file for GoToVisualState() method, we could not debug it directly.

    But we could debug with some third part tools, such as XAML Spy which could interact with the UI visual tree, extract data, explore the filesystem, create stunning artwork, and more.

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, July 26, 2017 2:59 AM
    Moderator