3

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

1
  • any solution with full source code about it ? Commented May 29, 2012 at 12:35

2 Answers 2

2

I think this article 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.

Sign up to request clarification or add additional context in comments.

Comments

0

Powershell can instantiate and use C# (or any .NET) objects just fine. I've never tried having C# code invoke powershell commands, but I'd be surprised if it couldn't. That said, the DLR route is good too, and in fact there's examples in Ayende's DSL book http://www.amazon.com/DSLs-Boo-Domain-Specific-Languages/dp/1933988606/ref=sr_1_1?ie=UTF8&qid=1308063119&sr=8-1 that might be useful to you as well (even if you end up not using Boo, it's a good read).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.