我有一个来自Codeplex的 WPF 网络摄像头组件的源代码,我正在尝试将其从 .NET 3.5 移植到 .NET 4.0。
在两个目标下都可以正常编译,但在 .NET 4.0 版本中,在此方法System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception
的行中运行带有 a 的应用程序时会崩溃: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 下工作。