Version Independent reference in C# Class Library

0

I have a C# class library MyLibrary in which I am referencing a sample.dll version 2.7.0. This MyLibrary is being referenced in WCF project. Which is deployed on the server.

Now on the server, I have sample.dll with the version 3.0.0 because of that I am getting referenced dll not found error as following.

Could not load file or assembly 'sample, Version=2.7.0.0, Culture=neutral, PublicKeyToken=185805eaf7302b6c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I have found few solutions for making it version Independent like adding 'BindingRedirect' as it is a class library, I don't have web.config or app.config where I can configure 'BindingRedirect'. I have also tried setting 'Specific Version' to false but still getting the same error.

I want to make my class library such that it should work with any version of Sample dll

I tried adding following in web.config of my WCF project

 <dependentAssembly>
        <assemblyIdentity name="sample" publicKeyToken="185805eaf7302b6c" culture="neutral"/>
        <bindingRedirect oldVersion="2.7.0.0" newVersion="3.0.0.3"/>
</dependentAssembly>

But still getting the same error.

c#
versioning
class-library
dll-reference
asked on Stack Overflow Oct 16, 2019 by Rahul Bhati • edited Oct 16, 2019 by Rahul Bhati

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0