Tutorial 8 - DLL Initialization

Mar 15, 2009 at 7:32 PM
Hey,

I am having trouble running Tutorial 8.  The program throws an exception on Line116:

captureDevice.InitVideoCapture(0, 0, FrameRate._30Hz, Resolution._640x480, false);

Here is the msg:

A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)

System.IO.FileLoadException was unhandled
  Message="A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)"
  Source="mscorlib"
  StackTrace:
       at System.Runtime.InteropServices.Marshal.BindMoniker(IMoniker pmk, UInt32 grfOpt, Guid& iidResult, Object& ppvResult)
       at System.Runtime.InteropServices.Marshal.BindToMoniker(String monikerName)
       at DirectX.Capture.Capture.createGraph()
       at DirectX.Capture.Capture..ctor(Filter videoDevice, Filter audioDevice)
       at GoblinXNA.Device.Capture.DirectShowCapture.InitVideoCapture(Int32 videoDeviceID, Int32 audioDeviceID, FrameRate framerate, Resolution resolution, Boolean grayscale) in C:\goblinxna\src\Device\Capture\DirectShowCapture.cs:line 242
       at Tutorial8___Optical_Marker_Tracking.Tutorial8.SetupMarkerTracking() in C:\goblinxna\tutorials\Tutorial8 - Optical Marker Tracking\Tutorial8.cs:line 116
       at Tutorial8___Optical_Marker_Tracking.Tutorial8.Initialize() in C:\goblinxna\tutorials\Tutorial8 - Optical Marker Tracking\Tutorial8.cs:line 65
       at Microsoft.Xna.Framework.Game.Run()
       at Tutorial8___Optical_Marker_Tracking.Program.Main(String[] args) in C:\goblinxna\tutorials\Tutorial8 - Optical Marker Tracking\Program.cs:line 14
  InnerException: 

I have the most recent Goblin XNA (3.1) as well as the latest ARTagWrapper for VS2008.

Here is the contents of my bin dir:

 Directory of C:\goblinxna\bin

03/15/2009  03:19 PM    <DIR>          .
03/15/2009  03:19 PM    <DIR>          ..
03/15/2009  03:19 PM           194,048 ARTagWrapper.dll
03/15/2009  03:14 PM    <DIR>          Content
03/15/2009  03:23 PM            45,056 DirectX.Capture.dll
03/15/2009  03:23 PM            61,440 DShowNET.dll
03/15/2009  02:19 PM           333,312 GoblinXNA.dll
02/06/2009  12:08 AM               120 GoblinXNA.dll.config
03/15/2009  02:19 PM           923,136 GoblinXNA.pdb
03/15/2009  02:19 PM           532,847 GoblinXNA.XML
02/06/2009  11:38 AM            75,776 Lidgren.Network.dll
05/24/2006  10:32 PM           446,464 Newton.dll
02/06/2009  10:40 PM           209,542 Newton.zi_
02/06/2009  12:06 AM            40,960 NewtonWrapper.dll
05/01/2008  12:02 PM            40,960 Tao.FreeGlut.dll
05/01/2008  12:02 PM         1,171,456 Tao.OpenGl.dll
03/15/2009  03:24 PM             1,860 template_setting.xml
03/15/2009  02:21 PM            12,288 Tutorial1 - Getting Started.exe
03/15/2009  02:21 PM            17,920 Tutorial1 - Getting Started.pdb
03/15/2009  02:21 PM            17,408 Tutorial10 - Networking.exe
03/15/2009  02:21 PM            28,160 Tutorial10 - Networking.pdb
03/15/2009  02:21 PM            13,824 Tutorial2 - Simple Animation.exe
03/15/2009  02:21 PM            19,968 Tutorial2 - Simple Animation.pdb
03/15/2009  02:21 PM            14,848 Tutorial3 - Simple 2D GUI.exe
03/15/2009  02:21 PM            22,016 Tutorial3 - Simple 2D GUI.pdb
03/15/2009  02:21 PM            14,848 Tutorial4 - 3D Object Selection.exe
03/15/2009  02:21 PM            19,968 Tutorial4 - 3D Object Selection.pdb
03/15/2009  02:21 PM            14,336 Tutorial5 - Simple Physics.exe
03/15/2009  02:21 PM            19,968 Tutorial5 - Simple Physics.pdb
03/15/2009  02:21 PM            14,336 Tutorial6 - Simple Particle Systems.exe
03/15/2009  02:21 PM            19,968 Tutorial6 - Simple Particle Systems.pdb
03/15/2009  02:21 PM            15,872 Tutorial7 - Custom Shape.exe
03/15/2009  02:21 PM            19,968 Tutorial7 - Custom Shape.pdb
03/15/2009  03:14 PM            13,824 Tutorial8 - Optical Marker Tracking.exe
03/15/2009  03:14 PM            17,920 Tutorial8 - Optical Marker Tracking.pdb
03/15/2009  02:21 PM            15,360 Tutorial9 - Advanced Features.exe
03/15/2009  02:21 PM            19,968 Tutorial9 - Advanced Features.pdb
              34 File(s)      4,429,745 bytes
               3 Dir(s)  219,163,639,808 bytes free

C:\goblinxna\bin>
Mar 15, 2009 at 8:08 PM
Edited Mar 15, 2009 at 8:15 PM
I figured it out.  I was trying to start the wrong camera.

This construct tries to grab the first camera in the list of available DirectShow devices:

captureDevice.InitVideoCapture(0, 0, FrameRate._30Hz, Resolution._640x480, false);

Using  A Win32 binary of GraphEDT (or build your own -- see DirectX Tools), I checked out what devices DirectShow is listing:


dshow

As you can see, my LifeCam is showing up as the 3rd device (counting from top).

So I changed the construct to this:

captureDevice.InitVideoCapture(2, 0, FrameRate._30Hz, Resolution._640x480, false);

And it worked!

Also, I was missing ARTag.cf (don't know if this casued the problem or not..)