Thursday, January 06, 2011

How to fix Eazfuscator.NET unhandled exception error in WPF?

Today, I wanted to obfuscate one of the WPF applications that we are planing to deploy soon. While
googling I found this grate open source product Eazfuscator.NET and I downloaded the latest beat version and gave it a try.

After the obfuscating process completed I ran the .exe file to check whether everything is working as it suppose to but it didn't and I got this exception instead.

"Description: The process was terminated due to an unhandled exception. Exception Info: System.Windows.Markup.XamlParseException"

Now confused. I had no idea how to fix it ! googled it again and got nothing! So i decided to play around it and see.

1. Create a separate window. set it as the start-up Url in App.xaml file Eg,

2. If it's working, which it did for me.

3. Try looking at the MainWindow.xaml event bindings with the MainWindow.xaml.cs file.

most if the time, when it obfuscates, it will obfuscates events as well, If you have any events Like
Window_Loaded make sure they are not being obfuscated using the flag

[System.Reflection.Obfuscation(Exclude = true)]


[System.Reflection.Obfuscation(Exclude = true)] private void Window_Loaded(object sender, RoutedEventArgs e) {


4. Open the VS 2010 editor, Change it to release mode and rebuild.

you should see a message like,

Obfuscating assembly 'xxxxx.exe'...

then run, You should get an error message if you have any problems starting up which should be easy to diagnose.

Hope this will help someone. Eazfuscator.NET is a grate free product and I hope it will stay that way !


Oleksiy said...

Hi Aruna,

I came upon your message, and tried to reproduce the error for a window 'Loaded' event. The funny thing - it works even without explicit [Obfuscation] attributes.

So, it would be nice to see the corresponding part of XAML file.

Thank you in advance

Aruna Tennakoon said...

Hi Oleksiy,

Loaded is an example, I got the error on Window_StateChanged event if i am not mistaken.

Rami AbuGhazaleh said...

Thank you.

This helped me resolve the issue I was also experiencing.


LogicNP said...

AFAIK Eazfuscator is no longer free. Also try Crypto Obfuscator - it supports XAML/BAML renaming (essential for WPF apps).