reference a dll in GAC from command line

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a doubt. I would greatly appreciate it if somebody could help me out.

I created a dll(xyz.dll) and installed it in the GAC using GACUtil.exe. Now,
I want to use the dll for my application(abc.exe). Both the compilation and
running of the application is done thru command line.

In this case, how should I refer to my xyz.dll in the GAC?
Should I just say,
c:\ > csc /r:xyz.dll abc.cs (this is not working – should I set my PATH
variable?)
or
c:\ > csc /r:"path to gac"/xyz.dll abc.cs (this works – but is this right
approach?)

And when I try to run the exe without the dll in the current directory it
complains about the missing library.

Any help is appreciated. Thanks

-Praneetha
 
Leo2005 said:
Hello,
I created a dll(xyz.dll) and installed it in the GAC using GACUtil.exe.
Now,
I want to use the dll for my application(abc.exe). Both the compilation
and
running of the application is done thru command line.

In this case, how should I refer to my xyz.dll in the GAC?
Should I just say,
c:\ > csc /r:xyz.dll abc.cs (this is not working - should I set my PATH
variable?)
or
c:\ > csc /r:"path to gac"/xyz.dll abc.cs (this works - but is this right
approach?)

The GAC is a deployment mechanism. At development time, you should have a
local copy laying around somewhere that is not in the GAC. (Similar to
VS.NET's CopyLocal option for References).

However, if you really must reference directly from the GAC, I like your
second way. I don't see anything wrong with referencing your GAC path in
the build, other than maybe when the version changes and breaks your
reference.

To ease things, you can use environment variables to help reduce versioning
impact on your build process. For example, in a batch file or make file,
you could

set GAC=%SYSTEMROOT%\assembly\GAC
set MyXYZVer=1.0.5000.0
set MyXYZ=%GAC%\xyz\%MyXYZVer%__b77a5c561934e089\xyz.dll
csc /r:"%MyXYZ%" abc.cs

-- Alan
 
Thanks for clarifying, Alan.

Alan Pretre said:
The GAC is a deployment mechanism. At development time, you should have a
local copy laying around somewhere that is not in the GAC. (Similar to
VS.NET's CopyLocal option for References).

However, if you really must reference directly from the GAC, I like your
second way. I don't see anything wrong with referencing your GAC path in
the build, other than maybe when the version changes and breaks your
reference.

To ease things, you can use environment variables to help reduce versioning
impact on your build process. For example, in a batch file or make file,
you could

set GAC=%SYSTEMROOT%\assembly\GAC
set MyXYZVer=1.0.5000.0
set MyXYZ=%GAC%\xyz\%MyXYZVer%__b77a5c561934e089\xyz.dll
csc /r:"%MyXYZ%" abc.cs

-- Alan
 
Back
Top