Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decompile complex BAML to valid XAML

Tags:

c#

wpf

xaml

baml

I tried ILSpy, but it failed:

System.NotImplementedException: StaticResourceStart
   в Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ProcessNext()
   в Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ReadInternal()
   в Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.Read()
   в System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
   в System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
   в System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   в ILSpy.BamlDecompiler.BamlResourceEntryNode.LoadIntoDocument(IAssemblyResolver resolver, AssemblyDefinition asm, Stream stream)
   в ILSpy.BamlDecompiler.BamlResourceEntryNode.LoadBaml(AvalonEditTextOutput output)
   в ILSpy.BamlDecompiler.BamlResourceEntryNode.<>c__DisplayClass3.<View>b__1()

I tried Baml Viewer for .Net Reflector, but it was unable to generate valid XAML.

The main problem was with Binding that reference to wrong StaticResource.

For example (namedViews is CollectionViewSource):

   Visibility="{Binding Path=Value, Converter={StaticResource namedViews}}"
   ToolTip="{StaticResource namedViews}"

What other applications exist to decompile BAML? Any patch to BAML Viewer?

like image 557
Quiz Avatar asked Jun 15 '11 09:06

Quiz


1 Answers

Not sure if this will help you, but if you can run the application, you can use Snoop to run through the structure of a WPF application.

Other options:

  • dotPeek (but I believe it needs the Baml4dotPeek plugin which is based on Baml Viewer for Reflector, which, as you said, didn't work.)
  • JustDecompile (you have to register with Telerik, I believe)
  • Woodstock for WPF

I've only tried Snoop and like it very much, but that didn't seem to solve your problem.

like image 114
Peter Avatar answered Oct 07 '22 21:10

Peter