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??????????????????
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.
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????????
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.
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,
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.
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.