aspnet / Mvc

[Archived] ASP.NET Core MVC is a model view controller framework for building dynamic web sites with clean separation of concerns, including the merged MVC, Web API, and Web Pages w/ Razor. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
5.62k stars 2.14k forks source link

MissingMethodException: Method not found at 1.0.0-rc2-* #4430

Closed rsbavaresco closed 8 years ago

rsbavaresco commented 8 years ago

Hi,

Referencing packages from RC2 (aspnetcidev endpoint) throws Missing Method Exception at runtime when:

  [HttpGet("~/signin")]
  public ActionResult SignIn(string returnUrl = null)
  {
      ViewBag.ReturnUrl = returnUrl;    
      return View("SignIn", HttpContext.GetExternalProviders());
  }

Current project.json:

{
  "dependencies": {
    "AspNet.Security.OAuth.Introspection": "1.0.0-alpha1-0114",
    "AspNet.Security.OAuth.Validation": "1.0.0-alpha1-0114",
    "AspNet.Security.OpenIdConnect.Server": "1.0.0-beta5-0691",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Mvc.Razor": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Mvc.Core": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Mvc.Dnx": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Authentication.Google": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Hosting": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-*",
    "Microsoft.EntityFrameworkCore.InMemory": "1.0.0-rc2-*",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-*",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-*"
  },
  "frameworks": {
    "net451": {
      "dependencies": {
        "Microsoft.AspNetCore.Owin": "1.0.0-rc2-*",
        "Microsoft.Owin.Security": "3.0.0",
        "NWebsec.Owin": "1.0.0"
      },
      "frameworkAssemblies": {
        "System.ComponentModel": "4.0.0.0"       
      }
    },
    "netstandardapp1.5": {
      "dependencies": {
        "NETStandard.Library": "1.5.0-*"
      },

      "imports": [
        "dnxcore50"
      ]
    }
  },
  "compilationOptions": {
      "emitEntryPoint": true,
      "preserveCompilationContext": true
  },
  "commands": {
      "web": "Mvc.Server"
  }
...
}

Stack trace:

An unhandled exception occurred while processing the request.

MissingMethodException: Method not found: 
'Void Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions..ctor(Microsoft.
CodeAnalysis.OutputKind, Boolean, System.String, System.String, System.String, 
System.Collections.Generic.IEnumerable`1<System.String>, 
Microsoft.CodeAnalysis.OptimizationLevel, Boolean, Boolean, System.String, System.String, 
System.Collections.Immutable.ImmutableArray`1<Byte>, System.Nullable`1<Boolean>, 
Microsoft.CodeAnalysis.Platform, Microsoft.CodeAnalysis.ReportDiagnostic, Int32, 
System.Collections.Generic.IEnumerable`1<System.Collections.Generic.KeyValuePair`2<
System.String,Microsoft.CodeAnalysis.ReportDiagnostic>>, Boolean, Boolean, 
Microsoft.CodeAnalysis.XmlReferenceResolver, Microsoft.CodeAnalysis.SourceReferenceResolver, 
Microsoft.CodeAnalysis.MetadataReferenceResolver, 
Microsoft.CodeAnalysis.AssemblyIdentityComparer, 
Microsoft.CodeAnalysis.StrongNameProvider, Boolean)'.

at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions..ctor()

TargetInvocationException: An exception was thrown by the target of a call.

at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean 
noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& 
bNeedSecurityCheck)

I tried to add another versions of three packages too:

"Microsoft.AspNetCore.Mvc": "1.0.0-rc3-*",
"Microsoft.AspNetCore.Mvc.Razor": "1.0.0-rc3-*",
"Microsoft.AspNetCore.Mvc.Core": "1.0.0-rc3-*",

Nothing changed the exception throwed and it was working at 20270 build. I would like to freeze my build at latest RC2 version and to be waiting for RC2 release. It would be possible? Some mistake I made?

Current build: 20466.

Thanks

halter73 commented 8 years ago

Maybe this something to do with the fact that we started publishing rc3 packages. Instead of getting the latest version of every package, you might be getting the rc2 version of the packages you directly reference, but the rc3 versions of your transitive dependencies and therefore aren't getting coherent bits.

I think the fix is to switch from the https://www.myget.org/F/aspnetcidev/ feed to the https://www.myget.org/F/aspnetvnext/ feed which doesn't have the rc3 packages. You might have to clear your nuget cache first for this to work.

If that doesn't fix it, could you provide your project.lock.json file?

rsbavaresco commented 8 years ago

None RC3 dependencies were downloaded, even with aspnetcidev.

I switched from aspnetcidev to aspnetvnext feed, clear all nuget caches, deleted my old project.lock.json and runned dnu restore from command line. Same error.

Now:

Feeds used:
    https://www.nuget.org/api/v2/
    https://www.myget.org/F/aspnetvnext/
    https://api.nuget.org/v3-flatcontainer/
    https://myget-2e16.kxcdn.com/artifacts/aspnet-contrib/nuget/v3/flatcontainer/

Attached files: project.json, project.lock.json, NuGet.config

github.zip

pranavkm commented 8 years ago

Are you using DNX to build your application?

rsbavaresco commented 8 years ago

Yes, nothing different I made from RC1 to RC2 to compile, except download RC2 dnx runtime and modify project.json file.

pranavkm commented 8 years ago

This is a known issue - DNX is compiled against an older build of Roslyn. I haven't gotten around to updating it as yet.

rsbavaresco commented 8 years ago

Ok. Two questions:

Thank you!

pranavkm commented 8 years ago

Tracking DNX changes via https://github.com/aspnet/dnx/issues/3397