Using two DLLs with same name and same namespace

后端 未结 5 1688
面向向阳花
面向向阳花 2020-12-06 10:42

I have a project which needs to reference two DLLs with the same name. The DLLs are not strong named, have the same exact name.

I need to access some types within ea

5条回答
  •  遥遥无期
    2020-12-06 11:39

    Using extern alias to bring the assemblies in with different namespaces. If you can differenciate the namespace, you should be able to use using altType1 = someProduct.Type1 to create a local alias for the type.

    First qualify the assemblies from the command line:

    /r:ProductA=companyDLLA.dll
    /r:ProductB=companyDLLB.dll
    

    Then reference them using extern alias:

    extern alias productA;
    extern alias productB;
    

    Finally you can alias the local types:

    using productTypeA = productA.Type1;
    using productTypeB = productB.Type1;
    

提交回复
热议问题