I have somes difficulties to include the dll that I am creating to a project.
Here is the situation :
- A.dll (My dll) works with B.dll & C.dll (whose come from NuGet)
- ProjectWPF
I put the A.dll (from the bin/Release) of the A.dll project, to the ProjectWPF root folder. Then I add new reference to the copyied dll.
When doing that, the execution fails, saying that some dlls are missing (B & C dll). The thing is that it only works when I am installing B & D dll from the NuGet in the ProjectWPF. And, of course, I don't want to do that each time I am including A.dll to a project.
I think that there must be a way to simply include a dll (which works with other dlls), by simply adding THAT dll, and not also the other.
Hope you understand my problem. Thank, and waiting for your help.
LocalCopy is already true on the reference
I have somes difficulties to include the dll that I am creating to a project.
Here is the situation :
- A.dll (My dll) works with B.dll & C.dll (whose come from NuGet)
- ProjectWPF
I put the A.dll (from the bin/Release) of the A.dll project, to the ProjectWPF root folder. Then I add new reference to the copyied dll.
When doing that, the execution fails, saying that some dlls are missing (B & C dll). The thing is that it only works when I am installing B & D dll from the NuGet in the ProjectWPF. And, of course, I don't want to do that each time I am including A.dll to a project.
I think that there must be a way to simply include a dll (which works with other dlls), by simply adding THAT dll, and not also the other.
Hope you understand my problem. Thank, and waiting for your help.
LocalCopy is already true on the reference
Share Improve this question edited 2 days ago ASh 35.7k9 gold badges65 silver badges87 bronze badges asked 2 days ago mr_noisettemr_noisette 34 bronze badges New contributor mr_noisette is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 4- 1 "How to correctly include a created DLL, which includes other DLLs, in a project?" - you don't. You use NuGets. As you already do. Now in your WPF Project, you can have a ProjectReference or you can yourself choose to create your own nuget. Mind that there is the possibility to also create "private" nugets and -sources. (Private to your company/Orga or even Project) – Fildor Commented 2 days ago
- 3 You shouldn't "put" dlls yourself, rather reference class library in solution and setup its depedencies, the rest (copying dlls into output folder) will be done automatically by publishing. – Sinatr Commented 2 days ago
- See also: Manage references in a project <- If you do it correctly, as Sinatr says, you shouldn't need to copy around dlls manually and explicitly at all. – Fildor Commented 2 days ago
- You can't imagine how the "ProjectReference" solved my problem... A huge thank to both of you! – mr_noisette Commented 2 days ago
1 Answer
Reset to default 2I mostly use 3 ways to add references. All are available as context menu options to the "dependencies" node for your project in the solution explorer:
Project references
Put Project A and ProjectWPF in the same solution, and add a project reference from ProjectWPF to Project A. This should automatically include all transitive dependencies.
Nuget references
If Project A for some reason need to be in another solution/repository you can still deploy it from a local nuget server. This require a bit of work to setup such a server, and likely a continuous integration server to build and deploy the packages. But it is feasible for even fairly small companies. You also need to add your nuget server as a package source in visual studio.
It is also possible to use a simple folder as a package destination/source. But I would not expect this to work well if you have more than a few packages.
This method should also include all transitive dependencies, but I have found it not quite as reliable as project references.
Assembly references
This is mostly useful for third party dlls that rarely change. Add the dll, and all of its dependencies, to a folder as part of your repository, and add Assembly references to each. For native dlls you can add them as simple content files with the "copy to output directory" property. Note that this makes updates a pain, so is more of a last resort option.
With this option you need to manage any transitive dependencies yourself.