Referencing the assembly during development and using it during run time are different things. When you build the solution, the referenced assembly should be there to allow the build. If you deploy it and place it in the same directory as the referencing assembly, it will work just fine.
What to do if you don't want to deploy this assembly but you want to require that it should present in the target system, by some reason (by the way, why?!)? Environment variable as such won't help you, but in principle, you can use it during installation.
There are generally two ways of resolving the referenced assembly. The first one is: you can require it to be placed in GAC. Everyone can do it using cagutil.exe. How to require it is your problem, but if it is formally submitted to GAC (you need to sign it just for this purpose as the strongly named assembly is required), it will always be resolved properly. It also helps unique versioning (strong naming, not GAC itself).
Another way of resolving the referenced assembly is the application's standard configuration file. Here is the sample using assembly location
probing:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath=".\MyLibraries\MyAssemblies"/>
</assemblyBinding>
</runtime>
</configuration>
If you don't use this configuration file, the application will run, and the referenced assembly should be in the same directory. If you add this file and name it "myApplication.exe.config" (where "myApplication.exe" is the name of the main executable module of the application entry assembly), the run-time will try to find the required referenced assembly in the sub-directory specified by
privatePath
, in this example, relative to the location of this executable module. This way, you can reuse a set of referenced between applications located in different directories. You can develop a deployment procedures writing appropriate configuration files with required locations of directories for probing, depending on user's optional parameters or other factors.
—SA