如何在2个DLL中区分具有相同名称(和名称空间)的两个类? [英] How to distinguish between two classes with the same name (and namespace) in 2 DLL's?
问题描述
我有两个DLL-一个Common.dll
和一个CFW.Infrastructure.Sdk.dll
.这两个DLL都包含以下类:
I've got two DLL's - a Common.dll
and a CFW.Infrastructure.Sdk.dll
. Both DLL's contain the following class:
CFW.Common.Hashing.BlockHasher
我有一个引用两个DLL的 test项目.当我尝试测试BlockHasher时,出现以下错误:
I have a test project that references both DLL's. When I try to test the BlockHasher, I get the following error:
我喜欢测试CFW.Infrastructure.Sdk.dll
中的一个.因为完全限定的名称是相同的,所以我无法使用正常"的名称来解决这个问题.
I like to test the one in the CFW.Infrastructure.Sdk.dll
. Because the fully qualified names are the same I can't fix this with a 'normal' using.
推荐答案
打开解决方案资源管理器.导航到DLL并向其中添加alias
.
Open the solution explorer. Navigate to the DLL and add an alias
to it.
添加以下C#文件(必须在顶部):
Add the following the the C# file (must be on top):
extern alias Sdk;
3.添加一些usings
进行区分:
我添加了在使用中出现问题的类:
3.Add some usings
to distinguish:
I've added the classes that gave problems as usings:
using BlockHasher = Sdk.CFW.Common.Hashing.BlockHasher;
using SigningAlgorithm = Sdk.CFW.Common.Hashing.SigningAlgorithm;
4.完成!
这篇关于如何在2个DLL中区分具有相同名称(和名称空间)的两个类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!