Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Generate and Execute Dynamic Script With .NET  : Page 3

Use the System.Reflection classes in the .NET Framework to write, execute, and interact with code you write dynamically at run-time from your applications.


advertisement
The JScript scripting language, based on a Microsoft implementation of the ECMA 262 language, has been overhauled and improved to support integration with the .NET Framework. The improvements include support for compiled code, type and type less variables, cross-language integration, and access to all of the .NET Framework classes and resources. In addition, there are enhanced performance features supporting faster script execution that can be used in conjunction with ASP.NET. All of these enhancements are geared towards providing a more flexible and robust environment for developing high performance applications with the .NET Framework while leveraging scripting technologies.

Here's how to create and compile a simple class. First define a class in JScript.NET with a simple member function that returns a string, for example:

// Jscript.NET code class MyClass { function GetString() : string { return "MyString"; } }

Next, compile the class into a .NET assembly. You can use JScript compiler jsc.exe to compile the code using the command line. For the example class, you would write:

jsc.exe /target:library MyClass.js

The preceding command creates a file named MyClass.dll, which you can then reference just like any other .NET assembly. Precompiled script code provides a huge performance advantage over traditional script interpretation, and in addition, you can interoperate with the JScript.NET classes from any other .NET language.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap