Referencing dlls in my c#project

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

Guest

Hi there. Im developing a c# app and i have a solution with some projects:
the main project which generates the executable file and some other projects
which some of them im compiling generate dll's which my main project needs to
run.
When i compile a dll project it generates the dll it implements. Then i take
that dll and put it in the directoory where my main app executable is. Then i
go to my main project and add a reference in it to that dll which i have put
in its directory.
The problem? Mainly that this is not too adecuate because for example when i
go to other computer and try to execute the program instead of the dll being
in the same directory as the app executable the project was configurated to
search the dll in a complete route which now in the other computer culdnt be
the same as in my computer for example.
Anyone knows a tutorial to teach you how to manage the dll references or
your project references to avoid this kind of problem? Anyway if i want to
make an installer for my application its referemnces couldnt be relative to
my machine specific routes , they have to be more general and be dependent
the inistallation directories i choose. Anyone knows how to do this??
I dont know if i have explained myself correctly, sorry if i haven't.
Thanks
 
Hi,

First of all, stop copying DLLs from one directory to the other to compile
other projects. It's possible in nearly every cases to compile a complete
solution from zero with just "regenerate solution" menu click, as far as you
took the time to prepare for it.

1)In your case : we'll name the target directory for your dll(s), DLL_PATH.
you have to let the files in this path (destination path), and reference
them FROM THIS PATH in the other project who need to have the reference.
Choose to make a local copy of the DLL in the property page of references.
2)Right clicking in your solution under VS explorer will drop down the
context-menu. You have two very interesting option in it (dunno the correct
transalation but..) where you can "manage dependencies" and "view compilation
order" for your entire solution. If you setup your solution well, it'll build
in one click.

I'm building a solution with 14 projects with a lot of references between
each of them. Add been tricky to setup cause of DLL doing more than 64K. You
have to know a DLL doing more than 64Kb will be kept in memory and it won't
be possible to be reference more than ont time from the same directory. You
need then to have different targets path for the projects calling this DLL.

Hope I'm at least as clear as you were ;) and it'll be helpfull for u.

Sebastien
 
Don't use a reference to the DLL. Include the other project in your solution
(you can include an project into many solutions), and reference the project
from the other project. It will optionally build the project and copy the
DLL into the correct bin folder when you build, run, or debug.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

If the truth hurts, wear it.
 
I pass over referencing project in place of DLL without seeing it.

Thanks, I'll use it in own solution, sounds it'll be helpfull.
 
Back
Top