在运行时执行C#或VB.NET代码 [英] Executing C# or VB.NET code at Runtime

查看:112
本文介绍了在运行时执行C#或VB.NET代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近在Codility.com上度过了一段时间,并且跨越了我的脑海;他们如何执行您创建的代码(具体涉及C#和VB.NET)?



我基本上想知道我将如何在表单上使用一个文本框在其中键入一些代码,然后运行该代码?是否可以没有第三方工具?



另外,如何防止与此类程序的基于Web的实现相关的安全性违规?

解决方案

看看 http://msdn.microsoft.com/en-us/library/system.codedom.compiler.aspx 在Web应用程序中执行此类代码是一个安全问题。 .Net提供了一组功能来帮助您解决这个问题,例如将不同用户的编译代码运行在不同的应用程序域中。


Been spending some time on Codility.com recently and it crossed my mind; how do they execute the code you have created (Specifically pertaining to C# and VB.NET) ?

What I am basically wondering is how would I take a textbox on a form type some code in it and then run that code? Is this possible without 3rd party tools?

Also how would you prevent security violations specifically pertaining to a web based implementation of such a program?

解决方案

Have a look at http://msdn.microsoft.com/en-us/library/system.codedom.compiler.aspx Executing such code in a web app is in deed a security problem. .Net provides a set of functionalities to help you solve that problem, like the possibility to run your compiled code in a different app domain as a different user.

这篇关于在运行时执行C#或VB.NET代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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