none
How to set Reference Alias in csproj?

    Question

  • If I have 2 dlls with same name, public key token and culture.
    How can I reference them both in the same C# project?

    Scenarios: having to reference and old and new dll for the sake of upgrade.

    Regards
    Min Chew

    [Edit]
    Solution here

    1. In app.config
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
            <assemblyIdentity name="myAssembly"
                              publicKeyToken="here token dll"
                              culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
           <bindingRedirect oldVersion="1.0.0.1-2.0.0.0" newVersion="2.0.0.0" />
           <codeBase version="1.0.0.0" href="folder\namedll.dll" />
           <codeBase version="2.0.0.0" href="folder\namedll.dll" />
        </dependentAssembly>
    </assemblyBinding>
    


    2. Unload and edit the csproj file, and add or set:

    <AutoGenerateBindingRedirect>false</<AutoGenerateBindingRedi‌​rect>



    • Moved by Sabah ShariqMVP Tuesday, March 14, 2017 10:40 AM Moved From Visual C#
    • Edited by Min Chew Monday, May 15, 2017 9:44 AM Removed verbosity, rewrote question and added answer
    Tuesday, March 14, 2017 1:39 AM

Answers

All replies