Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 120013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:44:38+00:00 2026-05-11T03:44:38+00:00

I have recently integrated the .NET NLog logging component into one of our applications

  • 0

I have recently integrated the .NET NLog logging component into one of our applications which developed purely in unmanaged code (C++ and VB6 components compiled in Visual Studio 6). We have a bunch of C++ application talking to NLog via a COM interface.

Everything is working fine at the moment but I do notice that the following message pops up (in the output window if debugging the C++ component in VS6; as a prompt in the IDE if debugging NLog via VS 2005) during program termination:

LoaderLock was detected Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

The DllMain is as follows:

extern 'C' BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) {     if (dwReason == DLL_PROCESS_ATTACH)     {         _Module.Init(ObjectMap, hInstance);         DisableThreadLibraryCalls(hInstance);     }     else if (dwReason == DLL_PROCESS_DETACH)         _Module.Term();     return TRUE;    // ok } 

My guess is that _Module.Term(); now includes the releasing of some .NET references (I am keeping a reference to a NLog object in one of my C++ classes to avoid having to instantiate and release each time) which is causing this warning to pop up.

My question: is this safe to ignore? If it isn’t, what is a good workaround? (the best I can think of is to instantiate a reference to that NLog object and release it every time I want to write to the log file…not the most elegant of solutions)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:44:39+00:00Added an answer on May 11, 2026 at 3:44 am

    It is most definitely not safe to ignore this message. If you hit this message, you’ve almost certainly created a real loader lock policy violation. This is a very serious error and can cause unpredictable behavior in a program (including deadlock).

    The best way to avoid this is to not access any other .Net Objects/Functions directly or indirectly inside of DLL main. For your case, it’s probably best to use a different cache policy. Perhaps create a ref counted object to hold the .Net reference. That way the object will be released before DllMain is called for unload (the dll can’t be unloaded until all of your objects are destroyed).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java software that was recently integrated into another Java software (which
I have recently merged together 5 of my stand-alone projects into one project to
I have recently integrated in a HUD method into my XNA game project and
We have a application which integrates a 3rd party scanning component - Dynam .NET
I have recently started learning CUDA and I've integrated my CUDA into MS Visual
I have recently taken on a project in which I need to integrate with
I have been looking at protobuf-net recently and protocol buffers and so far it
Recently, I was trying to prototype some jQuery-based menu into ASP.NET MVC. Just to
I have recently integrated facebook comments on my photo gallery. I am facing a
We recently added a feature to our software that requires .NET 2.0 SP2. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.