Errors After Obfuscar Obfuscation

381 Views Asked by At

I've used Obfuscar on my C# application, but the obfuscated version throws an exception where the normal version doesn't.

I'm trying to figure out what the problem is, but I'm struggling. I've used the XML options to turn off as much obfuscation as I can - essentially only changing the local variable names is in effect (can you turn that off?) - but the problem remains.

It appears to be caused by this line, concerning the Magick.NET library:

MagickImageCollection rowImages = new MagickImageCollection();

and throws this error:

The type initializer for 'NativeMagickImageCollection' threw an exception

Using ILSpy, I can't see anything in the obfuscated method that would trip this up - it's the very first thing in that method, more or less.

I'm at a loss as to what to try next - any ideas?

1

There are 1 best solutions below

0
Kyudos On

It turns out to just be my unfamiliarity with C#! Thanks to ChatGPT which told me to check the "InnerException" I found I was just missing a Magick DLL in my "Obfuscated" directory - nothing to do with the obfuscation at all, at least not directly. I guess I'm used to a more strident / obvious complaint when a DLL is missing. The "benefits" of managed code I suppose!

(Note I had, of course, run "Dependencies" on the obfuscated app - the missing DLL was not reported that way!)