-1

I wish to be able to write code into an already running program that will compile and implement the code when I hit the send code button on my UI.

For example:

If I type:

MessageBox.Show("Hello World");

and the hit Send, I will get a pop up saying Hello World.

I have searched and searched for ways to this but I can't get any working.

Can anyone recommend a good way to do this?

Mark Schultheiss
  • 32,614
  • 12
  • 69
  • 100

2 Answers2

2

You could use CSharpCodeProvider but it is an older technology and is soon to be outdated.

The latest project Microsoft are toying with is Roslyn, it's currently in CTP and it exposes the compiler and analysis systems used by Microsoft and VStudio etc when building C# and VB.NET apps.

Here's a link on how to use its built in scripting engine.

http://visualstudiomagazine.com/articles/2011/11/16/the-roslyn-scripting-api.aspx

Clint
  • 6,133
  • 2
  • 27
  • 48
1

What you are looking for is the CSharpCodeProvider.

This allows you to compile or evaluate C# code from a source and run it. It can do it on the fly and from another process.

LightStriker
  • 19,738
  • 3
  • 23
  • 27