none
"Attempting managed execution inside OS Loader lock"

    Question

  • Hi guys,
    I've googled on this subject and I found lots of articles about it, but nothing regarding exactly the same situation.
    And I can't find a way to disable it.

    I'm running on VS 2008 sp 1, .net 3.5 sp1, Win XP Pro, Delphi 2009 and I have the following problem.

    When attempting to raise a managed com object in the initialization part of a unit inside another UNmanaged com object an exception is thrown

    "Debug Output: <mda:msg xmlns:mda="
    http://schemas.microsoft.com/CLR/2004/10/mda">   <!--         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.    -->   <mda:loaderLockMsg break="true"/> </mda:msg>  Process regsvr32.exe (3852)"

    Here the process is regsvr32.exe because I debug (run under Delphi 2009 debugger) the UNmanaged COM object registration.
    The problem occurs when I debug any unmanaged com object in whose dllmain (or image initialization) - obviously - I attempt to run managed code.

    How can my application hang and why? A reference to a good article on this subject would be greatly appreciated.

    Anyway this exception is thrown only when debugging and it's a little(!) bit annoying (with all those OutputDebugString messages), I've to click through 20 or so messages until it's passed.

    Do you know a way to add an exception for this loader exception (forgive the tautology)? May be add its type in the disabled exception list? Or set a specific registry key?

    Any help will be appreciated.

    Thanks in advance,
    Xaoc

     


    In fiery flight we would leave this hall...
    • Edited by Xaoc Friday, November 07, 2008 9:28 AM
    Friday, November 07, 2008 9:26 AM

Answers

  • There are not a lot of Delphi users in this forum.  I'd recommend a Delphi forum.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Thursday, November 13, 2008 10:38 AM
    Saturday, November 08, 2008 12:19 AM
    Moderator

All replies

  • Debug + Exceptions, open the "Managed Debugging Assistants" node and turn off the LoaderLock checkbox.
    Hans Passant.
    • Proposed as answer by Stas Berkov Monday, February 02, 2009 2:51 PM
    Friday, November 07, 2008 1:38 PM
    Moderator
  • Thank you for replying.

    And under Delphi the same thing? Cause my problem is when debugging with Delphi 2009
    Or do I need to recompile my managed COM with turned off MDA - LoaderLock or something?

    In fiery flight we would leave this hall...
    Friday, November 07, 2008 10:55 PM
  • There are not a lot of Delphi users in this forum.  I'd recommend a Delphi forum.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Thursday, November 13, 2008 10:38 AM
    Saturday, November 08, 2008 12:19 AM
    Moderator