ASP.NET Core - problems and fixes

I am working on a project based on ASP.NET Core for few months already. During this time I’ve had various problems I had to fix. Recently I converted my application to RC2 version release few weeks ago. I thought it might be good idea to write a post listing problems I had with an information how to fix them. I hope there will be some people who will find it useful.

Problem starting you application

You can build your app, but get an exception when starting it:

An unhandled exception of type 'System.TypeLoadException' occurred in Program.exe

Additional information: Method 'get_Sources' in type


  • check if all packages are rc2-final - you might have an old rc1 reference hidden somewhere
  • Run dotnet restore –no-cache
  • remove configuration packages from %userprofile%.nuget\packages and run dotnet restore again

Adding ‘old’ class library project as a reference

I work on a project where I am using ‘old style’ class library projects. Visual Studio still has problems adding such references to core projects and gives you an error ‘Unable to resolve dependency’. This is how you can fix this:

  1. Close Visual Studio
  2. Delete all wrap folders in the solution
  3. Delete all global.json files in the solution
  4. Temporarily delete all sln files in subfolders of the solution
  5. Call dnu wrap …csproj for all dependency projects
  6. Call dnu restore
  7. Open Visual Studio again.

Visual Studio doesn’t see referenced class library project

If Visual Studio 2015 doesn’t see class library project you have referenced, but building works just fine. It may be a problem with project.lock.json files:

  1. close Visual Studio
  2. delete all project.lock.json files in solution
  3. open VS

EntityFramework Core migrations in Class Library projects

EF Core preview1 tools don’t support running migrations from class library projects. Unfortunately there is no fix for that problem. You need to create a temporary application project, where you will copy your db context and models classes and run your migration commands.

Other posts

You might also be interested in these posts about ASP.NET Core:


Michał Dymel's Picture

About Michał Dymel

Passionate software developer interested in Web Development, .NET, Angular2, Architecture and security. Currently doing remote consulting.

Szczecin, Poland
Web Analytics