P1: JDT
WL040C-44 WL040/Bidgoli-Vol III-Ch-51 June 23, 2003 16:33 Char Count= 0
MIGRATING FROMVBSCRIPT TO THE.NET FRAMEWORK 631of the class to be exposed, and calling RSDispatch. A
generic Java applet (Rsproxy.class) is used as a commu-
nication conduit to convey client-side script requests to
the IIS Web server, which then invokes the ASP page
containing the method being called and responds to the
applet, which then passes the result of the call back to the
client-side script. The client-side call can be made syn-
chronously (i.e., locks the Web browser until response is
received) or asynchronously (i.e., allows client-side script
processing to continue, calling the application back when
the result is ready). Examples and more details about
how remote scripting works are available on the Microsoft
MSDN Web site (Microsoft, 2002a) under Using Remote
Scripting. It should be noted, however, that remote script-
ing is functionally a precursor to what is called in the .NET
framework Web services. As such, remote scripting will al-
most certainly be supplanted eventually by technologies
such as .NET Web services and the more generic simple
object access protocol (SOAP).Windows Script Components
Windows Script Components are a generic, object-based
way to encapsulate script fragments and modules. The
roots of Windows Script Components go back to ear-
lier versions of VBScript, but in their present form they
are supported as of VBScript version 5. Windows Script
Components are implemented through the Microsoft
Script Component Runtime Dynamic-Link Library (i.e.,
SCROBJ.DLL, which ships with latest version of VB-
Script). This library includes intrinsic object interface
handlers suitable for use with IIS scripting host (i.e., ASP),
Internet Explorer scripting host (i.e., Dynamic HTML),
and standard COM Automation hosts (e.g., WSH) and
is extensible. In essence, applications, including other
scripts that want to make use of your Windows Script
Components access your components through the Script
Component Runtime Library. Your Windows Script Com-
ponents themselves (a typical file extension is .wsc) are
simply XML files that contain your script in combina-
tion with XML elements that describe your component,
including which interface handler is to be used, to the
script component run time. The top-level XML element
of a Windows Script Component file is <package>, which
in turn contains one or more <component> elements. As
appropriate <component> elements may contain any of
the elements listed in Table 3.Script Encoding
Being able to modularize and reuse script has created a de-
mand for ways to protect the integrity of script fragments
and to help protect their potential value as intellectual
property. Toward this end Microsoft has introduced the
“Script Encoder” utility, a simple command line tool
(SRCENC.EXE) downloadable from Microsoft that can
be used to encode VBScript files for use with script in-
tended for the WSH, the IIS scripting host (i.e., ASP),
and the Internet Explorer scripting host. The Microsoft
Scripting Runtime Library provides the utilities used by
scripting hosts/scripting engines to decrypt the encoded
script. The SCRENC utility is invoked with command line
arguments specifying optional switches (e.g., whether to
provide diagnostic output during encoding), the input file
name (i.e., file to be encoded), and output file name (i.e.,
file containing encoded script). SCRENC will encode both
VBScript and JScript sources. Language attribute values
on any <script> elements containing encoded script and
ASP page @Language directive values are automatically
changed to “VBScript.Encode” or “JScript.Encode” as ap-
propriate. Script authors must identify the fragments of
script in the input source file that they want encoded by
use of an embedded comment marker immediately be-
fore each segment of script to be encoded (e.g.,∗∗Start
Encode∗∗). Script encoding is further described, including
examples, on the Microsoft MSDN Web site (Microsoft,
2002a) under Scripting, Windows Script Technologies,
Script Encoder (Scripting Runtime Library).MIGRATING FROM VBSCRIPT
TO THE .NET FRAMEWORK
.NET Programming Language Environment
The Microsoft .NET framework represents a major reengi-
neering of Microsoft’s approach to support for applica-
tion development and implementation. .NET introduces
a new metalanguage called Microsoft intermediate lan-
guage (MSIL), a just-in-time (JIT) compilation scheme,
and a new common language run time (CLR) for the Win-
dows platform. The .NET framework continues support
for scripting (since beta version 2), but the fundamental
nature of script implementation under .NET has changed
such that it is no longer necessary to maintain VBScript
as a separate language distinct from Visual Basic. VisualTable 3Allowed Child Elements of Component Element in WSC FilesElement Comment
<registration> Containing information like ProgID, as required for the COM Automation interface handler.
<public> Describing publicly accessible properties, methods, and events associated with your component.
<implements> Specifying script component runtime interface handler for your component.
<script> Containing the VBScript that implements the logic of your component.
<object> Creates an instance of an external object for use by your script.
<reference> Links to an external type library.
<resource> Containing declarations and initialization for values used in your script that you would rather
initialize externally to the script itself.
<comment> Ignored during component parsing and execution.