title | ms.date | ms.topic | f1_keywords | helpviewer_keywords | ms.assetid | author | ms.author | |||
---|---|---|---|---|---|---|---|---|---|---|
/CLRUNMANAGEDCODECHECK (Remove SuppressUnmanagedCodeSecurityAttribute) |
09/27/2018 |
reference |
|
|
73abc426-dab0-45e2-be85-0f9a14206cc2 |
corob-msft |
corob |
/CLRUNMANAGEDCODECHECK specifies that the linker does not apply xref:System.Security.SuppressUnmanagedCodeSecurityAttribute to linker-generated PInvoke
calls from managed code into native DLLs.
/CLRUNMANAGEDCODECHECK[:NO]
By default, the linker applies the SuppressUnmanagedCodeSecurityAttribute to linker-generated PInvoke
calls. When /CLRUNMANAGEDCODECHECK is in effect, SuppressUnmanagedCodeSecurityAttribute is removed. To explicitly apply the SuppressUnmanagedCodeSecurityAttribute to linker-generated PInvoke
calls, you can use /CLRUNMANAGEDCODECHECK:NO.
The linker only adds the attribute to objects that are compiled using /clr or /clr:pure. However, the /clr:pure compiler option is deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017.
A PInvoke
call is generated by the linker when the linker cannot find a managed symbol to satisfy a reference from a managed caller but can find a native symbol to satisfy that reference. For more information about PInvoke
, see Calling Native Functions from Managed Code.
Note that if you use xref:System.Security.AllowPartiallyTrustedCallersAttribute in your code, you should explicitly set /CLRUNMANAGEDCODECHECK to remove the SuppressUnmanagedCodeSecurity attribute. It is a potential security vulnerability if an image contains both the SuppressUnmanagedCodeSecurity and AllowPartiallyTrustedCallers attributes.
See Secure Coding Guidelines for Unmanaged Code for more information about the implications of using SuppressUnmanagedCodeSecurityAttribute.
-
Open the project's Property Pages dialog box. For details, see Set compiler and build properties.
-
Expand the Configuration Properties node.
-
Expand the Linker node.
-
Select the Advanced property page.
-
Modify the CLR Unmanaged Code Check property.
- See xref:Microsoft.VisualStudio.VCProjectEngine.VCLinkerTool.CLRUnmanagedCodeCheck%2A.