热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

.NET程序集引用编译时错误-.NETAssemblyReferencesCompileTimeErrors

IhaveassemblyAwithclassZthatinheritsfromclassXinassemblyB.Nowinacompletelydiffere

I have assembly A with class Z that inherits from class X in assembly B. Now in a completely different solution, I have assembly C, which uses class Z.

我有程序集A和类Z,它继承自程序集B中的类X.现在在一个完全不同的解决方案中,我有程序集C,它使用类Z.

The compiler complains unless assembly C has a reference to both assembly A & B. Even though assembly C does not use class Z directly in anyway.

除非程序集C具有对程序集A和B的引用,否则编译器会抱怨。即使程序集C无论如何都不直接使用类Z.

Is this expected?

这是预期的吗?

It seems to me that if assembly B is missing at run time stuff blows up, but at compile time it shouldn't care.

在我看来,如果程序集B在运行时丢失,那么东西会爆炸,但在编译时它应该不在乎。

What am I missing here?

我在这里想念的是什么?

My goal is that I can tell my clients to depend on class Z in assembly A, but I can completely reconfigure my assemblies on the other side and have no effect at all on the client when they upgrade.

我的目标是我可以告诉我的客户端依赖于程序集A中的类Z,但我可以在另一端完全重新配置我的程序集,并且在升级时对客户端完全没有影响。

2 个解决方案

#1


6  

Yes, that's expected.

是的,这是预料之中的。

Think about it - how can assembly C know what it can do with Z unless it knows what the base class is? How could it know about any public members exposed by X?

想一想 - 如果程序集C知道它可以用Z做什么,除非它知道什么是基类?怎么知道X公开的任何公众成员呢?

#2


0  

expected behavior; all assemblies up the chain must be referenced

预期行为;必须引用链中的所有组件

[i don't like this, but that's the way it seems to be]

[我不喜欢这个,但这就是它的样子]


推荐阅读
author-avatar
curzz
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有