Dusty
Dusty

Reputation: 2189

Use CodeDOM or Mono - .NET

I understand I can use either the CodeDOM or Mono for compiling and executing C# code on the fly. Which of these are suggested given the security concerns of executing code and flexibility?

EDIT: I need to create an editor in which any user can enter code and choose to execute it. My concern is that if they have malicious code (accessing the file system for example) then I need to take precautions to prevent this from happening. How would I do this using CodeDOM or Mono?

Upvotes: 2

Views: 1373

Answers (2)

user7116
user7116

Reputation: 64078

You could use CodeDom anyways, compile and run the code in another AppDomain. My suggestion would be to insert the code as a CodeSnippetStatement into a CodeMemberMethod, that way they can't break out or are constrained by what you provide.

Upvotes: 1

Lex Li
Lex Li

Reputation: 63203

For maximum flexibility, Mono C# compiler should be the choice.

I don't think both provide any security protection inside, as that should be something you do in your own code.

Upvotes: 1

Related Questions