xamlParseException on window launch

Reid Kersey picture Reid Kersey · Aug 7, 2011 · Viewed 9.4k times · Source

I get the following error when I show this window from another window in my application:

XamlParseException occurred 'Set connectionId threw an exception.' Line number '4' and line position '25'.

With an inner exception of:

{"Unable to cast object of type 'System.Windows.Controls.TabControl' to type 'WpfApplication1.Window1'."}

My xaml code is as follows:

 <Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="482" Width="603" Loaded="Window_Loaded">
<Grid>
    <TabControl Height="402" HorizontalAlignment="Right" Margin="0,0,12,0" Name="tabControl1" VerticalAlignment="Top" Width="569" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}">
        <TabItem Header="tabItem1" Name="tabItem1">
            <Grid></Grid>
        </TabItem>
        <TabItem Header="tabItem2" Name="tabItem2">
            <Grid Height="374" Width="563">
                <ListView Height="317" HorizontalAlignment="Left" Margin="6,10,0,0" Name="listView1" VerticalAlignment="Top" Width="550">
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Header="IP" DisplayMemberBinding="{Binding CustomerIP}"/>
                            <GridViewColumn Header="Host Name" DisplayMemberBinding="{Binding HostName}"/>
                            <GridViewColumn Header="MAC" DisplayMemberBinding="{Binding MAC}"/>
                            <GridViewColumn Header="Avg. Ping Time" DisplayMemberBinding="{Binding time}"/>
                        </GridView>
                    </ListView.View>
                </ListView>
            </Grid>
        </TabItem>
        <TabItem Header="tabItem3" Name="tabItem3">
            <Grid Height="307" />
        </TabItem>
    </TabControl>
    <Button Content="Cancel" Height="23" HorizontalAlignment="Left" Margin="330,408,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
    <Button Content="Next" Height="23" HorizontalAlignment="Right" Margin="0,408,12,0" Name="button2" VerticalAlignment="Top" Width="75" Click="button2_Click" />
    <Button Content="Back" Height="23" HorizontalAlignment="Left" Margin="411,408,0,0" Name="button3" VerticalAlignment="Top" Width="75" IsEnabled="False" />
    <Rectangle Height="0" HorizontalAlignment="Left" Margin="13,40,0,0" Name="rectangle2" Stroke="Black" VerticalAlignment="Top" Width="453" />
    <ProgressBar Height="23" HorizontalAlignment="Left" Margin="5,408,0,0" Name="progressBar1" VerticalAlignment="Top" Width="319" Visibility="Hidden" />
    <Button Content="Remove" Height="23" HorizontalAlignment="Left" Margin="486,363,0,0" Name="button4" VerticalAlignment="Top" Width="75" IsEnabled="False" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="15,363,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" />
    <TextBox Height="23" HorizontalAlignment="Left" Margin="162,363,0,0" Name="textBox2" VerticalAlignment="Top" Width="120" />
    <Label Content="To" Height="28" HorizontalAlignment="Right" Margin="0,360,421,0" Name="label1" VerticalAlignment="Top" />
    <Button Content="Search" Height="23" HorizontalAlignment="Left" Margin="288,363,0,0" Name="button5" VerticalAlignment="Top" Width="75" Click="button5_Click" />
</Grid>

If you need my C# code to figure out this problem I can Email it to you, but it is against company policy to put that code on the web (and I enjoy my job... I dont want to get fired)

Please keep in mind that I normaly develop in VB.net, and C#.net is very new to me, so if you could please detail your explanations for a beginner that would be appreciated.


c#.net vs2010 Windows Vista x64 Intel Core 2 Quad

Answer

Samarth Agarwal picture Samarth Agarwal · Mar 12, 2013

Try Rebuilding the complete solution from Solution Explorer.