你如何解释深入浅出的转发类型?深入浅出、类型

2023-09-05 02:50:21 作者:坐在墳頭調戲鬼丿

我是preparing的MCTS 70-536,阅读此之后的文章。我肯定不是100%我理解typeforwarding的概念。我在文章更加混乱给出的步骤。请告诉我,如果我是复制型的源$ C ​​$ C这笔交易被转发并重新编译。与旧的DLL和客户端??,会发生什么

I am preparing for MCTS 70-536, after reading this article. I am not 100% sure I understand the concept of typeforwarding. I find the steps given in the article even more confusing. Whats the deal if I am copying the sourcecode of type to be forwarded and recompiling it. What happens with old dll and the client ??

推荐答案

转发类型,您可以重新定位组件之间的类型。因此,原本是类型A AssemblyA 。通过应用型转发,你可以用类型A AssemblyB 结束。

Type forwarding allows you to relocate a type between assemblies. So originally it is TypeA in AssemblyA. By applying type-forwarding, you can end with TypeA in AssemblyB.

的精妙之处是已编译的没有看到变化code - 他们要求的类型 AssemblyA ,和运行时悄悄地给了他们从 AssemblyB 的类型。这是在现有的code是非常重要的。

The subtlety is the code that is already compiled doesn't see the change - they ask for the type in AssemblyA, and the runtime silently gives them the type from AssemblyB. This is very important if you have existing code.

不过, 新的code不能重新编译引用类型A 没有你引用 AssemblyB

However; new code cannot be recompiled referencing TypeA without you referencing AssemblyB.

所以:

老客户不需要重新编译 但是,你确实需要重建两个 AssemblyA AssemblyB 在上面的例子中 在新的code(或重新编译code)现在必须引用 AssemblyB (新一) old clients don't need to be recompiled however, you do need to rebuild both AssemblyA and AssemblyB in the above example new code (or any recompiled code) must now reference AssemblyB (the new one)