JScript .NET without compilation?

I have written a script that uses the .NET framework for IO, Hashtables, Event Log entries, etc. I've been using jsc.exe to compile the script so that I can use the CLR debugger. Now that I have a final, debugged, script, I cannot run the .js file as a standalone, interpreted, script.

At first, it objected to the import statements (such as System.Diagnostics, System.IO, etc.) so I removed the import statements and fully specified all of the relevant classes in those namespaces. That did not seem to work. In fact, once I removed all of the import statements, jsc.exe gave me a "Variable 'System' has not been declared" at the first reference in the file (a reference to System.Collections.Hashtable).

This left me wondering: is it possible to use the .NET framework from an interpreted (not compiled) JScript .js or .wsf file?

If it is possible, could someone recommend to me either a URL or a set of rules I must follow to do so?

Thanks!

-a.

[960 byte] By [arttaylor] at [2008-2-13]
# 1
JScript.NET and JScript run under entirely different runtimes and there are many extensions to the JScript.NET language over the JScript language.

JScript is purely a script engine that runs under a script host like wscript.exe or cscript.exe, or even Internet Explorer.

JScript.NET is a JScript-like language that can call into the .NET Framework and other assemblies thanks to the CLI and must either be compiled or evaluated using the eval() function as called from another JScript.NET assembly.

So, from your example where "import" causes a syntax error, that's because the JScript engine doesn't understand "import".

If you want to debug your JScript scripts there are tools. Visual Studio since at least version 6.0 can debut Windows scripts including JScript and VBScript, and there is also the script debugger available from http://www.microsoft.com/downloads/details.aspx?FamilyID=2f465be0-94fd-4569-b3c4-dffdf19ccd99.

HeathStewart at 2007-9-8 > top of Msdn Tech,.NET Development,JScript for the .NET Framework...

.NET Development

Site Classified