views:

3100

answers:

3

I'm storing all localizable strings in a ResourceDictionary (in App.xaml) and assign those via the StaticResource markup extension to TextBlock.Text, Button.Content etc.

In Beta 2 and RC0, sometimes parsing the XAML in InitializeComponent() will fail with an AG_E_PARSER_BAD_PROPERTY_VALUE on the line and position where I set the attribute value to the StaticResource.

It only happens sometimes: When restarting the app, it parses and displays without any problems. The same interface code works for days or weeks, then it happens again.

Any ideas?

+1  A: 

Parser, at least in beta 2, didnt like whitespace...

For instance:

Text="{StaticResource bleh}"

worked

however this:

Text = "{StaticResource bleh}"

bombed

Brian Leahy
A: 

I am getting the same error. The solution suggested did not work. But when I removed the Static Resource and put the hardcoded string directly, it worked. But, how do we resolve this ?!

DotNetGuy
For a [similar problem I had](http://stackoverflow.com/questions/229117/xamlparseexception-attribute-in-custom-control-missing-but-its-defined), the "solution" was to try/catch the initialization until it worked. May work for you. Please edit your "answer" with information if you could solve it this way.
Daniel Beck
A: 

Basically it means bad xaml somewhere in the code you can see the Line number and Position and see something is wrong .. I got the same error in my xaml Once corrected everything seems working

Amature Developer
Read the question to the end (by the way, this was two years ago in SL 2.0 Release Candidate): It only happened SOMETIMES. And definitely no bad XAML, I quadruple-checked everything.
Daniel Beck