Bad install of WPF?
Magnus Hiie reported an interesting problem that some of you may be hitting (thanks Magnus!). He saw
System.Windows.Serialization.BamlParseException occurred
Message="Error at element 'StaticExtension' in markup file '' : Binary format of the specified custom attribute was invalid.."
on pretty much every xaml file he tried to load. Problem is that the machine has an assembly in the GAC that can't be loaded, and WPF needs to look at every assembly in the GAC. Assembly can't be read, so WPF chokes. We'll work on making this a little more tolerant, but for now the solution is to remove whatever unreadable assembly is in your GAC. You can figure out which assembly is causing the problem by breaking on first chance exceptions, call stack will look something like:
mscorlib.dll!System.Reflection.CustomAttributeData.GetCustomAttributes(System.Reflection.Module module = {Microsoft.BizTalk.KwTpm.StsBizTalkAdapter.dll} , int tkTarget) + 0x4f bytes
As to why we're touching every assembly in the GAC -- we scan every assembly for XmlnsDefinitionAttribute so we know how to map XML namespaces into assemblies. We cache it, so we don't need to do this every time a process launches, but we do need to read all the assemblies once.
Comments
- Anonymous
December 20, 2005
Does this attribute allow my control library to define the namespace to use in XAML without having to have the mapping directive in the referencing XAML file? Do I still need the xmlns:x=y or does the attribute define the prefix as well? I will check the docs also now that I know such an attribute even exists. - Anonymous
January 18, 2006
I get a variation of the BamlParseException.
Here is the trace.
what is going wrong over here?
System.Windows.Serialization.BamlParseException: Error at element 'StaticExtension' in markup file '' : Could not load type 'System.Runtime.CompilerServices.NGenAttribute' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.. ---> System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.NGenAttribute' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. - Anonymous
February 16, 2006
The comment has been removed