How can I allow a user to enter a string into a winforms application and then use reflection to parse that string which can be executed at runtime?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Security holes galore, I think, unless you do this with the utmost care! If you really want to do this however, you’ll want to look into using the CodeDOM. Since C# is not (yet) a dynamic language, it does not have an
evalfeature, and dynamically compiling assemblies with the CodeDOM is the closest you’ll get.For an example, see my answer to this related question, which uses
CSharpCodeProvideralong with the CodeDOM to achieve the goal. Beware though, if you want to make your app even reasonably secure, you’ll want to run the code with its own AppDomain, and possibly its own process (with some form of IPC).