HighTechTalks DotNet Forums  

"Managed Debugging Assistant 'LoaderLock' has detected a problem in

Dotnet Framework (CLR) microsoft.public.dotnet.framework.clr


Discuss "Managed Debugging Assistant 'LoaderLock' has detected a problem in in the Dotnet Framework (CLR) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
mohan (AT) tek (DOT) com
 
Posts: n/a

Default "Managed Debugging Assistant 'LoaderLock' has detected a problem in - 06-05-2006 , 02:32 AM






Hi all,

I have ported my VB.Net project from VS2003 to VS2005. I am facing two
issues while running my applications:
Issue1:
I am calling some managed dlls (developed in C#) from my Vb .net .
Whne I
debug the code,Iam getting the following Error message.

"Managed Debugging Assistant 'LoaderLock' has detected a problem in
'F:\VBSource\bin\Debug\TekRobo.exe'.
Additional Information: DLL 'F:\VBSource\bin\Debug\Tekspyhook.dll' is
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."

How to resolve the above error?

i ssue2:

I am calling mainform instance (static variable) from other VB .net
modules
from the same projects.In VS2003 ,I did not face any issues. But in
VS2005 ,I
am getting the following exception. P.s I am running the application
under
thread.

"A first chance exception of type 'System.InvalidOperationException'
occurred in System.Windows.Forms.dll
Additional information: Cross-thread operation not valid: Control
'StressTest' accessed from a thread other than the thread it was
created on."

it would be greatful ,if any one help me to resolve the above two
issues.
Thanks
Mohan
Was this


Reply With Quote
  #2  
Old   
Greg Young
 
Posts: n/a

Default Re: "Managed Debugging Assistant 'LoaderLock' has detected a problem in - 06-05-2006 , 06:18 AM






Problem 1: Are you using any other dlls? Basically it is saying that the
TekSpyHook DLL is accessing another DLL in its DLLMain which is a big no no.
Is this your own DLL or from somewhere else?

Problem 2: You can only access controls on the thread that they were created
on. You should be using Invoke/BeginInvoke in order to marshal operations on
controls back to the main thread. If you do a google on VB.NET control
invoke (or begininvoke) you can find a ton of articles .. here is one from
msdn mag
http://msdn.microsoft.com/msdnmag/is...s/default.aspx.
Basically in 2.0 its alerting you that you have a threading problem where as
it did not in 1.x.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung

<mohan (AT) tek (DOT) com> wrote

Quote:
Hi all,

I have ported my VB.Net project from VS2003 to VS2005. I am facing two
issues while running my applications:
Issue1:
I am calling some managed dlls (developed in C#) from my Vb .net .
Whne I
debug the code,Iam getting the following Error message.

"Managed Debugging Assistant 'LoaderLock' has detected a problem in
'F:\VBSource\bin\Debug\TekRobo.exe'.
Additional Information: DLL 'F:\VBSource\bin\Debug\Tekspyhook.dll' is
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."

How to resolve the above error?

i ssue2:

I am calling mainform instance (static variable) from other VB .net
modules
from the same projects.In VS2003 ,I did not face any issues. But in
VS2005 ,I
am getting the following exception. P.s I am running the application
under
thread.

"A first chance exception of type 'System.InvalidOperationException'
occurred in System.Windows.Forms.dll
Additional information: Cross-thread operation not valid: Control
'StressTest' accessed from a thread other than the thread it was
created on."

it would be greatful ,if any one help me to resolve the above two
issues.
Thanks
Mohan
Was this




Reply With Quote
  #3  
Old   
mohan (AT) tek (DOT) com
 
Posts: n/a

Default Re: "Managed Debugging Assistant 'LoaderLock' has detected a problem in - 06-06-2006 , 03:25 AM



Hi Greg,

Thanks very much.

Problem1:
I am using some managed dll which will be calling the unmaged
dll(tekSpy.dll).
The unmanaged dll is calling win32 dll for doing code injection. i.e
it will be accesing managed exe through hook process.

Once I unchecked the Loder lock exception thrown option from
Debug->Exceptions,I am not getting the messgae. But I am not sure that
, this will be the permanent solution.

Pls let me know your thoughts.

Problem 2:
I got your point. But I dont know how to call main form instance
through control.invoke.
Especially how to assign mainform instance to delegate?

Thanks,
Mohan



Greg Young wrote:
Quote:
Problem 1: Are you using any other dlls? Basically it is saying that the
TekSpyHook DLL is accessing another DLL in its DLLMain which is a big no no.
Is this your own DLL or from somewhere else?

Problem 2: You can only access controls on the thread that they were created
on. You should be using Invoke/BeginInvoke in order to marshal operations on
controls back to the main thread. If you do a google on VB.NET control
invoke (or begininvoke) you can find a ton of articles .. here is one from
msdn mag
http://msdn.microsoft.com/msdnmag/is...s/default.aspx.
Basically in 2.0 its alerting you that you have a threading problem where as
it did not in 1.x.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung

mohan (AT) tek (DOT) com> wrote in message
news:1149489172.672028.192690 (AT) i39g2000cwa (DOT) googlegroups.com...
Hi all,

I have ported my VB.Net project from VS2003 to VS2005. I am facing two
issues while running my applications:
Issue1:
I am calling some managed dlls (developed in C#) from my Vb .net .
Whne I
debug the code,Iam getting the following Error message.

"Managed Debugging Assistant 'LoaderLock' has detected a problem in
'F:\VBSource\bin\Debug\TekRobo.exe'.
Additional Information: DLL 'F:\VBSource\bin\Debug\Tekspyhook.dll' is
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."

How to resolve the above error?

i ssue2:

I am calling mainform instance (static variable) from other VB .net
modules
from the same projects.In VS2003 ,I did not face any issues. But in
VS2005 ,I
am getting the following exception. P.s I am running the application
under
thread.

"A first chance exception of type 'System.InvalidOperationException'
occurred in System.Windows.Forms.dll
Additional information: Cross-thread operation not valid: Control
'StressTest' accessed from a thread other than the thread it was
created on."

it would be greatful ,if any one help me to resolve the above two
issues.
Thanks
Mohan
Was this



Reply With Quote
  #4  
Old   
Greg Young
 
Posts: n/a

Default Re: "Managed Debugging Assistant 'LoaderLock' has detected a problem in - 06-06-2006 , 05:25 PM



1) Turning it off is not the right way to handle it ... it can cause
seemingly random problems at runtime (i.e. app just hangs without ever
hitting your code on some machines) the code that is in there is not safe
....

2) There are examples up on the web (all over the place) .. just google on
control begininvoke .. basically you make a method that does the accessing
... then you call control.invoke/begininvoke on the other thread causing it
to message the main thread to run your method (delegate)

<mohan (AT) tek (DOT) com> wrote

Quote:
Hi Greg,

Thanks very much.

Problem1:
I am using some managed dll which will be calling the unmaged
dll(tekSpy.dll).
The unmanaged dll is calling win32 dll for doing code injection. i.e
it will be accesing managed exe through hook process.

Once I unchecked the Loder lock exception thrown option from
Debug->Exceptions,I am not getting the messgae. But I am not sure that
, this will be the permanent solution.

Pls let me know your thoughts.

Problem 2:
I got your point. But I dont know how to call main form instance
through control.invoke.
Especially how to assign mainform instance to delegate?

Thanks,
Mohan



Greg Young wrote:
Problem 1: Are you using any other dlls? Basically it is saying that the
TekSpyHook DLL is accessing another DLL in its DLLMain which is a big no
no.
Is this your own DLL or from somewhere else?

Problem 2: You can only access controls on the thread that they were
created
on. You should be using Invoke/BeginInvoke in order to marshal operations
on
controls back to the main thread. If you do a google on VB.NET control
invoke (or begininvoke) you can find a ton of articles .. here is one
from
msdn mag
http://msdn.microsoft.com/msdnmag/is...s/default.aspx.
Basically in 2.0 its alerting you that you have a threading problem where
as
it did not in 1.x.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung

mohan (AT) tek (DOT) com> wrote in message
news:1149489172.672028.192690 (AT) i39g2000cwa (DOT) googlegroups.com...
Hi all,

I have ported my VB.Net project from VS2003 to VS2005. I am facing two
issues while running my applications:
Issue1:
I am calling some managed dlls (developed in C#) from my Vb .net .
Whne I
debug the code,Iam getting the following Error message.

"Managed Debugging Assistant 'LoaderLock' has detected a problem in
'F:\VBSource\bin\Debug\TekRobo.exe'.
Additional Information: DLL 'F:\VBSource\bin\Debug\Tekspyhook.dll' is
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."

How to resolve the above error?

i ssue2:

I am calling mainform instance (static variable) from other VB .net
modules
from the same projects.In VS2003 ,I did not face any issues. But in
VS2005 ,I
am getting the following exception. P.s I am running the application
under
thread.

"A first chance exception of type 'System.InvalidOperationException'
occurred in System.Windows.Forms.dll
Additional information: Cross-thread operation not valid: Control
'StressTest' accessed from a thread other than the thread it was
created on."

it would be greatful ,if any one help me to resolve the above two
issues.
Thanks
Mohan
Was this





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.