yck1509 / ConfuserEx

An open-source, free protector for .NET applications
http://yck1509.github.io/ConfuserEx/
Other
3.57k stars 1.63k forks source link

Assembly.GetType(...) fails with names starting with \u2028 #52

Closed bignoncedric closed 10 years ago

bignoncedric commented 10 years ago

Assembly.GetType(...) fails when a name starts with the unicode character \u2028.

For example, the following program obfuscated with only the renamer and a seed = "12" will fail.

internal static class Program
{
    static void Main()
    {
        Do<MyClass1>();
        Do<MyClass2>();
        Do<MyClass3>();
        Do<MyClass4>();
        Do<MyClass5>();
        Do<MyClass6>();
        Do<MyClass7>();
        Do<MyClass8>();
        Do<MyClass9>();
    }

    public static void Do<T>()
    {
        Console.WriteLine("Doing {0}", String.Concat(from c in typeof(T).Name
                                                        select String.Format(@"\u{0:x4}", (int)c)));
        var t = Assembly.GetExecutingAssembly().GetType(typeof(T).FullName);
        if (t == null)
            throw new Exception("Type not found!!");
    }
}

internal sealed class MyClass1 { }
internal sealed class MyClass2 { }
internal sealed class MyClass3 { }
internal sealed class MyClass4 { }
internal sealed class MyClass5 { }
internal sealed class MyClass6 { }
internal sealed class MyClass7 { }
internal sealed class MyClass8 { }
internal sealed class MyClass9 { }

Maybe, you should remove the \u2028 character from the allowed characters for the renaming.

yck1509 commented 10 years ago

In most situations, you should exclude the classes from renaming if you are using their name/namespace. Note that if you reference it directly (i.e. typeof(MyClass1).Name), ConfuserEx would automatically exclude it.

yck1509 commented 10 years ago

Also, if having obfuscated names do not matter in your application, feel free to describe your situation so that I could help you.

yck1509 commented 10 years ago

Close due to inactivity. If you're are still encountering this issue, please feel free to reopen the issue with more information.