2010-07-15 40 views
0

我有一个WPF摄像头组件的源代码Codeplex,我试图从.NET 3.5移植到.NET 4.0。WPF摄像头组件在.NET 4.0下崩溃

编译下两个目标就好了,但在.NET 4.0版本,它在这个方法行moniker.BindToObject(bindCtx, null, ref filterId, out filterObject);运行与System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception应用程序崩溃时:

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下工作。

+0

你尝试添加到您的app.config <启动useLegacyV2RuntimeActivationPolicy = “真”>字符串? – 2010-07-23 13:02:59

+0

@Eugene Cheverda我刚刚尝试在app.config中添加这个,但没有改变:我仍然得到异常。 – luvieere 2010-07-23 13:15:58

回答

0

我下载了代码,用4.0编译了它,它对我很有用。你确定你有一个你的系统知道的摄像头吗?也许你可以检查设备管理器来验证。

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

-Matt

+0

相机是一个天才眼睛110,连接和功能。编译和运行.NET 3.5 SP1的作品,而在4.0引发我提到的异常。 – luvieere 2010-07-20 19:42:34