不同的DLL但在控制台应用程序和网站中应该是相同的

时间:2017-08-15 02:28:44

标签: c# .net visual-studio .net-assembly compiler-warnings

我有一个使用相同System.Runtime.Serialization.Primitives.dll程序集的控制台应用程序和网站。但是,当我运行网站时,我的程序集是右边的那个,但是如果我运行安慰应用程序,网站的DLL会转到左边的那个并导致错误。这两个项目都是v4.7,这是在我将所有项目升级到该框架后开始的。

两个项目都有这个

  <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

2 个答案:

答案 0 :(得分:8)

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.

答案 1 :(得分:3)

自从我使用2015年以来,我继续升级到Visual Studio 2017.完成后,事情开始正常工作,很多这些参考问题都消失了。

相关问题