惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
G
Google Developers Blog
宝玉的分享
宝玉的分享
爱范儿
爱范儿
Last Week in AI
Last Week in AI
U
Unit 42
B
Blog RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
D
DataBreaches.Net
Recent Commits to openclaw:main
Recent Commits to openclaw:main
雷峰网
雷峰网
T
The Exploit Database - CXSecurity.com
L
LangChain Blog
C
CERT Recently Published Vulnerability Notes
S
Schneier on Security
C
Cisco Blogs
MongoDB | Blog
MongoDB | Blog
G
GRAHAM CLULEY
Hacker News - Newest:
Hacker News - Newest: "LLM"
大猫的无限游戏
大猫的无限游戏
L
LINUX DO - 最新话题
D
Docker
K
Kaspersky official blog
Security Latest
Security Latest
博客园 - 【当耐特】
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Hacker News
The Hacker News
P
Privacy International News Feed
Microsoft Security Blog
Microsoft Security Blog
V2EX - 技术
V2EX - 技术
The Last Watchdog
The Last Watchdog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Martin Fowler
Martin Fowler
Latest news
Latest news
Project Zero
Project Zero
TaoSecurity Blog
TaoSecurity Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Threat Research - Cisco Blogs
H
Heimdal Security Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Help Net Security
Help Net Security
A
Arctic Wolf
Cisco Talos Blog
Cisco Talos Blog
Engineering at Meta
Engineering at Meta
M
MIT News - Artificial intelligence

博客园 - 逍遥游

验证数字的正则表达式集 .NET实现RSS格式文件 - 逍遥游 - 博客园 SQL SERVER 2005 通过链接服务器 访问 ORACLE 9i 的快速设定方法 [转]asp.net页面缓存技术 - 逍遥游 - 博客园 Oracle常用Script [整理]如何在 JavaScript 中实现拖放 [转]鼠标拖动层的javascript脚本 [转]Spring笔记 [转]web项目经理手册-项目经理需要铭记在心的话 [原]学习Struts+Spring+hibernate笔记 [转]Request.UrlReferrer详解 [转]hibernate产生自动增长的主键 JSP学习相关链接 .net 资源网站收集 一个很COOL的图片验证码程序[含源码] 转 关于XMLHTTP无刷新数据获取和发送 (转) .NET中获取客户端HTML代码 使用Hibernate、Struts的一些错误总结 [转]简单好用的ajax进度条(xmlhttp),实现的是真正的进度
C#中如何动态运行代码
逍遥游 · 2007-06-08 · via 博客园 - 逍遥游

private void Compiler(string code)
        {
            CompilerParameters vCompilerParameters = new CompilerParameters();
            vCompilerParameters.GenerateExecutable = false;
            vCompilerParameters.GenerateInMemory = true;
            vCompilerParameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");
            string vSource =
                "using System.Windows.Forms;\n" +
                "public class Temp\n" +
                "{\n" +
                "    public void Test()\n" +
                "    {\n" +
                "         " + code + "\n" +
                "    }\n" +
                "}\n";
            CompilerResults vCompilerResults =
                CodeDomProvider.CreateProvider("CSharp").CompileAssemblyFromSource(vCompilerParameters, vSource);

            Assembly vAssembly = vCompilerResults.CompiledAssembly;
            object vTemp = vAssembly.CreateInstance("Temp");
            MethodInfo vTest = vTemp.GetType().GetMethod("Test");
            vTest.Invoke(vTemp, null);
        }

string code = "int sum = 0;\nfor(int i = 0; i < 100; i++)\n{\nsum += i;\n}\nMessageBox.Show(sum.ToString());";
            Compiler(code);