Share DLL between projects

There are several projects in my solution. Each project refers to other projects. The dlls are quite large, and I do not want them to be included in the basket of every project that references it.

What are my options? Ideally, I would like to place them in one place and refer to them without having to include them in the bin folder for each project. The only place I can think of is the GAC. Are there any ideas / suggestions on how you did this?

Can sensing trajectories be used? Has anyone used this before / pointed me to a tutorial?

I tried the research paths, I get an error message when the application starts, is this configured correctly? I placed my dlls that I want to download from this path in the folder C: \ Projects \ myProject \ bin. And set the copy to false in the link

<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="C:\Projects\myProject\bin"/> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> </assemblyBinding> 

thanks

+4
source share
2 answers

I assume that you prefer disables CopyLocal when accessing assemblies in Visual Studio

Stages can be:

  • Open Solution Explorer
  • Right-click on a reference element (project or assembly)
  • Select Properties from the context menu.
  • Set CopyLocal to False (default is true)

Then the links will not be copied to your project\bin\debug etc.

UPDATE

You still need to copy your dependency to the same folder, or GAC, or probe pools to run your application.

Here's how .Net resolves assembly references.

You can refer to How to Runtime Locates Assemblies .

UPDATE 1

MSDN Build Location

Using the <probing> The runtime detects assemblies that do not have a code base by sensing. For more information about sensing, see "How to Runtime Locates Assemblies". You can use this element in the application configuration file to specify the subdirectories that should be performed during the search when searching for an assembly. The following example shows how to specify the directories that the runtime should execute.

 <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="bin;bin2\subbin;bin3"/> </assemblyBinding> </runtime> </configuration> 

The privatePath attribute contains the directories in which the runtime should look for assemblies. If the application is located in C:\Program Files\MyApp , the runtime will look for assemblies that do not specify a code base in C:\Program Files\MyApp\Bin , C:\Program Files\MyApp\Bin2\Subbin and C:\Program Files\MyApp\Bin3 . The directories specified in privatePath must be subdirectories of the application directory.

+1
source

You can add links to libraries only in the source folder only to start the project:

1) Right-click on the start of the project, Add "," Existing Item ". Or the combination of [Shift]+[Alt]+[A] in VS2010 with default values.

2) Change the selector type to " All files (*) ", find and select your library.

3) Change the "Add" selector to " Add As Link " and press it.

4) Select the link added to the project, and in the "Properties" window, set " Copy to Output Directory " to " Copy always ". Now, every time you create a solution, this library will be copied to the output folder of your startup project.

5) If you want to limit the copying of this DLL to the output of the project that uses it, right-click the link in this project, and in the properties window set " Copy Local " to false.

Effects:

The only place your dll link will be displayed will be your startup project output directory.

Disadvantages:

If you change your initial project, you will need to add all the links to it again.

The catalog of running projects in Solution Explorer becomes messy.

+1
source

Source: https://habr.com/ru/post/1481358/


All Articles