Well, I admit that this code will look strange to you, and that is because it is strange . This is just code to reproduce the behavior, not the code I want to use.
class Program { static void Main(string[] args) { try { Activator.CreateInstance(typeof(Func<int>), new object[] { new object(), IntPtr.Zero }); } catch { Console.WriteLine("This won't print!"); } Console.Write("Actually this will not print either!"); Console.ReadLine(); } }
No matter what type of exception I'm trying to catch (the actual exception is an ArgumentException, as far as I can tell), the code inside the catch block will not execute. In fact, execution will simply be stopped on the Activator.CreateInstance line.
Patrik HΓ€gne
source share