Bin 文件夹中的 Win32 异常

问题描述 投票:0回答:1

是否必须有一些特殊的东西才能运行在 Bin 文件夹中输出的 .exe?当尝试以管理员身份运行 .exe 时,它只会崩溃并出现未处理的 win32 异常。

c# xaml uwp-xaml
1个回答
1
投票

当我尝试运行代码时,它会拉伸组框,使 GUI 看起来很糟糕。 .XAML 中的什么可能会导致这样的情况?

您使用

Margin
属性来控制 XAML 控件的位置,这会导致您看到混乱的布局。

请参阅Layout文档以了解如何在UWP中使用XAML制作良好的布局。

例如,您可以简单地使用网格控件将这些控件放在不同的行和列上。

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition></ColumnDefinition>
        <ColumnDefinition></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"></RowDefinition>
        <RowDefinition Height="4*"></RowDefinition>
        <RowDefinition Height="4*"></RowDefinition>
        <RowDefinition Height="*"></RowDefinition>
    </Grid.RowDefinitions>
    <ComboBox HorizontalAlignment="Center" Grid.Row="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Height="42" Width="232"/>
    <ListView x:Name="DatabaseInfo" Grid.Row="1" Grid.Column="0" Header="Database Info." BorderThickness="2" BorderBrush="Black" SelectionMode="None" FontFamily="Tahoma" >
        <ListView.HeaderTemplate>
            <DataTemplate>
                <ListViewHeaderItem Content="{Binding}" Height="40" />
            </DataTemplate>
        </ListView.HeaderTemplate>

        <StackPanel Width="230" Height="30" Orientation="Horizontal" >
            <TextBlock Name="ServerNameDisplay" HorizontalAlignment="Left" Text="Server" Width="115" Height="25" />
            <TextBox Name="Server" HorizontalAlignment="Right" Text="" Height="25" Width="115" />
        </StackPanel>

        <StackPanel Width="230" Height="30" Orientation="Horizontal" >
            <TextBlock Name="DatabaseNameDisplay" HorizontalAlignment="Left" Text="Database" Width="115" Height="25" />
            <TextBox Name="Database" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
        </StackPanel>
        <StackPanel Width="230" Height="30" Orientation="Horizontal" >
            <TextBlock Name="UserNameDisplay" HorizontalAlignment="Left" Text="UserName" Width="115" Height="25" />
            <TextBox Name="UserName" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
        </StackPanel>
        <StackPanel Width="230" Height="30" Orientation="Horizontal" >
            <TextBlock Name="PasswordDisplay" HorizontalAlignment="Left" Text="Password" Width="115" Height="25" />
            <TextBox Name="Password" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
        </StackPanel>
    </ListView>
    <ListView x:Name="RabbitMQInfo" Grid.Row="1" Grid.Column="1" Header="Rabbit MQ Info." BorderThickness="2" BorderBrush="Black" SelectionMode="None" FontFamily="Tahoma" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
        <ListView.HeaderTemplate>
            <DataTemplate>
                <ListViewHeaderItem Content="{Binding}" Height="40" />
            </DataTemplate>
        </ListView.HeaderTemplate>
        <StackPanel Width="230" Height="30" Orientation="Horizontal" >
            <TextBlock Name="RabbitMQUserDisplay" HorizontalAlignment="Left" Text="UserName" Width="115" Height="25" />
            <TextBox Name="RabbitMQUser" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
        </StackPanel>
        <StackPanel Width="230" Height="30" Orientation="Horizontal" >
            <TextBlock Name="RabbitMQPassDisplay" HorizontalAlignment="Left" Text="Password" Width="115" Height="25" />
            <TextBox Name="RabbitMQPass" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
        </StackPanel>
    </ListView>
    <ListView x:Name="MachineInfo" Grid.Row="2" Grid.Column="0" Header="Name Info." BorderThickness="2" BorderBrush="Black" SelectionMode="None" FontFamily="Tahoma" >
        <ListView.HeaderTemplate>
            <DataTemplate>
                <ListViewHeaderItem Content="{Binding}" Height="40" />
            </DataTemplate>
        </ListView.HeaderTemplate>
        <StackPanel Width="230" Height="30" Orientation="Horizontal" >
            <TextBlock Name="NameDisplay" HorizontalAlignment="Left" Text="Name" Width="115" Height="25" />
            <TextBox Name="Name" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
        </StackPanel>
    </ListView>
    <ListView x:Name="IPAddressInfo" Grid.Row="2" Grid.Column="1" Header="IP Address Info." BorderThickness="2" BorderBrush="Black" SelectionMode="None" FontFamily="Tahoma" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
        <ListView.HeaderTemplate>
            <DataTemplate>
                <ListViewHeaderItem Content="{Binding}" Height="40" />
            </DataTemplate>
        </ListView.HeaderTemplate>
        <StackPanel Width="230" Height="30" Orientation="Horizontal" >
            <TextBlock Name="IPAddressDisplay" HorizontalAlignment="Left" Text="IPAddress" Width="115" Height="25" />
            <TextBox Name="IPAddress" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
        </StackPanel>
        <StackPanel Width="230" Height="30" Orientation="Horizontal">
            <TextBlock Name="PortDisplay" HorizontalAlignment="Left" Text="Port" Width="115" Height="25" />
            <TextBox Name="Port" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
        </StackPanel>
    </ListView>
    <Button x:Name="btnSave" Content="Save"  Grid.Row="3" Grid.ColumnSpan="2"  HorizontalAlignment="Center"  VerticalAlignment="Center" Width="100" Height="50"/>
</Grid>

我关于 UWP 应用程序的另一个问题是,是否必须有一些特殊的东西才能运行在 Bin 文件夹中输出的 .exe?当尝试以管理员身份运行 .exe 时,它只会崩溃并出现未处理的 win32 异常。

UWP 在沙箱中运行,它与经典的桌面应用程序不同。您不能直接双击“.exe”文件来启动它。当您在 Visual Studio 中编码时,您可以按 F5 启动它并调试它。如果它已经部署,您可以从 Windows 的“开始”菜单启动它。

温馨提示:下次请不要在一个帖子中发布多个问题。

© www.soinside.com 2019 - 2024. All rights reserved.