UWP App在Visual Studio调试模式下工作,但发布版本不会运行,缺少DLL(C#)

时间:2018-03-13 03:06:27

标签: c# visual-studio uwp visual-studio-2017 windows-10-universal

我制作了一个非常简单的应用程序,它在Visual Studio的调试器中运行得很好,但是当我尝试在没有Visual Studio的情况下运行它时,通过发布版本,应用程序将无法运行或崩溃并在那里声明&# 39;缺少DLL。

这是我的过程:

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

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

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

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

MainPage.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>

MainPage.xaml.cs中

&#13;
&#13;
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;
            }
        }
    }
}
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

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