Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different DLL but should be the same in console application and website

I have a console application and website that use the same System.Runtime.Serialization.Primitives.dll assembly. However, when I run the website, my assembly is the one on the right, but if I run consolation application, the DLL for the website turns to the one on the left and causes errors. Both projects are v4.7 and this started happening after I upgraded all my projects to that Framework.

Both projects have this in it

  <dependentAssembly>
    <assemblyIdentity name="System.Runtime.Serialization.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
  </dependentAssembly>

enter image description here

like image 767
Mike Flynn Avatar asked Aug 15 '17 02:08

Mike Flynn


2 Answers

Ways to solve this issue with different referencing of same DLLs:

Step 1: Create a new web app on your Visual Studio 2015

Step 2: Check if the issue still persists in this new web app project.


If the answer is NO and the issue does not persist any more, then:

Step 1: Track the assembly reference, which is causing the issue, in the original website (your first/buggy web application) project from the References section.

Step 2: Remove the Reference

Step 3: Add New Reference and refer the assembly from the Browse option instead of checking the already available one. (Best if you can copy the assembly DLL reference path from the Console project, which is working)

Step 4: Clean and then Rebuild project.

If the issue still persists then it's an issue with the framework upgrade, which you have performed.

If the issue is resolved then yay, you have solved it!


Now, if the issue did not persist in the new web app project, which you have created, but only remains in the old website/app then it means the initial issue is due to a corrupted referencing of the DLL after the framework is upgraded to v4.7

Even after updating the reference in your website/app and in your newly created web app, if the issue of referencing DLLs still exists then your upgrade to v4.7 framework is corrupted and you may need to uninstall and install (or simply repair the framework upgrade but I prefer the first option) the framework again.

Since you have installed Visual Studio 2017 after you have installed .Net v4.7 on your system, the IDE have fixed the subtle issue on its own. Whereas your Visual Studio 2015 was already installed and the framework upgrade to v4.7 got corrupted somehow, your 2015 IDE could not resolve the subtle issue internally.

If the issue is resolved then uninstall one version of your IDE, no point in hogging your hard disk memory by keeping both Visual Studio 2015 and 2017 on the same system. (This is just a suggestion)


Excess Help Material:

Microsoft has a dedicated installer page for .NET Framework v4.7 targeted for different versions of Visual Studio, which can be accessed from here: Targetting .NET Platform. You may want to download a fresh copy of .NET framework v4.7 from the aforementioned link and install it for your Visual Studio 2015 if you wish to continue with VS2015.

like image 114
Somdip Dey Avatar answered Nov 16 '22 00:11

Somdip Dey


I went ahead and upgraded to Visual Studio 2017 since I was using 2015. After doing that things started working correctly and a lot of these reference issues went away.

like image 40
Mike Flynn Avatar answered Nov 16 '22 01:11

Mike Flynn