Cannot perform CAS Asserts error
Published Jan 28 2019 02:09 PM 2,493 Views

“Cannot perform CAS Asserts” error may appear when you try to use a third-party library in a .NET application. This issue is related to the security implementation that protects your system from untrusted components.


The error message:

System.InvalidOperationException: Cannot perform CAS Asserts in Security Transparent methods

CAS (Code Access Security)

CAS is a security implementation included in .NET Framework to secure the system against malicious code and components.


The .NET Framework provides a mechanism for the enforcement of varying levels of trust on different code running in the same application called Code Access Security (CAS).

Microsott Docs


Root Cause

The application is probably trying to use an external library which is not trusted by CAS. You might have upgraded .NET Framework version in the development machine. If this is the case, update your code as per the new CAS requirements that are introduced with the new .NET Framework.

More information about major CAS changes in .NET Framework 4.0: Link


Solution 1: Full-trust

Make your application a “full-trust” application unless the application is marked as security-transparent.

Solution 2: GAC

Add the external DLLs into GAC (Global Assembly Cache) by using Gacutil.exe. This article explains steps to install an assembly into GAC. Gacutil.exe comes with Windows SDK and Visual Studio.

Solution 3: Code changes

Change your application’s code to make it compatible with the new CAS implementations. This is the best solution in the long-term. Refer to this article for guidance.

Version history
Last update:
‎Jan 28 2019 02:09 PM
Updated by: