OS Loader lock exception

W

Wilfried Mestdagh

Hi,

I'm trying out the demo version of FastReports. All is running fine in a
small test project. I just copy my code from test project into a large
application to demonstrate tomorrow but have an error in this line:

dataSet = new TfrxUserDataSetClass();

This is the exception error:

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.

It does only happen when running in the IDE (VS2005 pro). The same code
runs in a test project without errors. I have no idea where the
difference is or where to start debugging. I don't use DLL's (here and
there P/Invoke for Win32 of course) and I don't have images. Also the
target application uses Microsoft MapPoint if that could make any
difference.

Can someone give me some hints from where to start locating the source
of the problem ? I have no source code of the product.
 
W

Willy Denoyette [MVP]

| Hi,
|
| I'm trying out the demo version of FastReports. All is running fine in a
| small test project. I just copy my code from test project into a large
| application to demonstrate tomorrow but have an error in this line:
|
| dataSet = new TfrxUserDataSetClass();
|
| This is the exception error:
|
| 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.
|
| It does only happen when running in the IDE (VS2005 pro). The same code
| runs in a test project without errors. I have no idea where the
| difference is or where to start debugging. I don't use DLL's (here and
| there P/Invoke for Win32 of course) and I don't have images. Also the
| target application uses Microsoft MapPoint if that could make any
| difference.
|
| Can someone give me some hints from where to start locating the source
| of the problem ? I have no source code of the product.
|
| --
| rgds, Wilfried [MapPoint MVP]
| http://www.mestdagh.biz

You are definitely calling into a mixed mode DLL (MapPoint stuff?), which at
his turn calls into managed code from within the DllMain function.
Check following page for details on how to diagnose and possibly solve the
issue:
http://msdn2.microsoft.com/en-us/library/ms173266(VS.80).aspx


Willy.
 
W

Wilfried Mestdagh

Hi Willy,

I traced down a little bit. It is not MapPoint. It happens when I use
Weifenluo dock panel in same project [
http://sourceforge.net/forum/forum.php?forum_id=402316 ]. The problem is
that if there is a bug in A that shows up in B, then both authors will
probably say there is no bug :( Anyway I try to contact both.

But how can the use of a component give that kind of an error in another
component ?
 
W

Willy Denoyette [MVP]

| Hi Willy,
|
| I traced down a little bit. It is not MapPoint. It happens when I use
| Weifenluo dock panel in same project [
| http://sourceforge.net/forum/forum.php?forum_id=402316 ]. The problem is
| that if there is a bug in A that shows up in B, then both authors will
| probably say there is no bug :( Anyway I try to contact both.
|
| But how can the use of a component give that kind of an error in another
| component ?
|
| --
| rgds, Wilfried [MapPoint MVP]
| http://www.mestdagh.biz

I can't believe it's DocPanel, IFAIK it's CSharp code only, the OS Loader
issue is a Mixed mode C++ thing, CS assemblies don't have a DllMain function
nor are they loaded by the OS loader.

Willy.
 
W

Wilfried Mestdagh

Hi Willy,

I started a new application, and added the offending code line in the
form's Load event. Project runs normal in IDE. Then I drop a dockpanel
to main form. Now I have the exception. I'm not sure what's next to try :(
 
W

Willy Denoyette [MVP]

| Hi Willy,
|
| >> I can't believe it's DocPanel, IFAIK it's CSharp code only, the OS
Loader
| >> issue is a Mixed mode C++ thing, CS assemblies don't have a DllMain
function
| >> nor are they loaded by the OS loader.
|
| I started a new application, and added the offending code line in the
| form's Load event. Project runs normal in IDE. Then I drop a dockpanel
| to main form. Now I have the exception. I'm not sure what's next to try :(
|
| --
| rgds, Wilfried [MapPoint MVP]
| http://www.mestdagh.biz

You don't call into MapPoint code do you? Did you try to build the DocPanel
from source using VS2005?
Are you sure you and/or DocPanel doesn't call into managed C++ code?
Once again, the "OS loader lock" exception is thrown when you call into the
CLR from unmanaged code in a DllMain function, and this, only when running
in the debugger, so I would start by investigating investigate the call
stack.
Willy.
 
W

Wilfried Mestdagh

Hi Willy,
You don't call into MapPoint code do you?

No I used a brand new project as test with only this single line of code.
Did you try to build the DocPanel from source using VS2005?

Yes I did, but result was same.
Are you sure you and/or DocPanel doesn't call into managed C++ code?

YesI think so. As you already have mentioned docpanel is written in pure
C#. But I'm not sure the problem "is" in dockpanel. I think it is in
FastReport (I think it is written in Delphi.net). The problem is only
there when dockPanel is sitting on a form.

I have solved it temporary by creating the FastRecord component before
creating DockPanel. This seems to be ok now.
Once again, the "OS loader lock" exception is thrown when you call into the
CLR from unmanaged code in a DllMain function, and this, only when running
in the debugger, so I would start by investigating investigate the call
stack.

There is almost nothing in the call stack when I have the error. The
test program is only 1 line of code.

One more question: Can I tell the IDE to ignore this ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top