Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
249 views
in Technique[技术] by (71.8m points)

c# - .NET - Multiple libraries with the same namespace - referencing

Today I am faced with a curious challenge...

This challenge involves two .NET libraries that I need to reference from my application. Both of which I have no control over and have the same namespace within them.

So...

I have foo.dll that contains a Widget class that is located on the Blue.Red.Orange namespace.

I have bar.dll that also contains a Widget class that is also located on the Blue.Red.Orange namespace.

Finally I have my application that needs to reference both foo.dll and bar.dll. This is needed as within my application I need to use the Widget class from foo and also the Widget class from bar

So, the question is how can I manage these references so that I can be certain I am using the correct Widget class?

As mentioned, I have no control over the foo or bar libraries, they are what they are and cannot be changed. I do however have full control over my application.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to use an extern alias - introduced in C# 2.

Anson Horton has a walkthrough on his blog which you may find useful.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...