5x1llz
5x1llz

Reputation: 303

.NET Project Reference: How to reference a dll via a referenced project?

Hope I'm asking this correctly:

I have a project

Projects.Client

I have my class library ( infrastructure stuff I use all the time )

Library

Assuming these are both projects, how can I do this from a class in the "Projects.Client"

using Library;

public class xxx
{
    public void DoSomething()
    {
        Library.SomeDll.DoSomething();
    }
}

SomeDll.dll is referenced in the "Library" project. "Library" is a reference in end client project "Projects.Client"

I know I could simply add SomeDll to the "Projects.Client" project but there are a number of items and I use them all the time. I'd like to be able to include the "Library" and somehow be able to reference everything within it(including raw code and dll's). Is this possible?

please note: I'd prefer not to write explicit wrappers for all the methods and the dll is static so I can not seem to get away with doing this in the "Library" project:

public static class WrapSomeDll
{
    public static extern SomeDll Dll();
}

Any inventive answers are appreciated, I might not even need dual references, wrappers e.t.c.

Upvotes: 4

Views: 4520

Answers (2)

Thomas Levesque
Thomas Levesque

Reputation: 292415

You just need to reference the project and add using clauses for the namespaces you want to use. There is no need to specify the name of the DLL

Upvotes: 0

John Saunders
John Saunders

Reputation: 161773

Sorry, that doesn't work. You need the reference to SomeDll in order to use its metadata in Project.Client. It's really as simple as that.

Keep in mind that references aren't just a matter of resolving symbols to addresses. This is a matter of pulling over the metadata (types) so that it can be used.

Upvotes: 2

Related Questions