fsi.exe大会:任何人都知道如何嵌入它? [英] fsi.exe Assembly: Anyone know how to embed it?

查看:133
本文介绍了fsi.exe大会:任何人都知道如何嵌入它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很长一段时间的读者,第一个问题。 fsi.exe是.NET可执行文件,因此包含它自己组装完成所有的美味方法和诸如此类的东西FSI用于执行F#脚本。

Long time reader, very first question. fsi.exe is a .NET executable and therefore contains its own assembly complete with all the yummy methods and whatnot fsi uses to execute F# scripts.

看着在.net反射的组件(选择你的类,但壳牌就是最好的例子)揭示了一堆垃圾*名字看起来像装饰的C ++函数(比如,从依赖沃克)。顺便说一下,略跑题了,F#组件编译大致相同的方式,有很多垃圾*名字,这使我想到fsi.exe写于F#,也许证明,可用性的?

Looking at the assembly in .NET Reflector (pick your class, but Shell is the best example) reveals a bunch of garbage* names that look like decorated C++ functions (say, from Dependency Walker). Incidentally and slightly beside the point, F# assemblies compile in much the same way, with lots of garbage* names, which leads me to think fsi.exe was written in F#, perhaps as a proof-of-usability?

总之,这里是我的问题:有没有人深入研究fsi.exe并知道如何将它嵌入到.NET应用程序?因为我想用F#作为脚本语言,但程序编译成(惊喜)程序和脚本必须由fsi.exe,这是不能接受的我的域名被执行(我需要一个持久的VM)。我不指望一个如何对使用fsi.exe指导,但我很好奇,想知道是否有人曾与它,如果是这样,你有什么发现它是如何工作?

Anyway, here's my question: has anyone delved into fsi.exe and figured out how to embed it into a .NET application? Because I'd like to use F# as a scripting language, but programs compile to (surprise) programs, and scripts must be executed by fsi.exe, which is unacceptable in my domain (I need a persistent VM). I don't expect a how-to guide on using fsi.exe, but I'm curious to know if anyone has played with it and, if so, what have you discovered about how it works?

感谢您的时间。

*垃圾在一个偶然一瞥。显然,他们被格式化为是引擎盖下方的特殊原因这种特别的方式。

* Garbage at a casual glance. Obviously they are formatted this particular way for a particular reason that is beneath the hood.

推荐答案

据我所知, fsi.exe 不公开,你可以使用任何API将它嵌入到你的应用程序(如实施脚本)。我认为主要有两种选择:

As far as I know, fsi.exe doesn't expose any API that you could use to embed it in your application (e.g. to implement scripting). I think there are essentially two options:

  • 如果您希望使用现有 fsi.exe 直接,唯一的办法就是使用启动它的.NET 进程类,并用它在某种程度上进行通信。这应该是可行的 - 你可以使用标准的输入命令发送到该过程。要读取输出反馈,你可以使用标准的输出,但是这给你的信息有限。或许,这将有可能使用.NET远程处理的 fsi.exe 和您的应用程序(在FSI脚本加载的情况下将信息发送到通过Remoting您的应用程序,例如你的对象进行沟通)。

  • If you want to use existing fsi.exe directly, the only way is to start it using .NET Process class and communicate with it somehow. This should be doable - you can send commands to the process using standard input. To read output back, you can use standard output, but this gives you only limited information. It probably would be possible to use .NET Remoting to communicate between fsi.exe and your application (e.g. your objects loaded in script context in FSI would send information to your application via Remoting).

另一种方法是使用F#的开源发布并修改 fsi.exe 揭露你需要作为一个API的所有信息。这需要更多的努力,以了解如何 fsi.exe 的作品,但它应该是可行的。你可能不需要那么多增加 - 由FSI保持状态包含像全局变量。

Another alternative is to use the open-source release of F# and modify fsi.exe to expose all information you need as an API. This requires more effort in order to understand how fsi.exe works, but it should be doable. You probably don't need that many additions - the state maintained by FSI contains things like global variables.

关于许可证 - 你可能无法使用 fsi.exe 随Visual Studio中。我不知道关于 fsi.exe 自带的CTP版本。从源代码(可这里)编译它肯定会有很好(因为它有开源版本)。

Regarding the license - you probably cannot use fsi.exe distributed with Visual Studio. I'm not sure about fsi.exe that comes with the CTP release. Compiling it from source (available here) will be definitely fine (because it has open-source release).

这篇关于fsi.exe大会:任何人都知道如何嵌入它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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