Reputation: 3506
I'm adding my dll
file to my reference and set Copy local to true
Everything is OK and after I build application, my dll
added to output folder
Now my question is how do Ι change the local path?
For example:
my application path is C:\myproject
, I want to put dll
into C:\myproject\libs
How can I set dll
path to {applicatonpath}\libs
NOT {applicationpath} ?
Upvotes: 1
Views: 7223
Reputation: 299
When you compile you project, visual studio will put everything that has been compiled and set to copy locally to the "output folder", which depends on your current compile configuration. If you are compiling in Debug mode then this folder will be:
c:\your_solution_path\your_project_path\bin\Debug
If you use Release mode, it will be:
c:\your_solution_path\your_project_path\bin\Release
However, sometimes we reference a lot of assemblies (DLLs if you will) and those assemblies have dependencies of their own. In order to make everything "point and click" for our convenience, we must tell visual studio how we would like it to act for a particular project build.
So, as TotPeRo said, you should go do project properties and use the functionality of Pre-build
and Post-build
events. As the name suggests, Pre-Build
happens before the actual build, while Post-Build
takes place immediately after it. Please refer these links for further information: link1 and link2.
Lets assume the following scenario:
In order to compile this, the compiler is smart enough to determine, that Project B should be compiled first. If everything checks, the project is compiled into ProjectB.dll. Then, the compiler proceeds to compile Project A. It check all the dependencies and finds out, that you have already compiled Project B (which is a dependency for Project A) and that it can continue. Everything is then copied to the output folder (bin/Debug or bin/release) and should be in working order.
However, during runtime, something goes wrong and the application crashes. You find out, that Project B does not have the appropriate library to work with (namely MatLab libraries). And then you conclude, that MatLab should be included in the bin/debug (or bin/release) folder at compile-time. Since the MatLab library is a dependency library for Project B but not for Project A, it does not get copied and hence the exception. You can mitigate this behavior with the aforementioned Pre and Post-Build events. You can tell the Visual Studio that you want it to manually copy MatLab.dll to the output folder when it is doing a compile. This comes super handy when you come into situations like these. Build events can also trigger a lot of other things so be sure to check it out. I'm using this a lot and it's a time saver at least.
Upvotes: 2
Reputation: 6791
in post-build event on visual studio go to properties in your project and add this:
copy "c:\pathtolibrary\bin\debug\namelibrary.dll" "$(SolutionDir)\bin\Debug\libs"
Upvotes: 1
Reputation: 306
in the Visual Studio you can go Project > [project name] Properties > Reference Path change the path/create folder or else you want First make folder lib new project source code then use relative address
Upvotes: 2