2010-07-15 39 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