none
References to a project that references third party libraries installed on system. RRS feed

  • Question

  • Hi Everyone, I know similar questions has been asked before, I checked but still have some doubts

    I have project A that references lib1.dll, lib2.dll from a software installed on my system; Windows 10 Pro, project B references project A and when I run my solution and project B tries to use a type on lib1.dll it requires me to add references to lib1.dll; shouldn't it be enough that my referenced project A already has a reference to those libraries?

    Thank you in advance,

    Luis


    Luis

    Tuesday, February 18, 2020 9:02 PM

Answers

  • I know similar questions has been asked before

    You're right that this is one of the most common newbie questions. I remember having trouble with it too when I started with DotNET.

    I have project A that references lib1.dll, lib2.dll

    project B references project A and when I run my solution and project B tries to use a type on lib1.dll it requires me to add references to lib1.dll

    shouldn't it be enough that my referenced project A already has a reference to those libraries?

    Nope. You're confusing includes and imports from other languages (where that keyword actually takes the full text of the referenced codefile) with includes/imports/references in DotNET (where that keyword typically is only used on pre-compiled DLLs). What it really means in any DotNET language is: "Do a whole bunch of dynamic loading and invoking in the back-end for me."

    So references aren't shared amongst DotNET runtimes the way imports/includes are literally sucked into the codefile at compile time in other languages (replacing the include/import statement with the full text of the imported item). It's literally akin to directly dynamic-loading the DLL in a regular language project, where you'd see the same behavior but you'd understand it a bit more intuitively.


    • Edited by Andrew B. Painter Tuesday, February 18, 2020 11:12 PM
    • Marked as answer by LazyCod3r Tuesday, February 18, 2020 11:34 PM
    • Unmarked as answer by LazyCod3r Wednesday, February 26, 2020 5:06 PM
    • Marked as answer by LazyCod3r Wednesday, February 26, 2020 5:38 PM
    Tuesday, February 18, 2020 11:10 PM

All replies

  • Perhaps a little more details e.g. when you say "tries to use a type on lib1.dll", please define how you are using it as there are a handful of ways from adding a reference with proper using statements to reflection.'

    Even with that if you are working with standard usage of code there needs to be a reference between namespaces.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, February 18, 2020 9:14 PM
    Moderator
  • I know similar questions has been asked before

    You're right that this is one of the most common newbie questions. I remember having trouble with it too when I started with DotNET.

    I have project A that references lib1.dll, lib2.dll

    project B references project A and when I run my solution and project B tries to use a type on lib1.dll it requires me to add references to lib1.dll

    shouldn't it be enough that my referenced project A already has a reference to those libraries?

    Nope. You're confusing includes and imports from other languages (where that keyword actually takes the full text of the referenced codefile) with includes/imports/references in DotNET (where that keyword typically is only used on pre-compiled DLLs). What it really means in any DotNET language is: "Do a whole bunch of dynamic loading and invoking in the back-end for me."

    So references aren't shared amongst DotNET runtimes the way imports/includes are literally sucked into the codefile at compile time in other languages (replacing the include/import statement with the full text of the imported item). It's literally akin to directly dynamic-loading the DLL in a regular language project, where you'd see the same behavior but you'd understand it a bit more intuitively.


    • Edited by Andrew B. Painter Tuesday, February 18, 2020 11:12 PM
    • Marked as answer by LazyCod3r Tuesday, February 18, 2020 11:34 PM
    • Unmarked as answer by LazyCod3r Wednesday, February 26, 2020 5:06 PM
    • Marked as answer by LazyCod3r Wednesday, February 26, 2020 5:38 PM
    Tuesday, February 18, 2020 11:10 PM
  • Hi Karen, thank you for taking the time to answer. This is what I meant, Project "A" references a library named "AutConnListTypeLibrary", among others, these are libraries from the IBM personal communication 3270 emulator that is installed on the end user computer. Project "A" is a class library project, one of its methods returns a "ScreenObject" type, which is a type from the "AutConnListTypeLibrary"  library. When I call that method from project "B" I get this error :

    System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'Interop.AutConnListTypeLibrary"...

    If I'm referencing project A from project B why do I have to add a reference to "AutConnListTypeLibrary"?; I don't even want those libraries on my bin folder; if that is even possible, since they are already on the end user machine. Any suggestions is appreciated.

    Thank you!

    Luis


    Luis

    Tuesday, February 18, 2020 11:20 PM
  • Thank you Andrew, it makes sense now. 

    Luis


    Luis

    Tuesday, February 18, 2020 11:34 PM