Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Warning (level 1) C4747

Error Message

Calling managed 'entrypoint': Managed code may not be run under loader lock, including the DLL entrypoint and calls reached from the DLL entrypoint

The compiler found a (probable) DLL entry point compiled to MSIL. Because of potential problems with loading a DLL whose entry point has been compiled to MSIL, you are strongly discouraged from compiling a DLL entry point function to MSIL.

For more information, see Initialization of Mixed Assemblies and Linker Tools Error LNK1306.

To correct this error

  1. Do not compile the module with /clr.

  2. Mark the entry point function with #pragma unmanaged.


The following sample generates C4747.

// C4747.cpp
// compile with: /clr /c /W1
// C4747 expected
#include <windows.h>

// Uncomment the following line to resolve.
// #pragma unmanaged

BOOL WINAPI DllMain(HANDLE hInstance, ULONG Command, LPVOID Reserved) {
   return TRUE;

Community Additions

© 2015 Microsoft