Could not find System.Runtime 4.1.0.0 when running ASP.NET web application

前端 未结 3 1262
既然无缘
既然无缘 2021-01-05 01:00

I\'ve created a Portable Class Library with the following projects.json

{
  \"supports\": {},
  \"dependencies\": {
    \"Microsoft.CSharp\": \"4.0.1\",
             


        
相关标签:
3条回答
  • 2021-01-05 01:35

    I was getting a similar warning from ReSharper while running unit tests:

    The solution that worked for me was to run this in the Package Manager console:

    Update-Package System.Runtime -Reinstall
    

    What I observed is that before running the above command, the reference in the affected project was to System.Runtime v 4.0.20.0, but post execution, it changed to 4.1.1.0

    0 讨论(0)
  • 2021-01-05 01:47

    I was experiencing this issue after upgrade the .NET framework from 4.6.2 to 4.7, after digging around on several forums and the internet for a while and trying a lot, I found a solution and consits in two steps:

    1. I deleted all Dependent Assambly and update all nugets UPDATE-PACKAGE -projectName -reinstall.

    2. After the first step, I checked every missing assambly that throw me an exception in runtime and realize that in some cases the framework has a dll in our local machine that has nothing to do with the nuget then I deleted all local's dll references and install it from the nuget. After cleaning from the missing dll taking them from the Nuget my project run without any issue.

    Hope that help you.

    0 讨论(0)
  • 2021-01-05 01:54

    As mentioned in the update one solution to this problem is to package up the PCL as a nuget package. This however goes contrary to what one is trying to do when one targets .Net Standard with a PCL. Also the package solution becomes cumbersome to debug.

    To me it appears as a bug with Net Core Tools Preview when crossing the csproj to xproj boundary. To evidence this if one install the package via nuget:

    Install-Package System.Runtime
    

    The System.Runtime looks correct in the project.json as "System.Runtime": "4.1.0". Looking at the references, one will see that the version is listed as System.Runtime (4.0.20). Also the actual bin has absolutely reference to the actual dll.

    Simply copying the .Net 4.6.2 dll from the nuget cache into the bin solves the problem. This allows for direct references without packaging up your PCL.

    Hopefully when we hit Net Standard 2.0 and the tooling matures a bit more this type of thing will be a thing of the past.

    UPDATE: If you use the latest .Net Core release (1.1) and binaries this is fixed. The tool preview is still on 1.0.1 so you have to make sure you install the binaries for 1.1.

    0 讨论(0)
提交回复
热议问题