简体   繁体   中英

How to use class from DLL referenced by referenced DLL

I have 3 C# projects: P1, P2 and P3. I have class A in project P1 that I compile as assembly and get DLL. I reference project P1 in project P2 and use class A, and also compile it as assembly and get DLL. In addition, I reference project P2 in project P3 and want to use class A (from project P1) as well, but unfortunately, class A is not available. The reference sequence is as follows:

P1 -> P2 -> P3

I am using Visual Studio 2019 for development.

Please advise how to make class A from project P1 be visible in project P3.

Thank you

As others suggested, the direct way is to add the reference P1 to P3.

Also, if you don't want to add the reference P1, you can create a new class to inherit from the classA in the P2.

Like the following:

public class ExampleB:ExampleA
    {
        ....
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM