开发者

using c# like script in runtime

I want to learn if there is any library in .开发者_如何学JAVAnet to write c# scripts. Let me describe you with more detail, for example I have an application. When I run it, a c# editor will be opened end user will write some c# codes and when click run, this code should be evaluated and dom should be created after interpret my run time c# code will run. this is brief description of my mind...


I put together a little app called SimpleDevelop which uses CSharpCodeProvider to do what you describe. My understanding is that this (CodeDom) is deprecated and generally discouraged; however, it seems to work just fine for simple scenarios.


Basically, you want to use something like the CSharpCodeProvider. The Razor view engine in MVC essentially uses this to compile your code into an executable to run. If you want your user to be able to write code and then have it interpreted, you would start here. Please note though, this is an incredibly complicated and time intensive feat to get right; plus, linking in and executing foreign code dynamically is a security nightmare. Just be safe.


Are you looking for a test bench sort of?

I use LinqPad for that.

It is mostly a test bench for Linq queries, but I find it very useful for C# statements and mini programs and such.


Check out the System.CodeDom namespace.

This article contains lots of useful information: http://www.developerfusion.com/article/4529/using-net-to-make-your-application-scriptable/2/


You can use the Compiler namespace and compilate the code at runtime. Take a look here for an explanation on how to do it.


I have created an application which will run c# like script without using visual studio. It is on https://sourceforge.net/projects/csharpquickcode/

using c# like script in runtime

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜