In the below code snippet, the call to CreateDelegate with the 64-bit enum throws an ArgumentException "Error binding to target method". Yet the 32-bit enum works fine.
Could someone tell me why?
class Test
{
public static void DoIt()
{
Func<int, int> f32 = i => i;
var d32 = (Func<int, E32>)Delegate.CreateDelegate(typeof(Func<int, E32>), f32.Method);
Func<long, long> f64 = i => i;
var d64 = (Func<long, E64>)Delegate.CreateDelegate(typeof(Func<long, E64>), f64.Method);
}
}
enum E32 { };
enum E64 { };
(For some context on this weird code, it's inspired by this answer: https://stackoverflow.com/a/4026609/14582)
Is there something special about 64-bit enums that makes this fail, perhaps an unimplemented code path in binding argument matching code? Or is it a quirk that 32-bit enum works in this way?