在这两个目标下都能很好地编译,但在.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下工作。
发布于 2010-07-20 20:31:53
我下载了代码,用4.0编译了它,它对我来说很有效。你确定你有一个你的系统知道的摄像头吗?也许您可以检查设备管理器以进行验证。
如果我的相机没有插上电源,程序会抛出一个与你的类似的异常。
-Matt
https://stackoverflow.com/questions/3260354
复制相似问题