質問

I've been playing with a c# app that hosts IronPython, IronRuby, and (hopefully) PowerShell. Since IronPython and IronRuby were completely built on the DLR, the API for using them is pretty much identical.

IronPython.Hosting.Python.CreateEngine()

and

IronRuby.Ruby.CreateEngine()

both create instances of a Microsoft.Scripting.Hosting.ScriptEngine. Is there any hope of coercing PowerShell 3.0 to create a ScriptEngine? I have not been able to find much on the subject, other than PowerShell 3.0 seem be built on the DLR more than the previous version was (see http://huddledmasses.org/powershell-3-finally-on-the-dlr.

It doesn't appear that you can cast a PowerShell engine created with the following to a ScriptEngine.

System.Management.Automation.PowerShell.Create()

I suspect that if I really want to handle PowerShell through the same API I need to create my own ScriptEngine that wraps the PowerShell host.

役に立ちましたか?

解決

PowerShell V3 does indeed use some of the DLR, but only parts that shipped in the .Net Frameworks V4. The DLR project had many useful apis that were not included in .Net, e.g. Microsoft.Scripting.Hosting.ScriptEngine.

If PowerShell wanted to implement the ScriptEngine apis, PowerShell would have had to ship those apis as part of PowerShell. The PowerShell team wasn't willing to take ownership of those apis.

So you are correct in assuming you need to wrap PowerShell with your own code if you want to implement ScriptEngine.

他のヒント

PowerShell works with dotnet assembly and is very interesting when you have a administrator profil and you want to make advanced instructions.But you are a developper so why wrapping PowerShell, you can access all dotnet assembly from your code.It is better to code what you want instead of wrapping PowerShell Best regard

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top