Thread: dll reference

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    184

    dll reference

    Hello everyone,

    My coworker and I are developing an application in C# that has to reference a .dll. When we add a reference to the dll in the Windows > System32 directory, a copy of the dll acturally gets placed in the folder with the executable. It runs fine until you remove the dll from the folder. The question I have is when distributing the program to other computers, how can it be done to where the dll does not have to be in the same folder as the executable. I get errors if I place the dll in the System32 folder and the executable on the c:. The only way it will work is with the dll in the same folder as the exe. How can that be changed??????????????????

    Thanks,
    Kendal

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    If you add a reference to the windows path containing the dll and set the CopyLocal property of the reference to false, you should not need a local copy of the dll. If there are still errors, post some of them.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    184

    Error

    We set the copy local property to false and the path of the reference is pointing to the system32 directory. When he copies the executable to my machine and I copy the dll to the System32 directory and run the program, I get the following error:

    Just-In-Time Debugging Window
    An exception 'System.IO.FileNotFoundException' has occured in rtfview.exe.

    It gives me a list of debuggers and asks me if I want to debug. When I place the dll in the same folder as the exe, it runs just fine. Is there a compilation setting that I am missing???????? What else could be the proglem????????

    Thanks,
    Kendal

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    uhm... sorry for the previous reply, I seem to be a bit mentally challenged today *g*

    You don't put global dlls in the windows directory with .NET, you put them in the GAC ( global assembly cache ).

    Have a look here.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Registered User
    Join Date
    Feb 2003
    Posts
    184
    That is great!!!!!!!!!!
    I got it to work, thanks to you.
    So in .NET, any referenced DLL has to be in the global assembly cache. Just a few more questions:

    1)What do I do if this little program is going to be used on a machine that does not have the .NET framework??? Install it???

    2)How would I go about having the DLL installed into the global cache on every machine that uses it????? That would be included in the install program wouldn't it????? Where can I learn about that????? Because creating strong names and then compiling the assembly and then adding it to the GAC is a lot of work to do on each machine.

    Any suggestion will be greatly appreciated,
    Thanks,
    Kendal

  6. #6
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    1) Yes, you need to have the .NET Framework ( Redistributable = ~20 MB ) installed on the target machine.

    2) If you use Visual Studio, try do create a setup project. I never copied dlls to the GAC with it, but the other tasks like start menu entries and desktop shortcuts were so easy, there might be an easy way to copy to the GAC at install time, too.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  7. #7
    Registered User
    Join Date
    Jun 2003
    Posts
    4
    Look at the commandline tool 'gacutil.exe'

    this tool takes care of (un)registering .NET Assemblies to and from the GAC (Global Assembly Cache)

    This tool should be available also on machines with just the .NET runtime, so your setup program could simply call this tool to register the Dll's.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 04:42 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM