使用c#在编辑器中编译代码 [英] Compiling code in editor using c#

查看:115
本文介绍了使用c#在编辑器中编译代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii ...



任何人请提出一些建议,即在我自己的编辑器中编写C#.net代码,现在我想编译该代码,如果是代码没有任何错误,然后我想将该代码保存到.cs文件中

Hii...

anybody please give some suggestion that am writing C# .net code in my own editor and now i want to compile that code and if that code not had any errors then i want to save that code into a .cs file

推荐答案

使用CodeDOM很容易完成:

< a href =http://msdn.microsoft.com/en-us/library/system.codedom%28v=vs.110%29.aspx> http://msdn.microsoft.com/en-us/library /system.codedom%28v=vs.110%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/y2k85ax6%28v=vs.110%29.aspx [ ^ ]。



您也可以在应用程序中加载已编译的程序集,但它会是一个相当复杂的问题。这里的问题是.NET无法卸载一次加载的程序集(有充分的理由),因此解决方案将使用 AppDomain 。有关详细信息,请参阅我之前的回答:使用CodeDom生成代码 [ ^ ] 。



-SA
This is easily done using CodeDOM:
http://msdn.microsoft.com/en-us/library/system.codedom%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/y2k85ax6%28v=vs.110%29.aspx[^].

You can also load the compiled assemblies in your application, but it would be a considerable complication. The problem here is the inability of .NET to unload once loaded assemblies (for a good reason), so the solution would be using AppDomain. For further detail, please see my past answer: code generating using CodeDom[^].

—SA


这篇关于使用c#在编辑器中编译代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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