繁体   English   中英

UWP 应用程序在 Visual Studio 调试模式下工作,但发布版本无法运行,缺少 DLL (C#)

[英]UWP App works in Visual Studio debug mode, but the release build won't run, missing DLL (C#)

我制作了一个非常简单的应用程序,它可以在 Visual Studio 的调试器中完美运行,但是当我尝试在没有 Visual Studio 的情况下运行它时,通过发布版本,该应用程序要么无法运行,要么崩溃并声称缺少 DLL。

这是我的过程:

  • 清洁解决方案
  • 构建解决方案
  • 部署解决方案
  • 选中“ProjectFolder/bin/x86/Release”
  • 尝试启动“ProjectName.exe”,等待轮旋转一点,但没有任何反应
  • 检查“ProjectFolder/bin/x86/Release”中的“AppX”子文件夹
  • 尝试在“AppX”子文件夹中启动“ProjectName.exe”,但收到错误消息:“代码执行无法继续,因为找不到 SharedLibrary.dll。重新安装程序可能会解决此问题。” 然后是另一个错误:“代码执行无法继续,因为没有找到 mrt100_app.dll。重新安装程序可能会解决这个问题。”

我真的不知道我错过了什么。 下面,我将包括我的代码。 我真的没有做任何复杂的事情。 这实际上是我的第二个应用程序,第一个是教程中的“Hello World”应用程序。

如果您有任何线索我做错了什么,请告诉我。 谢谢!

  • 运行 Windows 10
  • 使用 Microsoft Blend for Visual Studio Community 2017
  • 需要更多信息? 问,我给你拿。

主页.xaml

<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Rando_Team"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Numerics="using:System.Numerics"
x:Class="Rando_Team.MainPage"
mc:Ignorable="d" Height="360" VerticalAlignment="Top">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Height="356" VerticalAlignment="Top">
    <Rectangle Margin="10,121,10,0" Stroke="#FFFDFEFF" Fill="#FFFDFEFF" Height="32" VerticalAlignment="Top"/>

    <Rectangle Margin="10,0,10,129" Stroke="#FFFDFEFF" Fill="#FFFDFEFF" Height="32" VerticalAlignment="Bottom"/>

    <Rectangle Margin="10,0,10,55" Stroke="#FFFDFEFF" Fill="#FFFDFEFF" Height="32" VerticalAlignment="Bottom"/>

    <Rectangle Margin="10,0,10,18" Stroke="#FFF3FBFF" Fill="#FFF3FBFF" Height="32" VerticalAlignment="Bottom"/>

    <Rectangle Margin="10,0,10,92" Stroke="#FFF3FBFF" Fill="#FFF3FBFF" Height="32" VerticalAlignment="Bottom"/>

    <Rectangle Margin="10,158,10,166" Stroke="#FFF3FBFF" Fill="#FFF3FBFF" d:LayoutOverrides="TopPosition, BottomPosition"/>

    <Rectangle Height="32" Margin="10,84,10,0" Stroke="#FF6FC6F0" VerticalAlignment="Top" Fill="#FF6FC6F0"/>

    <Button x:Name="button" Content="Generate" HorizontalAlignment="Stretch" Margin="10,47,10,0" VerticalAlignment="Top" Click="button_Click" Height="32"/>
    <TextBlock x:Name="textBlock" Height="32" Margin="10,10,0,0" TextWrapping="Wrap" Text="Number of boxes:" VerticalAlignment="Top" HorizontalAlignment="Left" Width="125"/>
    <TextBox x:Name="tfBoxes" Height="32" Margin="140,10,10,0" TextWrapping="Wrap" Text="10" VerticalAlignment="Top" InputScope="Number" TextChanged="textBox_TextChanged"/>
    <TextBlock x:Name="textBlock1" HorizontalAlignment="Left" Height="32" Margin="40,84,0,0" TextWrapping="Wrap" Text="Box" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="textBlock1_Copy" HorizontalAlignment="Right" Height="32" Margin="0,84,10,0" TextWrapping="Wrap" Text="Column" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="textBlock1_Copy1" Height="32" Margin="145,84,115,0" TextWrapping="Wrap" Text="Row" VerticalAlignment="Top" TextAlignment="Center" d:LayoutOverrides="LeftPosition, RightPosition"/>
    <TextBlock x:Name="tbBox1" HorizontalAlignment="Left" Height="32" Margin="40,121,0,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="tbCol1" HorizontalAlignment="Right" Height="32" Margin="0,121,10,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="tbRow1" Height="32" Margin="145,121,115,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" TextAlignment="Center" d:LayoutOverrides="LeftPosition, RightPosition"/>
    <TextBlock x:Name="textBlock1_Copy6" HorizontalAlignment="Left" Height="32" Margin="10,121,0,0" TextWrapping="Wrap" Text="1" VerticalAlignment="Top" Width="25" TextAlignment="Center"/>
    <TextBlock x:Name="tbBox2" HorizontalAlignment="Left" Height="32" Margin="40,158,0,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="tbCol2" HorizontalAlignment="Right" Height="32" Margin="0,158,10,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="tbRow2" Height="32" Margin="145,158,115,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" TextAlignment="Center" d:LayoutOverrides="LeftPosition, RightPosition"/>
    <TextBlock x:Name="textBlock1_Copy10" HorizontalAlignment="Left" Height="32" Margin="10,158,0,0" TextWrapping="Wrap" Text="2" VerticalAlignment="Top" Width="25" TextAlignment="Center"/>
    <TextBlock x:Name="tbBox3" HorizontalAlignment="Left" Height="32" Margin="40,195,0,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="tbCol3" HorizontalAlignment="Right" Height="32" Margin="0,195,10,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="tbRow3" Height="32" Margin="145,195,115,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" TextAlignment="Center" d:LayoutOverrides="LeftPosition, RightPosition"/>
    <TextBlock x:Name="textBlock1_Copy14" HorizontalAlignment="Left" Height="32" Margin="10,195,0,0" TextWrapping="Wrap" Text="3" VerticalAlignment="Top" Width="25" TextAlignment="Center"/>
    <TextBlock x:Name="tbBox4" HorizontalAlignment="Left" Height="32" Margin="40,232,0,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="tbCol4" HorizontalAlignment="Right" Height="32" Margin="0,232,10,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="tbRow4" Height="32" Margin="145,232,115,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" TextAlignment="Center" d:LayoutOverrides="LeftPosition, RightPosition"/>
    <TextBlock x:Name="textBlock1_Copy18" HorizontalAlignment="Left" Height="32" Margin="10,232,0,0" TextWrapping="Wrap" Text="4" VerticalAlignment="Top" Width="25" TextAlignment="Center"/>
    <TextBlock x:Name="tbBox5" HorizontalAlignment="Left" Height="32" Margin="40,269,0,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="tbCol5" HorizontalAlignment="Right" Height="32" Margin="0,269,10,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="tbRow5" Height="32" Margin="145,269,115,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" TextAlignment="Center" d:LayoutOverrides="LeftPosition, RightPosition"/>
    <TextBlock x:Name="textBlock1_Copy22" HorizontalAlignment="Left" Height="32" Margin="10,269,0,0" TextWrapping="Wrap" Text="5" VerticalAlignment="Top" Width="25" TextAlignment="Center"/>
    <TextBlock x:Name="tbBox6" HorizontalAlignment="Left" Height="32" Margin="40,306,0,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="tbCol6" HorizontalAlignment="Right" Height="32" Margin="0,306,10,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="100" TextAlignment="Center"/>
    <TextBlock x:Name="tbRow6" Height="32" Margin="145,306,115,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" TextAlignment="Center" d:LayoutOverrides="LeftPosition, RightPosition"/>
    <TextBlock x:Name="textBlock1_Copy30" HorizontalAlignment="Left" Height="32" Margin="10,306,0,0" TextWrapping="Wrap" Text="6" VerticalAlignment="Top" Width="25" TextAlignment="Center"/>
    <TextBlock x:Name="textBlock2" HorizontalAlignment="Left" Height="32" Margin="10,84,0,0" TextWrapping="Wrap" Text="#" VerticalAlignment="Top" Width="25" TextAlignment="Center"/>

</Grid>

主页.xaml.cs

 using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 namespace Rando_Team { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class MainPage : Page { int[] boxList = { 0, 0, 0, 0, 0, 0}; int[] rowList = { 0, 0, 0, 0, 0, 0 }; int[] columnList = { 0, 0, 0, 0, 0, 0 }; int numberOfBoxes; Random r; int n; public MainPage() { this.InitializeComponent(); numberOfBoxes = 10; r = new Random(DateTime.Now.Second); } private void button_Click(object sender, RoutedEventArgs e) { for (int i = 0; i < 6; i++) { boxList[i] = r.Next(1, numberOfBoxes + 1); } for (int i = 0; i < 6; i++) { rowList[i] = r.Next(1, 6); } for (int i = 0; i < 6; i++) { columnList[i] = r.Next(1, 7); } updateTextBoxes(); } private void updateTextBoxes() { tbBox1.Text = boxList[0].ToString(); tbBox2.Text = boxList[1].ToString(); tbBox3.Text = boxList[2].ToString(); tbBox4.Text = boxList[3].ToString(); tbBox5.Text = boxList[4].ToString(); tbBox6.Text = boxList[5].ToString(); tbRow1.Text = rowList[0].ToString(); tbRow2.Text = rowList[1].ToString(); tbRow3.Text = rowList[2].ToString(); tbRow4.Text = rowList[3].ToString(); tbRow5.Text = rowList[4].ToString(); tbRow6.Text = rowList[5].ToString(); tbCol1.Text = columnList[0].ToString(); tbCol2.Text = columnList[1].ToString(); tbCol3.Text = columnList[2].ToString(); tbCol4.Text = columnList[3].ToString(); tbCol5.Text = columnList[4].ToString(); tbCol6.Text = columnList[5].ToString(); } private void textBox_TextChanged(object sender, TextChangedEventArgs e) { if (int.TryParse(tfBoxes.Text, out n)) { numberOfBoxes = n; } else { tfBoxes.Text = ""; numberOfBoxes = 1; } } } }

您不能直接启动 UWP EXE。 您需要部署应用程序包,然后从应用程序列表/开始菜单启动它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM