JAL Computing

C++COMProgramming .NET Mac Palm CPP/CLI Hobbies

 

Home
Up

Q.  How do I install the .NET Framework runtime on another desktop?

A.  The following link describes how to distribute the runtime using Dotnetfx.exe, the .NET Framework redistributable package.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetdep/html/vsredistdeploy.asp?frame=true

Q.  Why do I need to declare "import System" to use System.Console.WriteLine?

A.  The "import" key word in JScript does more than just allow the use of partially qualified names in the System namespace. Here is a post from Peter Torr:

"import" does four things in JScript:

1) Alerts the compiler to the existence of the namespace
2) Allows unqualified access to the classes in the namespace
3) Adds a namespace object to the program
4) Automatically references the related assembly (if autoref is on -- see
help for more info).

> "The import statement acts as a reference to a namespace--it does not
> actually load the namespace's corresponding code"

This is correct. It does not cause the "namespace" to be loaded (in .NET, a
namespace is not an object; it is just a bit of text you can stick in front
of a class name). You still need to make the code that contains the needed
classes available to the compiler, which is done via references. If autoref
is on, the compiler will try and reference the correct assemblies for you
automatically.

In C# you can say:

System.Console.WriteLine("Foo");

even if you haven't said "using System". This is because C# knows that
"System" must be either a class or a namespace. If you say "using System",
then you can just write:

Console.WriteLine("Foo");

In other words, all "using" does is create shortcuts for the developer.

In JScript .NET, you can't just say:

System.Console.WriteLine("Foo")

without saying "import System" because JScript cannot guarantee that
"System" will be a class or namespace at runtime. It could be an expando
object or a host-injected object or an eval-ed variable or anything. The
import statement lets JScript know that the name "System" refers to a
namespace.

You can use fully qualified class names without importing their namespaces
if they are used in type contexts (basically, after a colon in a variable
declaration or function parameter list) because in this case it must be a
compile-time constant -- either a namespace or class.

Peter

--
Peter Torr -- [email protected] -- JScript .NET / VSA Runtime

 

TestMenu1 

Send mail to [email protected] with questions or comments about this web site. Copyright © 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 © 
Last modified: 08/04/09
Hosted by www.Geocities.ws

1