How to determine from MethodInfo - if a method is a dynamic method?
-
Friday, May 18, 2012 3:37 PM
Is there way with reflection to ascertain if a method is dynamic (generated dynamically) ?
I can see no obvious properties in MethodInfo or MethodBase so wondered if anyone had any idea?
Thx
Cap'n
All Replies
-
Friday, May 18, 2012 3:42 PMModerator
Hmm, check the type ?
if (methodInfo is System.Reflection.Emit.DynamicMethod) { // methodInfo is a dynamic method... }
- Proposed As Answer by Kris444 Friday, May 18, 2012 6:09 PM
- Marked As Answer by Mike FengMicrosoft Contingent Staff, Moderator Thursday, May 31, 2012 11:33 AM
-
Friday, May 18, 2012 6:11 PM
Hi,
You can also rely on ReflectedType. For dynamic methods ReflectedType is always null.
if(methodInfo.ReflectedType == null) { //methodInfo is dynamicmethod }
If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".
- Proposed As Answer by Mike FengMicrosoft Contingent Staff, Moderator Monday, May 21, 2012 10:38 AM
- Marked As Answer by Mike FengMicrosoft Contingent Staff, Moderator Thursday, May 31, 2012 11:33 AM
-
Saturday, June 02, 2012 4:33 PM
Hmm, check the type ?
if (methodInfo is System.Reflection.Emit.DynamicMethod) { // methodInfo is a dynamic method... }
Very good Mike - much appreciated.

