0

I have this code to protect my files from deobfuscation:

Assembly asm = Assembly.Load(decFL);
MethodInfo entryPoint = asm.EntryPoint;
entryPoint.Invoke(null, new object[] { new string[] { "[ARGS]", "" } });

Obviously, [ARGS] is replaced by arguments. Now, when I compile my protection "stub" of sorts with the program I want to protect, (targeting v2.0), it crashes when I try to run.

Could not load type 'System.Func`2' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

This is from the line MethodInfo.Invoke. When I compile it against version v4.0, it runs successfully, but no window is shown to indicate the program is running. Instead, it just closes after it reached the MethodInfo.Invoke.

I'm really not sure what is causing this.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Adam M
  • 113
  • 3
  • 13
  • I forgot to add that if I make a tiny app which just says "Hello" in the console, and compile it against v4.0 (and my stub @ v2.0), it will run just fine. – Adam M May 04 '14 at 19:19
  • Go to Debug -> Exceptions and select all checkboxes under "thrown", it should throw some exception instead of just closing – a'' May 04 '14 at 19:20
  • I can't do that, as I'm compiling from my builder application. I have wrapped the whole client in a try/catch statement, hence why I get nothing. – Adam M May 04 '14 at 19:21
  • System.Func wasn't introduced until .Net 3.5. What version of .Net was the assembly you are trying to run written in? – shf301 May 04 '14 at 19:21
  • I imagine it would be to do with this: var q = alphabet.Select(x => x.ToString()); int size = 3; for (int i = 0; i < size - 1; i++) q = q.SelectMany(x => alphabet, (x, y) => x + y); - It was compiled against v4.0 – Adam M May 04 '14 at 19:23

0 Answers0