C#解释器没有动力学或新组件的生成 [英] C# interpreter wihout dynamics or generation of new assemblies

查看:90
本文介绍了C#解释器没有动力学或新组件的生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要实现一个应该添加到能够支持脚本语言执行的框架的解释器。必须在脚本上下文中注入框架的大多数组件,允许使用脚本来操作应用程序。

I need to implement an interpreter that should be added to a framework able to support the execution of scripting language. Most of components of framework must be injected in the scripting context allowing to manipulate the application using scripting.

调用来自多个并发客户端,并且可能无需重新启动即可更新脚本服务器。首选的脚本语言是C#。

The invokes comes from multiple concurrent clients and potentially the scripting may be updated without the need to restart the server. The preferred scripting language is C#.

Roslyn不是一个好的解决方案,因为它为每个编译创建了一个真正的程序集(字节代码),或者至少我无法强制Roslyn作为解释器和不是编译器。在2000/3000调用之后,应用程序抛出"内存不足"的情况。例外
并且服务崩溃。我尝试重新使用生成的程序集,直到有新的脚本版本可用,但在真实的生产环境中可以添加许多新脚本。

Roslyn is not a good solution as it creates a real assemblies (byte code) for each compile or at least I was not able to force Roslyn as interpreter and not as compiler. After 2000/3000 calls, the application throws an "out of memory" exception and the service crashes. I have tried to reuse the generated assemblies until a new script version is available, but in a real production environment many new script could be added.

我见过Jint intepreter似乎符合我的请求但它是Javascript语言,并且它不支持脚本代码中应使用的现有框架方法的
out 参数。

I have seen Jint intepreter that seems matching my request but it is Javascript language and it does not support the out parameters of existing framework methods that should used inside the scripting code.

任何建议我们非常感谢能够解答合适的翻译。

Any suggestions is appreciated to address the right interpreter.

Maurizio Romano

Maurizio Romano

推荐答案

查看
CSX
。从来没有自己使用它,但这是为我们设计的。

Take a look at CSX. Never used it myself but that is what is designed for.

此外,您可以通过在单独的应用程序域中运行脚本来解决内存问题。对于沙盒用途,无论如何它可能是更好的选择。当然,你必须进入编组对象,但这就是大多数脚本库
的工作方式。

Also, you can work around the memory issue by having the scripts run in a separate appdomain. For sandboxing purposes it is probably a better option anyway. Of course then you have to get into marshalling objects but that is how most scripting libraries work.


这篇关于C#解释器没有动力学或新组件的生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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