Take the 2-minute tour ×

I try to create the same COM object instance from .Net Framework 4.0 console and windows forms application.

 var t = Type.GetTypeFromProgID("MyProgID");
 dynamic req = Activator.CreateInstance(t);

While my console application tells me:

System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM cla
ss factory for component with CLSID {CF2D8AF3-287C-4107-8790-D37F169E2475} faile
d due to the following error: 80040154 Class not registered (Exception from

Windows forms application creates instance without exceptions.

What can be wrong here?

In both cases I have [STAThread] attribute applied to "Program" class.

share|improve this question
What is the COM object you are trying to create? –  Bobby Alexander Apr 11 '11 at 6:15
That's my own com object instance. Thank you, @Bobby, i have found the issue –  Andrew Florko Apr 11 '11 at 6:19
add comment

1 Answer

I have found the issue.

COM objects work only in x86 environment. While my windows forms application was builded for x86 only, my console was "Any CPU" that provided error in x64 environment.

After I changed Platform Target for console application everything comes OK.

share|improve this answer
Dont forget to mark your answer as the correct one. –  Bobby Alexander Apr 11 '11 at 16:58
add comment

Your Answer


