繁体   English   中英

在 StartUp 上部署 ClickOnce 后出现异常

[英]Exception after ClickOnce deployment on StartUp

几个小时后,谷歌搜索并尝试将 go 返回到以前的代码我无法解决这个奇怪的异常。 所以我愿意接受任何建议。

我对我现有的 ClickOnce-Deployment 项目进行了更新,在 Debug 中一切正常。 完成更新后,我想在我自己的网络中测试该应用程序,因为它是一个多用户应用程序。 事实证明,我一定是在途中破坏了一些东西,因为我没有备份旧代码,所以我无法回滚。

我在 App.xaml.cs 中添加了一个异常捕获代码来写入日志,所以如果用户遇到异常我可以检查日志并采取相应措施。 这是以下日志的来源:

Zeilennummer "8" 和 Zeilenposition "9" von "Durch den Aufruf des Konstruktors für Typ "MietPlaner2020.MainWindow", der den angegebenen Bindungseinschränkungen entspricht, wurde eine Ausnahme ausgelöst.。 bei System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri) bei System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri) bei System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri) bei System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream) bei System .Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc) bei System.Windows.Application.DoStartup() bei System.Windows.Application.<.ctor>b__1_0(Object unused) beinal System.88749414387988.Application.DoStartup() bei System.Windows.Application.DoStartup()代表回拨,882936123098 88 args, Int32 numArgs) bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

在我的谷歌搜索中,我发现了这个英文翻译:

在与指定绑定约束匹配的类型“TestWPF.MainWindow”上调用构造函数引发异常。

MainWindow-Constructor 的代码看起来像这样

public MainWindow()
    {
        InitializeComponent();
        DataContext = this;

        CheckInstallation();

        //Min Window Size
        MinHeight = 720;
        MinWidth = 1280;

        CurrentlyShownDates = new List<DateTime>();
        CurrentDate = DateTime.Today;
        DayPickedDirectly = false;

        AddScrollBarColumn();

        LoadData();
    }

Row-Number“8”和Row-Position“9”无论如何我都认为这些行不合逻辑。 它从来都不是 =-符号,只是代码中的一个随机字母,所以老实说我不知道该怎么做。

因为它只发生在安装应用程序时,我无法通过调试器的代码 go,因为我无法在部署前重现异常。

在此先感谢,希望我能解决这个问题。

正如 Stephan 所问,这是 MainWindow.xaml:

<Window x:Class="MietPlaner2020.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:MietPlaner2020"
    xmlns:modals="clr-namespace:MietPlaner2020.Modals"
    xmlns:controls="clr-namespace:MietPlaner2020.Controls"
    mc:Ignorable="d" d:DesignWidth="1200"
    Title="Miet Planer" Loaded="LoadEntries" WindowStartupLocation="CenterScreen">
<DockPanel>
    <!-- TODO: Add as soon as local station logic is needed -->
    <!--<StatusBar DockPanel.Dock="Bottom" x:Name="MainStatusBar">
        <StatusBar.ItemsPanel>
            <ItemsPanelTemplate>
                <Grid x:Name="StatusBarGrid">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="230" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="230" />
                    </Grid.ColumnDefinitions>
                </Grid>
            </ItemsPanelTemplate>
        </StatusBar.ItemsPanel>
        <StatusBarItem HorizontalContentAlignment="Left">
            <TextBlock Text="Stations HERE" />
        </StatusBarItem>
        <Separator Grid.Column="1" />
        <StatusBarItem Grid.Column="2" HorizontalContentAlignment="Center">
            <TextBlock x:Name="StationInformation" Text="Station Name + ID HERE" />
        </StatusBarItem>
        <Separator Grid.Column="3" />
        <StatusBarItem x:Name="DataUpdateStatusItem" Grid.Column="4" HorizontalContentAlignment="Right">
            <TextBlock x:Name="DataUpdateStatusText" Text="Daten aktuell" />
        </StatusBarItem>
    </StatusBar>-->
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid>
            <DockPanel x:Name="CalendarPanel">
                <Grid x:Name="ButtonGrid" DockPanel.Dock="Top">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Grid HorizontalAlignment="Center" MinWidth="125" Grid.IsSharedSizeScope="True">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="Button"/>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="Button"/>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="Button"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Button x:Name="AddEntryButton" Grid.Column="1" MinWidth="125" Margin="10,0" Tag="Entry_Add" Content="_Termin hinzufügen" Style="{DynamicResource DefaultButton}" Click="OpenPopup"/>
                        <Button x:Name="AvailabilityCheckButton" Grid.Column="2" Margin="10,0" Tag="AvailabilityCheck" Content="_Verfügbarkeit" Style="{DynamicResource DefaultButton}" Click="OpenPopup"/>
                        <Button x:Name="ContractButton" Grid.Column="3" Margin="10,0" Tag="Contract" Content="Vertrag erstellen" Style="{DynamicResource DefaultButton}" Click="OpenPopup"/>
                    </Grid>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Column="1">
                        <Button x:Name="DecreaseWeekButton" MinWidth="20" Content="-" HorizontalAlignment="Left" Click="DecreaseWeek" Style="{DynamicResource PreviousButtonStyle}" Height="{Binding ElementName=PickWeek, Path=ActualHeight}" Width="{Binding ElementName=DecreaseWeekButton, Path=ActualHeight}"/>
                        <Button x:Name="PickWeek" Tag="WeekPicker" MinWidth="400" MinHeight="47" MaxHeight="47" HorizontalAlignment="Center" Click="OpenPopup" Style="{DynamicResource DefaultButton}">
                            <Grid>
                                <AccessText Text="_Kalender" Opacity="0"/>
                                <StackPanel>
                                    <TextBlock x:Name="PickWeek_Month" Text="MONTH" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20"/>
                                    <TextBlock x:Name="PickWeek_Week" Text="WEEK" HorizontalAlignment="Center" VerticalAlignment="Bottom"/>
                                </StackPanel>
                            </Grid>
                        </Button>
                        <Button x:Name="IncreaseWeekButton" MinWidth="20" Content="+" HorizontalAlignment="Right" Click="IncreaseWeek" Style="{DynamicResource NextButtonStyle}" Height="{Binding ElementName=PickWeek, Path=ActualHeight}" Width="{Binding ElementName=IncreaseWeekButton, Path=ActualHeight}"/>
                    </StackPanel>
                    <Grid Grid.Column="2" HorizontalAlignment="Center" MinWidth="125" Grid.IsSharedSizeScope="True">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="Button"/>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="Button"/>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="Button"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Button x:Name="ImportantEntriesButton" Grid.Column="1" Margin="10,0" Tag="ImportantEntries" Style="{DynamicResource DefaultButton}" Click="OpenPopup">
                            <Viewbox Width="32" Height="32" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
                                <Rectangle Width="32" Height="32">
                                    <Rectangle.Fill>
                                        <DrawingBrush>
                                            <DrawingBrush.Drawing>
                                                <DrawingGroup>
                                                    <DrawingGroup.Children>
                                                        <GeometryDrawing Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" />
                                                        <GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M8,16C3.589,16 0,12.411 0,8 0,3.589 3.589,0 8,0 12.411,0 16,3.589 16,8 16,12.411 12.411,16 8,16" />
                                                        <GeometryDrawing x:Name="ImportantEntriesMarkBackgroundColor" Brush="#80424242" Geometry="F1M9,10L7,10 7,3 9,3z M9,13L7,13 7,11 9,11z M8,1C4.134,1 1,4.134 1,8 1,11.865 4.134,15 8,15 11.865,15 15,11.865 15,8 15,4.134 11.865,1 8,1" />
                                                        <GeometryDrawing Brush="#FFEFEFF0" Geometry="F1M9,11L7,11 7,13 9,13z M9,10L7,10 7,3 9,3z" />
                                                    </DrawingGroup.Children>
                                                </DrawingGroup>
                                            </DrawingBrush.Drawing>
                                        </DrawingBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                            </Viewbox>
                        </Button>
                        <Button x:Name="SettingsButton" Grid.Column="2" MinWidth="125" Margin="10,0" Tag="Settings" Click="OpenPopup" Style="{DynamicResource DefaultButton}">
                            <Button.Content>
                                <Grid>
                                    <AccessText Text="_Einstellungen" Opacity="0"/>
                                    <Viewbox Width="32" Height="32" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
                                        <Rectangle Width="32" Height="32">
                                            <Rectangle.Fill>
                                                <DrawingBrush>
                                                    <DrawingBrush.Drawing>
                                                        <DrawingGroup>
                                                            <DrawingGroup.Children>
                                                                <GeometryDrawing Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" />
                                                                <GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M5.9859,-0.000199999999999534L5.6129,2.2378 3.7669,0.918800000000001 0.9189,3.7668 2.2369,5.6128 -9.99999999997669E-05,5.9858 -9.99999999997669E-05,10.0118 2.2369,10.3868 0.9189,12.2338 3.7669,15.0798 5.6119,13.7628 5.9859,15.9998 10.0129,15.9998 10.3869,13.7618 12.2339,15.0798 15.0799,12.2338 13.7619,10.3868 15.9999,10.0148 15.9999,5.9868 13.7619,5.6128 15.0799,3.7668 12.2339,0.919800000000001 10.3869,2.2378 10.0139,-0.000199999999999534z" />
                                                                <GeometryDrawing Brush="#FF424242" Geometry="F1M10.2123,8C10.2123,9.222 9.2223,10.212 8.0003,10.212 6.7783,10.212 5.7873,9.222 5.7873,8 5.7873,6.778 6.7783,5.788 8.0003,5.788 9.2223,5.788 10.2123,6.778 10.2123,8z M9.9643,3.257C9.8183,3.197,9.6683,3.17,9.5203,3.124L9.1663,1 6.8333,1 6.4803,3.121C6.1853,3.213,5.8993,3.332,5.6253,3.475L3.8753,2.225 2.2253,3.875 3.4773,5.627C3.4053,5.764 3.3183,5.89 3.2573,6.036 3.1973,6.182 3.1703,6.331 3.1243,6.479L1.0003,6.833 1.0003,9.166 3.1213,9.52C3.2133,9.815,3.3313,10.101,3.4753,10.375L2.2253,12.125 3.8753,13.775 5.6273,12.523C5.7643,12.595 5.8893,12.682 6.0353,12.742 6.1813,12.803 6.3313,12.83 6.4793,12.876L6.8333,15 9.1663,15 9.5203,12.879C9.8153,12.787,10.1013,12.668,10.3743,12.525L12.1243,13.775 13.7743,12.125 12.5233,10.373C12.5953,10.236 12.6823,10.11 12.7423,9.964 12.8033,9.818 12.8303,9.669 12.8763,9.521L15.0003,9.167 15.0003,6.834 12.8783,6.48C12.7863,6.185,12.6683,5.899,12.5243,5.625L13.7743,3.875 12.1253,2.225 10.3723,3.477C10.2353,3.405,10.1103,3.318,9.9643,3.257z" />
                                                            </DrawingGroup.Children>
                                                        </DrawingGroup>
                                                    </DrawingBrush.Drawing>
                                                </DrawingBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
                                    </Viewbox>
                                </Grid>
                            </Button.Content>
                        </Button>
                        <Button x:Name="PrintButton" Grid.Column="3" Margin="10,0" Click="PrintButton_Click" Style="{DynamicResource DefaultButton}">
                            <Button.Content>
                                <Grid>
                                    <AccessText Text="_Drucken" Opacity="0"/>
                                    <Viewbox Width="32" Height="32" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
                                        <Rectangle Width="32" Height="32">
                                            <Rectangle.Fill>
                                                <DrawingBrush>
                                                    <DrawingBrush.Drawing>
                                                        <DrawingGroup>
                                                            <DrawingGroup.Children>
                                                                <GeometryDrawing Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" />
                                                                <GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M15.2686,6.73C14.7906,6.252,14.1786,6,13.4996,6L12.9996,6 12.9996,0 2.9996,0 2.9996,6 2.4996,6C1.8206,6 1.2076,6.252 0.730599999999999,6.73 0.252599999999999,7.208 -0.000400000000000844,7.82 -0.000400000000000844,8.5L-0.000400000000000844,14 2.9996,14 2.9996,16 12.9996,16 12.9996,14 15.9996,14 15.9996,8.5C15.9996,7.822,15.7476,7.21,15.2686,6.73" />
                                                                <GeometryDrawing Brush="#FFEFEFF0" Geometry="F1M5,14L11,14 11,12 5,12z M11,2L5,2 5,7 11,7z M14,8.5L14,12 12,12 12,11 4,11 4,12 2,12 2,8.5C2,8.354 2.047,8.234 2.141,8.141 2.234,8.047 2.354,8 2.5,8L13.5,8C13.646,8 13.766,8.047 13.859,8.141 13.953,8.234 14,8.354 14,8.5" />
                                                                <GeometryDrawing Brush="#FF424242" Geometry="F1M11,12L5,12 5,14 11,14z M5,7L11,7 11,2 5,2z M3,10L4,10 4,9 3,9z M14,8.5C14,8.354 13.953,8.234 13.859,8.141 13.766,8.047 13.646,8 13.5,8L2.5,8C2.354,8 2.234,8.047 2.141,8.141 2.047,8.234 2,8.354 2,8.5L2,12 4,12 4,11 12,11 12,12 14,12z M15,13L12,13 12,15 4,15 4,13 1,13 1,8.5C1,8.083 1.146,7.729 1.437,7.437 1.729,7.146 2.083,7 2.5,7L4,7 4,1 12,1 12,7 13.5,7C13.916,7 14.271,7.146 14.563,7.437 14.854,7.729 15,8.083 15,8.5z" />
                                                            </DrawingGroup.Children>
                                                        </DrawingGroup>
                                                    </DrawingBrush.Drawing>
                                                </DrawingBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
                                    </Viewbox>
                                </Grid>
                            </Button.Content>
                        </Button>
                    </Grid>
                </Grid>
                <Grid x:Name="CalendarGrid">
                    <Border BorderThickness="1,2,0,2" BorderBrush="Black">
                        <Grid x:Name="BackgroundGrid">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Border BorderThickness="1,0,1,0" BorderBrush="Black" Grid.Column="0">
                                <DockPanel>
                                    <Label Content="Montag" FontSize="20" HorizontalAlignment="Center"  DockPanel.Dock="Top"></Label>
                                    <Label x:Name="Day1" Content="1" FontSize="20" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
                                </DockPanel>
                            </Border>
                            <Border BorderThickness="1,0,1,0" BorderBrush="Black" Grid.Column="1">
                                <DockPanel>
                                    <Label Content="Dienstag" FontSize="20" HorizontalAlignment="Center"  DockPanel.Dock="Top"></Label>
                                    <Label x:Name="Day2" Content="2" FontSize="20" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
                                </DockPanel>
                            </Border>
                            <Border BorderThickness="1,0,1,0" BorderBrush="Black" Grid.Column="2">
                                <DockPanel>
                                    <Label Content="Mittwoch" FontSize="20" HorizontalAlignment="Center"  DockPanel.Dock="Top"></Label>
                                    <Label x:Name="Day3" Content="3" FontSize="20" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
                                </DockPanel>
                            </Border>
                            <Border BorderThickness="1,0,1,0" BorderBrush="Black" Grid.Column="3">
                                <DockPanel>
                                    <Label Content="Donnerstag" FontSize="20" HorizontalAlignment="Center"  DockPanel.Dock="Top"></Label>
                                    <Label x:Name="Day4" Content="4" FontSize="20" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
                                </DockPanel>
                            </Border>
                            <Border BorderThickness="1,0,1,0" BorderBrush="Black" Grid.Column="4">
                                <DockPanel>
                                    <Label Content="Freitag" FontSize="20" HorizontalAlignment="Center"  DockPanel.Dock="Top"></Label>
                                    <Label x:Name="Day5" Content="5" FontSize="20" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
                                </DockPanel>
                            </Border>
                            <Border BorderThickness="1,0,1,0" BorderBrush="Black" Grid.Column="5">
                                <DockPanel>
                                    <Label Content="Samstag" FontSize="20" HorizontalAlignment="Center"  DockPanel.Dock="Top"></Label>
                                    <Label x:Name="Day6" Content="6" FontSize="20" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
                                </DockPanel>
                            </Border>
                            <Border BorderThickness="1,0,1,0" BorderBrush="Black" Grid.Column="6">
                                <DockPanel>
                                    <Label Content="Sonntag" FontSize="20" HorizontalAlignment="Center"  DockPanel.Dock="Top"></Label>
                                    <Label x:Name="Day7" Content="7" FontSize="20" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
                                </DockPanel>
                            </Border>
                        </Grid>
                    </Border>
                    <ScrollViewer x:Name="CategoriesScrollViewer" VerticalScrollBarVisibility="Visible">
                        <Grid x:Name="EntriesGrid">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="35"/>
                                <RowDefinition/>
                                <RowDefinition Height="35"/>
                            </Grid.RowDefinitions>
                        </Grid>
                    </ScrollViewer>
                </Grid>
            </DockPanel>
        </Grid>
    </Grid>
</DockPanel>

此处的解决方案: How to Publish a Winforms App with SQLite using ClickOnce

简短说明:通过 Nuget 获取 SQLite 不会将 SQLite.Interop.dll 添加到 ClickOnce 部署中。 您需要手动添加这些。 关于如何做到这一点,请点击链接。

暂无
暂无

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

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