Im getting a MethodAccessException whenever I try to invoke the method.
This is because the method generated for the C# (t) => t.DoSomething lambda is private. Chances are this lambda won't be static, either, depending on which of the local variables it captures from the outer method. You're issuing a callvirt instruction but you don't appear to be supplying an instance.
You can verify this by loading your application's code in Reflector and looking at the implementation of your (t) => t.DoSomething lambda.
You need to either:
- Upgrade your lambda to a real
public static method in an externally-visible class
- Find a way to include a parameter of type
Action<Type> in your IL method, generate code that calls Action<Type>.Invoke, then pass your action variable into the generated method