Using dll references from a folder

JayGee 181 Reputation points
2021-09-29T22:27:47.607+00:00

I can use Add Project Reference -> Browse and load my dll into Assemblies and use the reference.
However, I have several dlls in several directories, and I am wondering if there is a way to references these from their root directory.
So that I just need to type using RootDirectory.SubDir.Ref;

I saw this done in an XNA project, by adding to the .csproj file...

<ItemGroup>
    <Reference Include="DigitalRune">
      <HintPath>..\..\DigitalRune\References\XNA\Windows\DigitalRune.dll</HintPath>
...
</ItemGroup>

I tried to do that, with my project, but got a message about the project not being able to handle that change, and something about data lost.
I figured that's because the XNA format is older.

How can I accomplish the above?

Developer technologies | C#
{count} votes

1 answer

Sort by: Most helpful
  1. jordi van Dijk 1 Reputation point
    2021-10-06T09:03:37.367+00:00

    It's only possible to reference one dll at a time, so what you are trying can only be achieved by matching the namespace of all your dll's to one and the same namespace. this way you can use one include. so for instance you change all namespaces to MyCompany.BaseNameSpace you can include like this:

    using MyCompany.BaseNameSpace;
    

    I personally don't see why you would want to, your libraries are separate for a reason right? So I recommend adding them and including them separate as well.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.