代码之家  ›  专栏  ›  技术社区  ›  zanzindorf

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

  •  3
  • zanzindorf  · 技术社区  · 6 年前

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

    以下是我的流程:

    • 清洁溶液
    • 构建解决方案
    • 部署解决方案
    • 选中“ProjectFolder/bin/x86/Release”
    • 尝试启动“ProjectName.exe”,等待轮会旋转一点,但什么也没发生
    • 检查“ProjectFolder/bin/x86/Release”中的“AppX”子文件夹
    • 尝试在“AppX”子文件夹中启动“ProjectName.exe”,但出现以下错误:“由于SharedLibrary.dll未 建立重新安装程序可能会解决此问题。“然后是另一个 错误显示:“代码执行无法继续,因为 mrt100\U应用程序。未找到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;
                }
            }
        }
    }
    1 回复  |  直到 5 年前
        1
  •  6
  •   Stefan Wick MSFT    6 年前

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