无法在C#中实例化COM组件 - 错误80070002 [英] Can't instantiate COM component in C# - error 80070002
本文介绍了无法在C#中实例化COM组件 - 错误80070002的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试在我的计算机上实例化Windows Media Player COM对象:
I'm attempting to instantiate a Windows Media Player COM object on my machine:
Guid mediaPlayerClassId = new Guid("47ac3c2f-7033-4d47-ae81-9c94e566c4cc");
Type mediaPlayerType = Type.GetTypeFromCLSID(mediaPlayerClassId);
Activator.CreateInstance(mediaPlayerType); // <-- this line throws
执行最后一行时,会出现以下错误:
When executing that last line, I get the following error:
System.IO.FileNotFoundException was caught
Message="Retrieving the COM class factory for component with CLSID {47AC3C2F-7033-4D47-AE81-9C94E566C4CC} failed due to the following error: 80070002."
Source="mscorlib"
StackTrace:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at MyStuff.PreviewFile(String filePath) in F:\Trunk\PreviewHandlerHosting\PreviewHandlerHost.cs:line 60
InnerException:
同样的代码适用于其他开发人员机器和最终用户机器。由于某些原因,它只在我的机器上失败。原因可能是什么?
This same code works on other developer machines and end user machines. For some reason, it only fails on my machine. What could be the cause?
推荐答案
80070002是未找到文件的错误。
80070002 is a File Not Found error.
我的猜测是你的机器缺少依赖。尝试通过depends.exe运行com组件,以查看是否安装了所有必需的库。
My guess is your machine is missing a dependency. Try running the com component through depends.exe to see if you have all of the required libraries installed.
这篇关于无法在C#中实例化COM组件 - 错误80070002的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文