如何从一个特定的程序集引用命名空间? [英] How to reference a namespace from a specific assembly?

查看:150
本文介绍了如何从一个特定的程序集引用命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,这里是我的问题。

So here is my problem.

  • 在我的(测试)项目同时引用温莎城堡和犀牛制品。
  • 在我创建它实现Castle.Core.Interceptor.IInterceptor从Castle.Core.dll组件类
  • 在建设犀牛制品,Ayende使用Castle.Core.Interceptor并包括Rhino.Mocks.dll
  • 里面的整个该死的命名空间
  • My (test) project references both Castle Windsor and Rhino Mocks.
  • I am creating a class which implements Castle.Core.Interceptor.IInterceptor from the Castle.Core.dll assembly
  • In building Rhino Mocks, Ayende used Castle.Core.Interceptor and includes the whole darn namespace inside the Rhino.Mocks.dll

所以,当我尝试建立,我得到的错误

So when I try to build, I get the error

类型   Castle.Core.Interceptor.IInterceptor   存在于两个   C:\图书馆\ Rhino.Mocks.dll和   C:\图书馆\ Castle.Core.dll

The type 'Castle.Core.Interceptor.IInterceptor' exists in both 'c:...\Libraries\Rhino.Mocks.dll' and 'c:...\Libraries\Castle.Core.dll'

那么,如何做我指定我想使用IInterceptor实例从Castle.Core.dll,而不是包含在犀牛制品的人吗?

How then do I specify that I want to use the IInterceptor instance from the Castle.Core.dll rather than the one included in Rhino Mocks?

推荐答案

让我们这里扔明确的答案了,以防有人走来以后。 从文章这里

Let's throw the specific answer up here in case someone comes along later. From article here.

  • 选择下项目引用这两个组件中的一个(在我的情况,我选择Castle.Core)。按F4键,弹出属性并输入别名CastleCore
  • 在把有问题的CS文件的顶部外部别名CastleCore;
  • CastleCore参考类:: Castle.Core.Interceptors.IInterceptor 。或者对于我来说,我只是做了:
  • Select one of the two assemblies under project references (in my case I selected Castle.Core). Hit F4 to bring up properties and enter alias CastleCore
  • At the top of the problematic cs file put extern alias CastleCore;
  • Reference your class with CastleCore::Castle.Core.Interceptors.IInterceptor. Or in my case I simply did:

使用CCI = CastleCore :: Castle.Core.Interceptors;

using cci = CastleCore::Castle.Core.Interceptors;

和现在可以参考

cci.IInterceptor

这篇关于如何从一个特定的程序集引用命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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