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

Created on 6 Jun 2016  路  7Comments  路  Source: aspnet/KestrelHttpServer

My version of Kestrel is "Microsoft.AspnetCore.Server.Kestrel": "1.0.0-rc2-final"

dotnet --info:

位 dotnet --info
.NET Command Line Tools (1.0.0-preview2-002973)

Product Information:
 Version:            1.0.0-preview2-002973
 Commit SHA-1 hash:  512287ec03

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10240
 OS Platform: Windows
 RID:         win10-x64

project.json:

{
  "version": "1.0.0-*",

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "copyToOutput": [
      "appsettings.json",
      "appsettings.dev.json"
    ]
  },  

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

  "dependencies": {
    "models": "*",
    "dataaccess": "*",
    "services": "*",
    "IdentityServer4": "1.0.0-beta2-update2",
    "Microsoft.AspNetCore.Identity": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.AspnetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-rc2-final",
    "System.Security.Cryptography.Algorithms": "4.2.0-rc3-24128-00",
    "Serilog.Extensions.Logging": "1.0.0-rc2-10110",
    "Serilog": "2.0.0-rc-600",
    "Serilog.Sinks.Literate": "2.0.0-rc-25",
    "Serilog.Sinks.RollingFile": "2.0.0-rc-703",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0-*"
    }
  },
  "publishOptions": {
    "include": [
      "UI", "Views", "wwwroot", "logs", "appsettings.*", "*.pfx"
    ]
  },  
  "frameworks": {
    "netcoreapp1.0": {    
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    }
  },
  "scripts": {
    "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework netcoreapp1.0"
  }
}

Stacktrace:

I've added a few line breaks for readability:

[20:09:04 WRN] Connection processing ended abnormally
System.MissingMethodException: Method not found: 'System.Threading.Tasks.ValueTask`1<!0>
 System.Threading.Tasks.ValueTask`1.op_Implicit(System.Threading.Tasks.Task`1<!0>)'.
   at Microsoft.AspNetCore.Server.Kestrel.Http
      .MessageBody.ForContentLength.ReadAsyncImplementation
(ArraySegment`1 buffer, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Http.MessageBody.Consume(CancellationToken
 cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel
                     .Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()

Please let me know if you need more information, or if this is the wrong place to report this issue.

Most helpful comment

Just for reference, we had the same issue but were not able to identify any "wrong" package. We could see that the loaded version of System.Threading.Tasks.Extensions was 4.0.0 but could not figure out why. At the end we added to the project.json in our web app the explicit reference to System.Threading.Tasks.Extensions in correct version.

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

This seems to fix that problem.

All 7 comments

You should be using the RC2 version of all your dependencies:

{
  "dependencies": {
        "System.Security.Cryptography.Algorithms": "4.2.0-rc3-24128-00",
        "Microsoft.NETCore.App": {
           "type": "platform",
          "version": "1.0.0-*"
        }
  }
}

You should probably remove:
"System.Security.Cryptography.Algorithms": "4.2.0-rc3-24128-00",

and change:

{
"Microsoft.NETCore.App": {
           "type": "platform",
          "version": "1.0.0-*"
}
}

to

{
    "Microsoft.NETCore.App": {
           "type": "platform",
          "version": "1.0.0-rc2-3002702"
        }
}

There's no binary compat guarantees between pre-release versions.

@davidfowl Thanks!

Indeed, this is exactly what I figured out through pain and tears last night :)

Just for reference, we had the same issue but were not able to identify any "wrong" package. We could see that the loaded version of System.Threading.Tasks.Extensions was 4.0.0 but could not figure out why. At the end we added to the project.json in our web app the explicit reference to System.Threading.Tasks.Extensions in correct version.

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

This seems to fix that problem.

@pvasek That solved my problem after spending two days

That solved my problem after spending two days

What does your project file look like?

This is from .csproj. I don't have project.json.

<Reference Include="System.Threading.Tasks.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.4.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
    </Reference>

That doesn't look right at all. Can you make a project that reproduces the problem and put it on github.

Was this page helpful?
0 / 5 - 0 ratings