Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly 'System.Security.Principal.Windows'

Tags:

c#

asp.net

Solution has compiled successfully, but after I added an existing class file to the project, this error appeared:

The specified task executable "csc.exe" could not be run. Could not load file or assembly 'System.Security.Principal.Windows, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. MvcApplicationRegister

I installed System.Security.Principal.Windows package By NuGet, but error still appears.

like image 461
Mohammad Sadeghi Avatar asked Aug 18 '18 13:08

Mohammad Sadeghi


2 Answers

I had the same issue after I upgraded Microsoft.Net.Compiler from 2.8.2 to 2.9.0. After I downgraded to 2.8.2 projects compiled without any errors.

like image 161
Synthie Avatar answered Oct 17 '22 18:10

Synthie


None of the previous answers worked for me.

The problem was that I didn't have the .NET Compiler Platform SDK installed.

To solve, open Visual Studio Installer, choose "Modify", and under the "Invididual Component" tab, check the .NET Compiler Platform SDK, and confirm your changes by clicking "Modify".

enter image description here

After I installed it and reopened Visual Studio, the problem is gone.

like image 37
MMalke Avatar answered Oct 17 '22 18:10

MMalke