1

I'm developing an application in UWP c#. I have tried to publish and create my application package for sideloading and I did it.

The Problem has appeared since I used tag in XAML for setting controls' styles and also create DataTemplate... In this case, the program runs properly in the debugger but when I create the package for sideloading, unfortunately in destination machine (I tried on several machines) the program is terminated in every page which contains

Is there any hidden configuration that I'm not aware of?
I have attached two code sample which led to termination

I'm completely confused and exhausted from googling in last 2 days!

 <Page.Resources>

    <MenuFlyout x:Name="FacilityGroupMenu">
        <MenuFlyoutItem Text="Add Facility" Click="AddFacilityInGp_Click"/>
        <MenuFlyoutItem Text="Delete" Click="DeleteFacilityGp_Click"/>
    </MenuFlyout>

    <MenuFlyout x:Name="FacilityMenu">
        <MenuFlyoutItem Text="Start Monitoring"  Foreground="Green" Background="Red" Click="SetFacilityFiles_Click"/>
        <MenuFlyoutItem Text="Set Files"  Click="SetFacilityFiles_Click"/>
        <MenuFlyoutItem Text="Delete"  Click="DeleteFacility_Click"/>
    </MenuFlyout>

    <DataTemplate x:Key="FolderTemplate" x:DataType="local:FacilityItem">
        <TreeViewItem ItemsSource="{x:Bind Items}" Holding="cardstack_Holding" PointerPressed="cardstack_PointerPressed">
            <StackPanel Orientation="Horizontal">
                <Image  Width="20" Source="Icon/building.png"/>
                <TextBlock Margin="10 10" Text="{x:Bind Name}" />
            </StackPanel>
        </TreeViewItem>

    </DataTemplate>

    <DataTemplate x:Key="FileTemplate" x:DataType="local:FacilityItem">
        <TreeViewItem  Holding="cardstack_HoldingFacility" PointerPressed="cardstack_PointerPressedFacility">
            <StackPanel Orientation="Horizontal">
                <Image Width="20" Source="Icon/document.png"/>
                <TextBlock Margin="10 10" Foreground="White"  Text="{Binding Name}"/>
            </StackPanel>
        </TreeViewItem>
    </DataTemplate>

    <local:ItemTemplateSelector
        x:Key="ItemTemplateSelector"
        FolderTemplate="{StaticResource FolderTemplate}"
        FileTemplate="{StaticResource FileTemplate}" />


</Page.Resources>

<Page
x:Class="bimPort.BlankPage1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:bimPort"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
    <Style x:Key="ButtonStyle1" TargetType="Button">
        <Setter Property="Background" Value="{ThemeResource ButtonBackground}"/>
        <Setter Property="BackgroundSizing" Value="OuterBorderEdge"/>
        <Setter Property="Foreground" Value="{ThemeResource ButtonForeground}"/>
        <Setter Property="BorderBrush" Value="{ThemeResource ButtonBorderBrush}"/>
        <Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}"/>
        <Setter Property="Padding" Value="{StaticResource ButtonPadding}"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/>
        <Setter Property="FontWeight" Value="Normal"/>
        <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/>
        <Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}"/>
        <Setter Property="FocusVisualMargin" Value="-3"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <ContentPresenter x:Name="ContentPresenter" AutomationProperties.AccessibilityView="Raw" BackgroundSizing="{TemplateBinding BackgroundSizing}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" CornerRadius="{TemplateBinding CornerRadius}" ContentTransitions="{TemplateBinding ContentTransitions}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBackgroundPointerOver}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBorderBrushPointerOver}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundPointerOver}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBackgroundPressed}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBorderBrushPressed}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundPressed}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <PointerDownThemeAnimation Storyboard.TargetName="ContentPresenter"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBackgroundDisabled}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBorderBrushDisabled}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundDisabled}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </ContentPresenter>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Page.Resources>

<Grid>
    <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
        <Button Style="{StaticResource ButtonStyle1}" x:Name="button" Content="Button" HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Height="108" Width="199"/>

    </StackPanel>
</Grid>

farshad.b
  • 11
  • 1
  • Are you sure it's related to side-loading and not a "debug vs release" thing? What happens if you run it as "Release" from VS? – Stefan Wick MSFT Dec 20 '18 at 00:19
  • 1
    Also by "terminated" I assume you mean crashed? Can you include info about the crash? Note that you can run side-loaded apps under the debugger in VS by going to Debug->Other Debug Targets->Debug Installed App Package. – Stefan Wick MSFT Dec 20 '18 at 00:21
  • @StefanWickMSFT Yes, I meant Crashed! All things are perfect in the local machine. I have run it from VS in Release mode as well as Debug mode I also have created the package for sideloading in Release mode as well as Debug but in any other devices that I wanna install my app the problem will appear in any page that includes . I don't have any information about its crash because it occurs in a machine without VS and I can't debug it !! I'm pretty sure that the problem relates to – farshad.b Dec 20 '18 at 07:37
  • @StefanWickMSFT Suppose that I have installed my sideloaded application which includes 2 pages, in startup page, I don't have the app runs perfectly but when I navigate to another page with the app will crash. I ran the sideloaded app under the debugger in local machine and everything went well. – farshad.b Dec 20 '18 at 07:38
  • I suggest you to do a global exception handling and Use App.UnhandledException to show a MessageDialog on unhandled exceptions and do not forget to use e.Handled = true in the event invoke. After that deploy your app to a machine and lets see what error message and stack trace you will get. That maybe help you in finding the main issue – Ali NGame Dec 20 '18 at 09:12
  • Or use AppCenter to collect crash data on your app: https://appcenter.ms/ Without some info about the crash we can only speculate. – Stefan Wick MSFT Dec 20 '18 at 16:01
  • One more clarifying question:on the test machine where the crash occurs, are you running a different version of Windows 10 than on your development machine with VS installed? What version of Windows 10 are you targetting? (check in project properties) – Stefan Wick MSFT Dec 20 '18 at 16:01

0 Answers0