Unable to instantiate COM component in C # - error 80070002

I am trying to create an instance of 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 this 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: 

The same code works on other development machines and end-user machines. For some reason, it just fails on my machine. What could be the reason?

+3
source share
4 answers

80070002 - file error not found.

My guess is that there is no dependency on your machine. Try running the com component through the depend.exe file to see if all the necessary libraries are installed.

+5
source

, 0x80070002 , , , DLL COM .

+2

. , - , .

0

. - asp, .net. , . ? ? -, 0x80070002.

, , . - , , .. (Iis 6).

, regasm , , , , dev. .

Conclusion: sounds like a permission issue, but what do I know ..

0
source

Source: https://habr.com/ru/post/1710696/


All Articles