C#Visual studio需要引用基类dll [英] C# Visual studio needs reference to base class dll

查看:232
本文介绍了C#Visual studio需要引用基类dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我会遇到这个问题?

Why do I get this problem?

背景: myClass 继承自一个 ABC 的类,它继承自 BaseClass
BaseClass 是一个自定义创建的类,位于不同的命名空间中,包含在不同的DLL程序集中。

Background: myClass inherits from a class ABC which inherits from a BaseClass. BaseClass is a custom created class in a different namespace and contained in a different DLL assembly.

问题:VisualStudio希望我添加对 BaseClass DLL的引用 - 否则它将无法编译 myClass

Issue: VisualStudio wants me to add a reference to the BaseClass DLL - otherwise it won't compile myClass.


  • 为什么编译器不使用元数据?

  • 如果我购买了DLL(可能没有源代码)并且供应商使用了数百个类来继承,那么为什么我需要添加(并知道)所有这些引用?

谢谢

推荐答案

怎么可能呢如果你不提供基类的元数据?它不会从基类复制到派生类并存储在派生类的程序集中。

How could it get the metadata for the base class if you don't provide it? It doesn't get copied from the base class to the derived class and stored in the derived class' assembly.

您的供应商场景是不现实的。没有人设计深度为100类的类层次结构,更不用说将它们中的每一个存储在单独的程序集中。在最坏的情况下,最高可达到六到七。有一个底座组件,有时两个。任何更深层次的人都无法理解它是如何工作的。

Your vendor scenario is just not realistic. Nobody designs class hierarchies that are a hundred classes deep, let alone store each of them in a separate assembly. This tops out at six or seven, at worst. With one base assembly, sometimes two. Any deeper and nobody can understand how it works anymore.

这篇关于C#Visual studio需要引用基类dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆