两个不同的DLL具有相同的命名空间 [英] two different DLL with same namespace

查看:1513
本文介绍了两个不同的DLL具有相同的命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个DLL文件,它们都具有相同的命名空间,但它们具有不同的功能和类型。
我怎么能引用了两个DLL文件在我的项目,并利用它们的功能和类型?

I have two DLL file that they both have a same namespace but they have different functions and types. how can I references both DLLs in my Project and use their functions and types?

通过的方式。这两个DLL有一些功能和类型有相同的名字和不同的实施以及一些独特的功能和类型

by the way. these two DLL have some functions and types with same name and different implementation and some unique functions and types

推荐答案

有什么特别的你需要做的 - 只是引用它们,使用类型。命名空间可以跨越多个防空火炮没有集会的问题,因为他们没有真正的不透明类型。名字空间只是增加一个共同的preFIX到它所包含的所有类型,让你有不同的命名空间多种类型同名的一种方式。 (该框架不认为他们是具有相同的名称,因为它看到的一切的完全合格的名字 - 它的别名和连接到它的前面有一个命名空间)

There's nothing special you need to do - just reference them and use the types. Namespaces can span accross several assemblies without problems, because they're not really opaque types. A namespace is just a way of adding a common prefix to all the types it contains, allowing you to have multiple types of the same name under different namespaces. (The framework doesn't see them as having the same names, because it sees the "fully qualified" name of everything - which has an alias and a namespace attached to the front of it.)

在您引用2组件具有相同类型名称相同的命名空间(如2个不同版本的同一个DLL)中罕见的事件 - 你能辨别使用了哪些组件定使用别名的类型。或者只是使用属性在Visual盒 - 所有引用的默认别名是全球,但您可以在引用它(使用编译器开关指定自己的别名任何集会一室公寓) - 并有一个外部别名<名称> 你的code文件的顶部,你使用它条款 - 你会从不同的组件访问类型<名称> :: MyNamespace.Type

In the rare event that you reference 2 assemblies which have the same type names and the same namespaces (such as 2 different versions of the same dll) - you can distinguish which assembly to use for a given type using an alias. The default alias for all references is global, but you can specify your own alias for any assembly when you reference it (using a compiler switch - or just use the properties box in Visual Studio) - and have an extern alias <name> clause at the top of your code file where you use it - you would access the types from different assemblies with <name>::MyNamespace.Type

这篇关于两个不同的DLL具有相同的命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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