我有一個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下工作。
你嘗試添加到您的app.config <啓動useLegacyV2RuntimeActivationPolicy = 「真」>字符串? – 2010-07-23 13:02:59
@Eugene Cheverda我剛剛嘗試在app.config中添加這個,但沒有改變:我仍然得到異常。 – luvieere 2010-07-23 13:15:58