代码之家  ›  专栏  ›  技术社区  ›  luvieere

WPF网络摄像头组件在.NET 4.0下崩溃

  •  0
  • luvieere  · 技术社区  · 14 年前

    我有一个WPF网络摄像头组件的源代码来自 Codeplex 我正在尝试从.NET 3.5移植到.NET 4.0。

    在这两个目标下编译都很好,但在.NET 4.0版本中,当使用 System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception 在直线上 moniker.BindToObject(bindCtx, null, ref filterId, out filterObject); 在这种方法中:

    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;
            }
    

    知道为什么以及如何修复它吗?

    相机是 Genius Eye 110 ,我正在Windows XP SP2下工作。

    1 回复  |  直到 11 年前
        1
  •  0
  •   Matt    14 年前

    我下载了代码,用4.0编译了它,它对我很有用。您确定您的系统知道网络摄像机吗?也许您可以检查设备管理器进行验证。

    如果我的相机没有插上,程序会抛出一个与您类似的异常。

    -马特