[Mono-list] Specifying assemblies on mcs command line
Fri, 14 Jun 2002 12:46:49 +0200
On 06/11/02 murban wrote:
> When specifying assemblies on the mcs command line, sometimes the ".dll"
> extension is required, and sometimes it is prohibited. I'm not saying that
> the rules are "wrong" -- I'm saying that they're not entirely intuitive and
> that they are not clearly stated in the manpage.
> It's easiest to see the behavior with some examples. The examples assume that
> Qt.dll is found in /usr/local/lib:
Here, Qt is the assembly name, while Qt.dll is the assembly _filename_.
> > mcs -r Qt qhelloworld.cs
> Works. /usr/local/lib is searched by default.
Assembly.Load() is called: /usr/local/lib is in the default search path
of the runtime. The env variable MONO_PATH is used to search for the
> > mcs -r Qt.dll qhelloworld.cs
> Fails. Specifying the actual filename isn't allowed.
If you specify an assembly tha may loook like a filename, mcs uses
Assembly.LoadFrom(). Since there is no Qt.dll file, the loading fails.
At this point mcs uses the directories specified with the -L option, but
it adds the ".dll" extension. This is weird and the problem that most
likely confuses users, as you report below, too.
> > mcs -r /usr/local/lib/Qt qhelloworld.cs
> Fails. There is no file named /usr/local/lib/Qt
This should be expected in any case.
> > mcs -r /usr/local/lib/Qt.dll qhelloworld.cs
> Once one understand the behavior, it seems "obvious." However, when I first
> used Mono and "mcs -L /usr/local/lib -r Qt.dll qhelloworld.cs" would not
> work, I assumed that the "-L" flag was broken and that it was necessary to
> pass the full path to the assembly. It took a long time before it dawned on
> me to try simply "mcs -r Qt qhelloworld.cs."
My proposal is to change mcs to not add the dll extension if LoadFrom()
fails (or at least to add it only if it's not there already). This way
we could document better the behaviour of the -r and -L options.
-r takes either an assembly name or a filename. If given an assembly
name, the runtime tries to load the assembly from the runtime-specific
search paths (default path + MONO_PATH with the mono runtime, dunno what
the ms runtime uses). If given a filename, mcs tries to load the
assembly in the current directory and in the directories specified with
the -L option.
How does that sound?
firstname.lastname@example.org Monkeys do it better