我有一个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