KestrelHttpServer icon indicating copy to clipboard operation
KestrelHttpServer copied to clipboard

System.MissingMethodException: Method not found: 'System.Threading.Tasks.ValueTask`1<!0> System.Threading.Tasks.ValueTask`1.op_Implicit(System.Threading.Tasks.Task`1<!0>)'.

Open ybarbaria opened this issue 10 years ago • 7 comments

I try to communicate with my service wcf and I obtain this error since I have upgrade to aspnet core 1.0 and Update 3 of visual studio community 2015.

warn: Microsoft.AspNetCore.Server.Kestrel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60[0] Connection processing ended abnormally System.MissingMethodException: Method not found: 'System.Threading.Tasks.ValueTask1<!0> System.Threading.Tasks.ValueTask1.op_Implicit(System.Threading.Tasks.Task1<!0>)'. at Microsoft.AspNetCore.Server.Kestrel.Http.MessageBody.ForContentLength.ReadAsyncImplementation(ArraySegment1 buffer, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Http.MessageBody.Consume(CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Http.Frame`1.d__2.MoveNext()

ybarbaria avatar Jun 29 '16 20:06 ybarbaria

@ybarbaria There was recently a breaking change to ValueTask in System.Threading.Task.Extensions, and it looks like you are getting mismatched dependencies. You can see previous reports of this issue here and here.

Guessing based on your error, you've correctly updated your System.Threading.Task.Extensions dependency to 4.0.0, but you're using an older version of Microsoft.AspnetCore.Server.Kestrel.

Since you're only using release packages, make sure you don't have any myget sources in your NuGet.Config files. Then clear all you nuget package caches and restore.

If that doesn't fix things, please include a link to a gist with your project.lock.json.

halter73 avatar Jun 29 '16 23:06 halter73

Same problem, I have clear cache and verify mismatch dependancies.

I create a gist : https://gist.github.com/ybarbaria/91c7aefff3fb9c7a44f4517b920570d2

ybarbaria avatar Jun 30 '16 10:06 ybarbaria

I also try this configuration same result ... https://gist.github.com/ybarbaria/439b805b9a84c931814b1b7fb679b696

ybarbaria avatar Jun 30 '16 13:06 ybarbaria

Can you take a look at the exact Microsoft.AspNetCore.Server.Kestrel.dll loaded by your application at runtime? I would use Process Explorer to be sure you get the right one. Then take a look at the dll's detailed properties in file explorer. It should look like this:

image

halter73 avatar Jul 01 '16 19:07 halter73

For anyone still having problems with this, a temporary fix is to include this in your dependencies:

"System.Threading.Tasks.Extensions": "4.0.0-rc2-24027"

Update: this is bad advice, please keep reading.

nbahramzad avatar Jul 08 '16 16:07 nbahramzad

@nbahramzad Or upgrade your dependencies instead of downgrading one of them.

davidfowl avatar Jul 08 '16 16:07 davidfowl

I should elaborate, my old project.json looked like this:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final",
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview2-final"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "gcServer": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

and after updating everything to look like this:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview2-final"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "gcServer": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

I got this error message on restore:

Package Microsoft.AspNetCore.Mvc 1.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.AspNetCore.Mvc 1.0.0 supports:
      - net451 (.NETFramework,Version=v4.5.1)
      - netstandard1.6 (.NETStandard,Version=v1.6)
    One or more packages are incompatible with .NETCoreApp,Version=v1.0.
NuGet Config files used:
    C:\Users\nbahramzad\AppData\Roaming\NuGet\NuGet.Config
    C:\ProgramData\nuget\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
    https://api.nuget.org/v3/index.json

Just downgrading System.Threading.Tasks.Extensions was a quick and easy solution for getting things working with the non-upgraded project.json.

Finally, I figured out my problem. I updated the "frameworks" section from:

"frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

to this:

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "netstandard1.6"
      ]
    }
  },

and now everything works with the 1.0.0 RTM versions! Sorry for giving the bad advice and thank you @davidfowl for the tip. I hope this helps someone having the same problems I was having.

nbahramzad avatar Jul 08 '16 16:07 nbahramzad