Unimatrix_001
asked on
Reflection - Changing a method visibility
Hi,
I've got a MethodInfo object and I'm wanting to change that method (using reflection) from public to private. Possible?
Thanks,
Uni
I've got a MethodInfo object and I'm wanting to change that method (using reflection) from public to private. Possible?
Thanks,
Uni
Are you writing an assembly at run time, or what? What would the purpose/reason be? Just trying to understand the why before giving best answer on how.
ASKER
Hello!
Well, I'm playing around with some ideas for copy protection, also I wouldn't mind learning a little more about reflection as all the vast majority of stuff seems to be just pulling data and calling an existing method... nothing too exciting if you ask me.
Thanks,
Uni
Well, I'm playing around with some ideas for copy protection, also I wouldn't mind learning a little more about reflection as all the vast majority of stuff seems to be just pulling data and calling an existing method... nothing too exciting if you ask me.
Thanks,
Uni
Hi Unimatrix_001;
If you take a look at the MethodInfo class you will see that all its propertiesare Get's and non are Set's properties. So there is no way that I know to do this, sorry.
MethodInfo Class
http://msdn.microsoft.com/en-us/library/system.reflection.methodinfo.aspx
Fernando
If you take a look at the MethodInfo class you will see that all its propertiesare Get's and non are Set's properties. So there is no way that I know to do this, sorry.
MethodInfo Class
http://msdn.microsoft.com/en-us/library/system.reflection.methodinfo.aspx
Fernando
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh boy... Things just got difficult...
The Reflection.Emit permits you create at run time code it does not permit you to change the scope of a existing method from private to public.
LOL! We looked into that for the same reasons a while back, but ran out of time :( It has a lot of potention for use when installing programs, you could emit certain assemblies for things. But like you said, it gets difficult fast! Thanks!
ASKER
The Reflection.Emit permits you create at run time code it does not permit you to change the scope of a existing method from private to public.It does seem though as code could be copied and edited before being ran in a new assembly...