c# - Add reference to local folder -


i'm adding dll file reference , set copy local true

everything ok , after build application, dll added output folder

now question how Ι change local path?

for example:

my application path c:\myproject, want put dll c:\myproject\libs

how can set dll path {applicatonpath}\libs not {applicationpath} ?

when compile project, visual studio put has been compiled , set copy locally "output folder", depends on current compile configuration. if compiling in debug mode folder be:

c:\your_solution_path\your_project_path\bin\debug

if use release mode, be:

c:\your_solution_path\your_project_path\bin\release

however, reference lot of assemblies (dlls if will) , assemblies have dependencies of own. in order make "point , click" our convenience, must tell visual studio how act particular project build.

so, totpero said, should go project properties , use functionality of pre-build , post-build events. name suggests, pre-build happens before actual build, while post-build takes place after it. please refer these links further information: link1 , link2.

lets assume following scenario:

  • you have 1 solution.
  • that solution holds 2 projects (let's call them project , project b). project actual gui. project b helper project, compiles dll.
  • let's say, project b doing heavy matrix calculations, have include matlab libraries. note: project b uses these libraries.
  • project references project b can use calculated information b , show in gui in a.

in order compile this, compiler smart enough determine, project b should compiled first. if checks, project compiled projectb.dll. then, compiler proceeds compile project a. check dependencies , finds out, have compiled project b (which dependency project a) , can continue. copied output folder (bin/debug or bin/release) , should in working order.

however, during runtime, goes wrong , application crashes. find out, project b not have appropriate library work (namely matlab libraries). , conclude, matlab should included in bin/debug (or bin/release) folder @ compile-time. since matlab library dependency library project b not project a, not copied , hence exception. can mitigate behavior aforementioned pre , post-build events. can tell visual studio want manually copy matlab.dll output folder when doing compile. comes super handy when come situations these. build events can trigger lot of other things sure check out. i'm using lot , it's time saver @ least.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -