Question: Without using a WebBrowser control, how could I execute a JavaScript function, that is decoupled from any browser DOM dependencies, in a C# application? I am investigating implementing validation rules only once, for both server and client validation. See [this question](https://stackoverflow.com/questions/265343/automatically-duplicating-business-logic-on-web-client) for reference if you like. Are there any JS interpretor libraries I could use?

*Addendum:*
My goal here is to automatically deploy and invoke exactly the same validation logic on client and server, without communication between the two during the actual validation. So, ideally I would code my validation logic in JavaScript, and render that to the page. Alternatively, I could code my logic in C#, convert that to JavaScript using [Script#](http://projects.nikhilk.net/ScriptSharp/), and render that to the page. 

I don't want separate validation functions being maintained client and server side, and I don't want AJAX calls to server validation functions, and I don't want client only or server only validation.

Answer: 
This may help [A script host for C#/VB.NET/JScript.NET](http://www.codeproject.com/KB/dotnet/nscript.aspx) it uses built in classes within the Framework to execute script in VB, C# or JavaScript.

It uses the [CodeDomProvider](http://msdn.microsoft.com/en-us/library/system.codedom.compiler.codedomprovider.aspx) to execute the scripts, also check out [this](http://www.developerfusion.com/article/4529/using-net-to-make-your-application-scriptable/3/) article for a more complex example.
[Windows Script Host](http://msdn.microsoft.com/en-us/library/9bbdkx3k.aspx) (WSH) is a Windows administration tool. You can use *PInvoke* to activate it from *C#*. Recognizes an MS specific (and old) version of JavaScript.

WSH creates an environment for hosting scripts. That is, when a script arrives at your computer, WSH plays the part of the host — it makes objects and services available for the script and provides a set of guidelines within which the script is executed. Among other things, Windows Script Host manages security and invokes the appropriate script engine.