3

I have a Solution with 2 Projects...

Project A has Following A - Reference Third Party DLL (Which has a Class Called "Response") B - A Class which uses above DLL and returns the "Response" Object from a Method Called "GetResponse"

Now Project B Calls The Class From Project A Like This....

Response r = ProjectA.Class.GetResponse();

This will return a Error, because I dont have "Third party" reference in my project B.

I rather not ship my third party DLL to all of my other projects just to get the reference to Response Object from Third party DLL.

so is there anyway of doing it without having to add the 3rd party reference to Project B?

user2404597
  • 488
  • 4
  • 18
  • 3
    You're obviously trying to use the `Response` class here, so it simply *must* be defined. You need the reference. – Lucas Trzesniewski Oct 22 '15 at 20:04
  • yes, I can reference it....but anyway to Map Response Object to Project B without having to reference the entire DLL? – user2404597 Oct 22 '15 at 20:07
  • In newer versions of VS/.NET you can use Shared Projects, which will compile the shared code into each project. This may be suitable for your needs, but may come with type casting/conversion issues. More info @ http://stackoverflow.com/q/30634753/16391 – StingyJack Oct 22 '15 at 20:11
  • Also, if B calls A, its already implicitly referencing the assemblies that A references. – StingyJack Oct 22 '15 at 20:12

1 Answers1

5

If your project is using objects defined in the third party DLL, it has to be referenced directly as well.

If you want to avoid this, you can wrap the Response object in a custom object defined in Project B, creating methods and properties to expose anything necessary on the Response class. Remember, you can't expose the Response class directly, or the direct reference will be necessary again.

Of course, even with wrapping, when deploying your final DLL, the third party DLL will still be required, it just won't need to be directly referenced.

Will Eddins
  • 13,628
  • 5
  • 51
  • 85