Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors after upgrading from RC2 to RTM #5884

Closed
sam-wheat opened this issue Jun 28, 2016 · 6 comments
Closed

Errors after upgrading from RC2 to RTM #5884

sam-wheat opened this issue Jun 28, 2016 · 6 comments

Comments

@sam-wheat
Copy link

Steps to reproduce

I am reporting two issues that appear to be related. Project fails on build or startup so the step to reproduce is to attempt to build or run.

The issue

ERROR 1:
Error CS0121 The call is ambiguous between the following methods or properties: 'Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.UseContentRoot(Microsoft.AspNetCore.Hosting.IWebHostBuilder, string)' and 'Microsoft.AspNetCore.Hosting.HostingAbstractionsWebHostBuilderExtensions.UseContentRoot(Microsoft.AspNetCore.Hosting.IWebHostBuilder, string)'

The error occurs in Program.cs of my web project:
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory()) //error here
.UseIISIntegration()
.UseStartup()
.Build();
host.Run();
}
}

ERROR 2:

If I comment out the following line in Startup.cs in the Blog project my project will build:
.UseContentRoot(Directory.GetCurrentDirectory()) //error here
However, it will not load and it fails with the same error message as found in this post:
#5881
The error message is:
Could not load type 'Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions' from assembly 'Microsoft.Extensions.DependencyInjection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Further technical details

I followed the instructions found here: https://docs.efproject.net/en/latest/miscellaneous/rc2-rtm-upgrade.html
After changing the EF package versions my projects would not build. The error message was that the logging and memory cache packages needed to be upgraded so I changed these packages as follows:
"Microsoft.Extensions.Logging": "1.0.0" (Blog, Blog.API)
"Microsoft.Extensions.Caching.Memory": "1.0.0", (Blog.API)
"Microsoft.Extensions.Caching.Abstractions": "1.0.0" (Blog.API)

EF Core version: (found in project.json or packages.config)
Operating system: Windows 10
Visual Studio version: 2015 Update 3

Other details about my project setup:

There are several projects in my solution. The three that are mentioned in this post are Blog, Blog.API, and Blog.Services (class library DBContext here).

Blog Project.json

    {
      "userSecretsId": "aspnet-RC2CoreTest2-d092f974-1ed6-4625-b2e4-825fd01d61d9",
      "version": "1.0.0-*",
      "dependencies": {
        "NETStandard.Library": "1.5.0-rc2-24027",
        "Microsoft.ApplicationInsights.AspNetCore": "1.0.0-rc2-final",
        "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-final",
        "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
        "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-rc2-final",
        "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "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.EntityFrameworkCore.SqlServer": "1.0.0",
        "Microsoft.EntityFrameworkCore.Tools": {
          "version": "1.0.0-preview2-final",
          "type": "build"
        },
        "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
        "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
        "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc2-final",
        "Microsoft.Extensions.Logging": "1.0.0",
        "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",
        "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
          "version": "1.0.0-preview1-final",
          "type": "build"
        },
        "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
          "version": "1.0.0-preview1-final",
          "type": "build"
        }
      },
      "tools": {
        "Microsoft.AspNetCore.Razor.Tools": {
          "version": "1.0.0-preview1-final",
          "imports": "portable-net45+win8+dnxcore50"
        },
        "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
          "version": "1.0.0-preview1-final",
          "imports": "portable-net45+win8+dnxcore50"
        },
        "Microsoft.EntityFrameworkCore.Tools": {
          "version": "1.0.0-preview2-final",
          "imports": [
            "portable-net45+win8+dnxcore50",
            "portable-net45+win8"
          ]
        },
        "Microsoft.Extensions.SecretManager.Tools": {
          "version": "1.0.0-preview1-final",
          "imports": "portable-net45+win8+dnxcore50"
        },
        "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
          "version": "1.0.0-preview1-final",
          "imports": [
            "portable-net45+win8+dnxcore50",
            "portable-net45+win8"
          ]
        }
      },
      "frameworks": {
        "net462": {
          "frameworkAssemblies": {
            "System.Drawing": "4.0.0.0"
          }
        }
      },
      "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%" ]
      }
    }

Blog.API Project.json

{
  "version": "1.0.0-*",
  "dependencies": {
    "NETStandard.Library": "1.5.0-rc2-24027",
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
    "Autofac": "4.0.0-rc2-240",
    "Autofac.Extensions.DependencyInjection": "4.0.0-rc2-240",
    //"System.AppDomain": "2.0.5",
    "Blog.Core": "1.0.0-*",
    "Blog.Domain": "1.0.0-*",
    "Blog.Model": "1.0.0-*",
    "Blog.Services": "1.0.0-*",
    "Microsoft.AspNetCore.Session": "1.0.0-rc2-final",
    "Microsoft.Extensions.Caching.Memory": "1.0.0",
    "Microsoft.Extensions.Caching.Abstractions": "1.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    }
  },

  "frameworks": {
    "net462": {
      "frameworkAssemblies": {
        "System.Drawing": "4.0.0.0"
      }
    }
  },
  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },
  "runtimeOptions": {
    "gcServer": true
  },
  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

Blog.Services Project.json

{
  "version": "1.0.0-*",

  "dependencies": {
    "Blog.Core": "1.0.0-*",
    "Blog.Domain": "1.0.0-*",
    "Blog.Model": "1.0.0-*",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "NETStandard.Library": "1.5.0-rc2-24027"
  },
  //"buildOptions": {
  //  "emitEntryPoint": true
  //},

  "frameworks": {
    "net462": {}
  },

  "tools": {
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  }
}
@ErikEJ
Copy link
Contributor

ErikEJ commented Jun 28, 2016

Looks like you still have many rc2 packages..,

@rowanmiller
Copy link
Contributor

Yep, you need to be on a full set of 1.0.0 packages (or 1.0.0-preview2 for tooling packages). Closing this out as we are confident that is the issue, but feel free to reply if that is not the case.

@lucamorelli
Copy link

lucamorelli commented Jun 30, 2016

I have the problem #2 too after the update of an application to rtm and openiddict alpha2-0331
this is the project.json

  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "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.Extensions.Configuration.UserSecrets": "1.0.0",
    "Microsoft.EntityFrameworkCore": "1.0.0",
    "MyLibrary": "1.0.0-*",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "OpenIddict": "1.0.0-alpha2-0331"
  },

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

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

@rowanmiller
Copy link
Contributor

@lucamorelli you should remove the imports from project.json. see https://docs.efproject.net/en/latest/miscellaneous/rc2-rtm-upgrade.html#net-core-remove-imports-in-project-json for more details (also see #5886).

If you still see issues after that, then open up a new issue.

@kevinchalet
Copy link

@lucamorelli FYI, OpenIddict was just updated to target ASP.NET Core/.NET Core/Entity Framework Core RTM. The error you're using should be fixed when moving to the latest OpenIddict builds.

@bspitzer
Copy link

Here is how I got past this one:

  1. I changed my MVC Dependency to:
    "Microsoft.AspNetCore.Mvc": "1.0.0",

  2. saved my project.json file and waited for the package restore to complete

  3. Ran "dotnet restore" from the package manager console.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants