C# – Could not load file or assembly ‘System.Security.Principal.Windows’

asp.netc

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.

Best Answer

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.