在程序运行的外部C#文件 [英] running external C# file in a program

查看:86
本文介绍了在程序运行的外部C#文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问NET框架有任何类,允许你运行(编译除preT或其他)外部脚本文件中包含C#code?

Does the .NET framework have any classes which allow you to run (compile, interpret or whatever) an external script file containing C# code?

举例来说,如果我有一个文件 hello.cs中包含这样的:

For instance, if I have a file Hello.cs containing this:

class Hello
//This program displays Hello World
{
    static public void Main()
    {
        System.Console.WriteLine("Hello World");
    }
}

我怎样才能加载code以上,从一个WinForm的,应用程序,并执行它?

how can i load the code above, from within a winform, app and execute it?

我感兴趣的负载/执行逻辑;该程序可以是任何东西,从一个控制台应用程序到另一个winform应用程序。

I'm interested in the load/execute logic; the program could be anything, from a console app to another winform app.

反思是否允许这样?

推荐答案

看看下面的文章:的 C#:写上使用即时编译扩展的应用程序

Check out the following article: C#: Writing extendable applications using on-the-fly compilation.

这篇关于在程序运行的外部C#文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆