sharing variables between powershell and C#
Question: I am trying to build a document assembly application in .Net that will allow
rules and conditions to be embedded within the document fragments, presumably
using some kind of scripting language (and I don't really want to invent my
own scripting language)

I need the ability for the c# code to invoke the scripting language and vice
versa, but importantly I also want them to be able to share arbitrary data
structures by reference (not just passing a couple of strings back and forward
by value)

Can I do this with powershell or do I need to use a DLR language such as
IronPython? Come to that, are there other advantages of using a DLR language
which mean I should use DLR anyway?

Andy


Answer: I think [this
article](http://www.codeproject.com/KB/cs/HowToRunPowerShell.aspx) is exactly
what you're looking for (for Powershell, anyway).

Using a DLR language might bring the bits of code you'll be executing a little
bit closer to home. Invoking Powershell from a .NET app executes on a new
thread according to the above article.

In any case, I would personally be leery of executing random bits of any
scripting language without defining a subset of allowed commands and
validating the input against that.

