How to distinguish between two classes with the sa

2019-05-21 14:38发布

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

I have a test project that references both DLL's. When I try to test the BlockHasher, I get the following error:

Blockhasher exists in both DLL's

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.

1条回答
小情绪 Triste *
2楼-- · 2019-05-21 15:12

External aliasses can be used.

1. Add an alias to the DLL reference

Open the solution explorer. Navigate to the DLL and add an alias to it.

Properties of the reference

2. Reference the alias

Add the following the the C# file (must be on top):

extern alias Sdk;

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.Done!

Got the idea from the Extern Alias Walkthrough.

查看更多
登录 后发表回答