.NET - Multiple libraries with the same namespace - referencing

后端 未结 5 1169
天涯浪人
天涯浪人 2020-12-09 09:14

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

相关标签:
5条回答
  • 2020-12-09 09:53

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

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

    0 讨论(0)
  • 2020-12-09 10:00

    I think you have to use extern alias

    See http://msdn.microsoft.com/en-us/library/ms173212.aspx

    Here's a walkthrough. http://blogs.msdn.com/b/ansonh/archive/2006/09/27/774692.aspx

    0 讨论(0)
  • 2020-12-09 10:03

    I'd be surprised if you can do this, without using reflection.

    It might be easier to create your own FooWrapper and BarWrapper dlls which reference foo and bar and expose their contents again under different namespaces.

    0 讨论(0)
  • 2020-12-09 10:13

    You could use the "Aliases" property for resolving conflicts. Select the library and open Property window. This is already discussed in this SO post

    0 讨论(0)
  • 2020-12-09 10:15

    Wow, thats tricky. I tink, I would create two wrapper-DLLs:

    1. MyBarWrapper.dll (which has a reference to bar.dll)
    2. MyFooWrapper.dll (which has a reference to foo.dll)

    and support different namespaces there.

    0 讨论(0)
提交回复
热议问题