DeBedenHasen
DeBedenHasen

Reputation: 45

'Value cannot be null' 'Parameter name: key' during compile with no obvious(?) reason

I've already been browsing the site for a while now, trying to find a solution for these pretty mysterious errors — none of the ones I found helping my particular case.

I should note that I know basically nothing about C# or how WPF actually works, which might also explain why none of the threads here looked like solutions to my problem.

After (I really don't know what I did), VS is now coming up with two (identical) errors:

Description: Value cannot be null.
Value cannot be null.
Parameter name: key

Apart from these, the solution does not contain any errors or warnings.

Double-clicking the errors opens the files MainWindow.xaml and App.xaml at Ln: 1 Ch: 1 with nothing highlighted as an error or warning.

// MainWindow.xaml

<Window x:Class="solution_alpha_pack_roll_generator.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"
        mc:Ignorable="d"
        Title="MainWindow" Height="470" Width="800">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <TextBlock Name="Rarities_1" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="NoWrap" TextAlignment="Center" FontSize="25" FontFamily="Lato" Text="Common" />
        <TextBlock Name="Rarities_2" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="NoWrap" TextAlignment="Center" FontSize="25" FontFamily="Lato" Text="Uncommon" />
        <TextBlock Name="Rarities_3" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="NoWrap" TextAlignment="Center" FontSize="25" FontFamily="Lato" Text="Rare" />
        <TextBlock Name="Rarities_4" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="NoWrap" TextAlignment="Center" FontSize="25" FontFamily="Lato" Text="Epic" />
        <TextBlock Name="Rarities_5" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="NoWrap" TextAlignment="Center" FontSize="25" FontFamily="Lato" Text="Legendary" />

        <TextBox Name="Rarities_1_C" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="NoWrap" TextAlignment="Center" FontSize="25" FontFamily="Consolas" Width="140" Height="50" Text="0.330" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
        <TextBox Name="Rarities_2_C" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="NoWrap" TextAlignment="Center" FontSize="25" FontFamily="Consolas" Width="140" Height="50" Text="0.285" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
        <TextBox Name="Rarities_3_C" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="NoWrap" TextAlignment="Center" FontSize="25" FontFamily="Consolas" Width="140" Height="50" Text="0.224" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
        <TextBox Name="Rarities_4_C" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="NoWrap" TextAlignment="Center" FontSize="25" FontFamily="Consolas" Width="140" Height="50" Text="0.125" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
        <TextBox Name="Rarities_5_C" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="NoWrap" TextAlignment="Center" FontSize="25" FontFamily="Consolas" Width="140" Height="50" Text="0.036" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />

        <Button Name="Rarities_Defaults" Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="25" FontFamily="Lato" Width="300" Height="50" Content="Reset to defaults" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Click="Rarities_Defaults_Click"/>
    </Grid>
</Window>
// App.xaml

<Application x:Class="solution_alpha_pack_roll_generator.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
</Application>

EDIT: (Re)Building is not possible with VS printing this in the Output window:

1>------ Rebuild All started: Project: solution_alpha-pack-roll-generator, Configuration: Debug Any CPU ------
1>App.xaml : error : Value cannot be null.
1>App.xaml : error : Parameter name: key
1>MainWindow.xaml : error : Value cannot be null.
1>MainWindow.xaml : error : Parameter name: key
1>Done building project "solution_alpha-pack-roll-generator.csproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

EDIT 2: GitHub repository here: https://github.com/DeBedenHasen/alpha-pack-roll-generator

Upvotes: 2

Views: 2670

Answers (1)

MaSiMan
MaSiMan

Reputation: 690

I think the problem is that you are referencing Xamarin.Formsand Xamarin.Essentials in your csproj. I cloned your repository, and after removing these references (and adding some using statements to MainWindow.xaml.cs, App.xaml.cs and AssemblyInfo.cs), it builds fine.

Upvotes: 3

Related Questions