.Net Inheritance - Automatic dependency referencing behavior issue

前端 未结 3 817
长情又很酷
长情又很酷 2021-01-05 02:42

I\'ve come across a strange issue that I\'ve just now noticed.

If you have a solution with 3 projects

** NOTE Edited after discussion **

Project LibA

3条回答
  •  心在旅途
    2021-01-05 02:57

    In the first scenario, you are just using the ClassA. So, it does not need the resource at compile time, just at run time.

    In the second scenario, you are inheriting from ClassA, so, its definition and information is needed by the compiler in order to build the final assembly.

    In the first scenario, VisualStudio copies the referenced DLL into the output directory, because it knows you'll need it there.

    In the second scenario, VisualStudio does not add the reference to the project, and that's I assume, your main doubt. I guess it's meant that way in order to avoid problems by being intrusive in your project. But, I'm just guessing...

提交回复
热议问题