views:

112

answers:

1

I've got a WPF webcam component's source-code from Codeplex that I'm trying to port from .NET 3.5 to .NET 4.0.

Compiles just fine under both targets, but in the .NET 4.0 version, it crashes when running the app with a System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception at the line moniker.BindToObject(bindCtx, null, ref filterId, out filterObject); in this method:

internal static IBaseFilter CreateFilter(string filterMoniker)
        {
            object filterObject = null;
            IBindCtx bindCtx = null;
            IMoniker moniker = null;

            int n = 0;

            if (CreateBindCtx(0, out bindCtx) == 0)
            {
                if (MkParseDisplayName(bindCtx, filterMoniker, ref n, out moniker) == 0)
                {
                    Guid filterId = typeof(IBaseFilter).GUID;
                    try
                    {
                        moniker.BindToObject(bindCtx, null, ref filterId, out filterObject);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex+"");
                    }

                    Marshal.ReleaseComObject(moniker);
                }
                Marshal.ReleaseComObject(bindCtx);
            }
            return filterObject as IBaseFilter;
        }

Any idea why and how to fix it?

The camera is a Genius Eye 110, and I'm working under Windows XP SP2.

A: 

Hi Luvieere,

I downloaded the code, compiled it with 4.0 and it worked for me. Are you sure that you have a webcam that your system knows about? Perhaps you can check the device manager to verify.

If my camera is not plugged it, the program throws an exception similar to yours.

-Matt

Matt
Camera is a Genius Eye 110, connected and functional. Compiling and running on .NET 3.5 SP1 works, whereas on 4.0 throws the exception I was mentioning.
luvieere