If I add Direct3D calls in the test, it will fail with
Loader Lock:
Managed Debugging Assistant 'LoaderLock' has detected
a problem in 'C:\Program Files\TestDriven.NET 2.0
\ProcessInvocation.exe'.
Additional Information:
DLL 'C:\WINDOWS\assembly\GAC\Microsoft.DirectX.Direct3D
\1.0.2902.0__31bf3856ad364e35
\Microsoft.DirectX.Direct3D.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.
Sample code:
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
using System.Threading;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using System.Windows.Forms;
[TestFixture]
[Category("Basic")]
public class TestPerformance_Direct3D
{
#region Basic Tests
[Test]
public void InitDevice()
{
// initialize direct3d device
Caps caps = Manager.GetDeviceCaps
(Manager.Adapters.Default.Adapter,
DeviceType.Hardware);
CreateFlags flags;
if
(caps.DeviceCaps.SupportsHardwareTransformAndLight)
flags =
CreateFlags.HardwareVertexProcessing;
else
flags =
CreateFlags.SoftwareVertexProcessing;
PresentParameters d3dParameters = new
PresentParameters();
d3dParameters.BackBufferFormat =
Format.Unknown;
d3dParameters.Windowed = true;
d3dParameters.SwapEffect =
SwapEffect.Discard;
d3dParameters.EnableAutoDepthStencil =
true;
d3dParameters.AutoDepthStencilFormat =
DepthFormat.D16;
d3dParameters.PresentationInterval =
PresentInterval.Immediate;
UserControl control = new UserControl();
Device d3dDevice = new Device(0,
DeviceType.Hardware, control, flags, d3dParameters);
}
#endregion
}
}
Logged In: YES
user_id=586918
Have you tried making your tests run in an STA?
Logged In: YES
user_id=1186177
Originator: NO
Hi,
this seems to be a known problem with managed DirectX itself that comes to the surface under VS2005:
http://www.google.com/search?hl=en&lr=&safe=off&q=LoaderLock+DirectX
http://www.thezbuffer.com/articles/304.aspx
HTH,
Andy