I was getting this error when I had a web project and a class library project in the same solution. 

System.IO.FileNotFoundException Could not load file or assembly System.Security.Principal.Windows

I wasn't able to build the class library project.

This was because the NuGet package Microsoft.Net.Compilers was not installed on both projects.

It was installed on the web project but not on the class library project.

So to fix this, go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution

Then as the image shows, in the Installed tab:

  1. Search for Microsoft.Net.Compilers
  2. Select the projects which do not have the project installed yet
  3. Choose the same version that is already installed on the other project
  4. Click Install

Once you have installed it. You should be able to do a clean and then a rebuild without the error now.

Want to thank me?

If I've helped you out and you want to thank me, why not buy me a coffee?

About the author

Paul Seal

Umbraco MVP and .NET Web Developer from Derby (UK) who specialises in building Content Management System (CMS) websites using MVC with Umbraco as a framework. Paul is passionate about web development and programming as a whole. Apart from when he's with his wife and son, if he's not writing code, he's thinking about it or listening to a podcast about it.

Related Posts

How to fix the error "Authentication failed because the remote party has closed the transport stream"

This post will show you how to fix the error "Authentication failed because the remote party has clo…

Read Post

How to solve the error "Could not load file or assembly 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version= ..."

This post will show you how to solve the error "Could not load file or assembly 'Microsoft.CodeDom.P…

Read Post

How to use Donut Caching in Umbraco and MVC

In this post I show you how easy Donut Caching is to use in Umbraco and MVC. It's very clever and no…

Read Post

How to start working with Umbraco v8

In this post I give you step by step instructions for getting Umbraco v8 forked, checked out and wor…

Read Post