Click here to Skip to main content
16,016,580 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Professionals,

My project is a C# windows application to which a dll is added as reference.

When deployed the executable goes to the c:\ of the local machine at the client place.

If I have to make changes in the dll, it will not be appropriate to copy the updated dll to the local machine. I have to copy somewhere in the server and have my project refer it from there.

In Short: I want to keep the executable at the workstation and the dlls in the server and set the path somewhere for my project to refer.

What I have tried :

1. In the dll properties made 'Copy Local' as false and changed the path to the location I want to.
2. Tried the <runtime><probing> element in the App.Config

Please suggest a right method. Thanks in advance.
Posted

1 solution

Assuming your server is accessible from all the client computers, you can make use of codebase element in app.config file of your application. Here[^] is MSDN page that tells how to specify the assembly location. Following is the example configuration from MSDN (in case the link is dead in future).


XML
<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
         <assemblyIdentity name="myAssembly"
                           publicKeyToken="32ab4ba45e0a69a1"
                           culture="en-us" />
         <codeBase version="2.0.0.0"
                   href="http://www.litwareinc.com/myAssembly.dll"/>
       </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>


Note that the path to DLL file is a URL and to point it to a server somewhere in your network, path should look something like this: file://[IP address or name]\folder\filename.dll

Also note that this element works differently for strong named assemblies and private assemblies. Here is an excerpt from MSDN:

Quote:
If the assembly has a strong name, the codebase setting can be anywhere on the local intranet or the Internet. If the assembly is a private assembly, the codebase setting must be a path relative to the application's directory.
 
Share this answer
 
v3
Comments
Priya-Kiko 6-Jan-16 3:57am    
Thanks for your quick response.

If I have have more than 1 dll then should there be an entry for each and every dll and is the publicKeyToken mandatory. Please advise.
dan!sh 6-Jan-16 4:04am    
Yes you will need assemblyidentity node for all the references you have. You can skip public token AFAIK.
Priya-Kiko 6-Jan-16 4:16am    
Thank you, I will try it and get back.
Priya-Kiko 6-Jan-16 4:59am    
I tried this code in App.Config for my 2 dlls. acc.dll and adm.dll. It doesn't seem to work. Have I got the syntax right. Please advise. Thanks. (Not able to submit with tags here.)

runtime
assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"
dependentAssembly

assemblyIdentity name="acc"
codeBase href="h:\mydlls\acc.dll"

assemblyIdentity name="adm"
codeBase href="h:\mydlls\adm.dll"

dependentAssembly
assemblyBinding
runtime
dan!sh 6-Jan-16 5:55am    
Check the updated response.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900