JScript .NET, Part III: Classes and Namespaces: Loading Assemblies - Doc JavaScript | WebReference

JScript .NET, Part III: Classes and Namespaces: Loading Assemblies - Doc JavaScript


JScript .NET, Part III: Classes and Namespaces

Loading Assemblies

When you specify /autoref- at the jsc.exe compilation command, there is no automatic association between namespaces and assemblies. You need to specify the assembly names explicitly. Use the /reference switch to do this. The syntax is simple:

/reference:file[;file2]

Since only one .exe file can be associated with a single application, your assemblies should be .dll files. In any case, when you compile with /target:winexe or /target:exe, do not pass to the /reference switch any assemblies created with /target:winexe or /target:exe.

When you reference an Assembly A which references another assembly (B), you may need to reference Assembly B as well, if Assembly B inherits from Assembly A, or if Assembly A implements an interface from Assembly B.

In order for the compiler to recognize types in an assembly, it needs to resolve these types first. You need to force the compiler to resolve these types by creating instances of these types, or by inheriting from these types.

Here is an example for using the /reference switch:

jsc /reference:metad1.dll;metad2.dll /out:out.exe input.js

The compiler searches for the assembly in the following order:

Here is an example using /lib:

jsc /lib:c:\ /reference:t2.dll t2.js

Next: How to specify member visibility


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: May 6, 2002
Revised: May 6, 2002

URL: http://www.webreference.com/js/column109/5.html