0

This is something that's driving me crazy.. I have a WPF project which is already in production. Now, I have to make some fix for which I have to set x:Name property to couple of controls. But, when I set x:Name property for any control, it's throwing XamlParser exception (inner exception says cannot cast type XXX to type Button where XXX is type of control for which I am setting x:Name property).

It also shows an additional error like,

Additional information: Set connectionId threw an exception.

I have closed and reopened Visual Studio; I have cleaned the solution and rebuilt many times; but no use.

Can anybody let mw know what's going on?

Here is the code - I have just added x:Name = "PnlUpDown" to stack panel.

<StackPanel Name="PnlUpDown" VerticalAlignment="Center" Grid.Column="3">
            <Button x:Name="BtnMoveUp" Padding="3,5" Margin="5,0,0,3" Tag="MOVEUP" >
                <Polygon Points="0,15 5,0,10,15" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}"/>
            </Button>
            <Button x:Name="BtnMoveDown" Padding="3,5" Margin="5,3,0,0" Tag="MOVEDOWN" >
                <Polygon Points="0,0 5,15,10,0" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=Button}}"/>
            </Button>
</StackPanel>

Now.. I find that not only x:Name property.. It's not allowing me to set any other property to any control - In general, if I modify my XAML it's throwing error..!!!!!!! For everything it's throwing Set Connection Id error :(

Adavesh
  • 557
  • 5
  • 9

2 Answers2

0

First, check out this post: How do you debug a XamlParseException?. Specifically, look at the call stack as noted in the answer by Igor Zevaka.

Also check the answers to the following questions:

XamlParseException can be one of the more difficult exceptions to find. If none of those point you in the right direction, look at the code-behind and the data context. Perhaps there is an exception being thrown in one of those locations.

Community
  • 1
  • 1
Brandon Bonds
  • 203
  • 1
  • 9
  • Thank you. I went through those links. But no use. Actually the same project is VS2013 and VS2010 (exact copies except prior one targets 4.5 framework and later one targets 3.5). If I make the changes in later one, it works fine. But 2013 one gives problem. May be some bug in VS2013. – Adavesh Jul 17 '14 at 12:03
0

I don't know how it's related but I just restarted my machine and the issue got resolved !!!! May be Visual Studio 2013 gets refreshed when the machine reboots.. I don't know. Anyways, Thanks everyone for your replies.

Adavesh
  • 557
  • 5
  • 9