I have created MFC ActiveX project in VS 2010 using C++. I have added just one function "Add" to the project by clicking the Add method option in the menu that pops when you right click _DProjectname under ProjectnameLib in solution explorer.

SHORT CSampleProgramActivex01Ctrl::Add(SHORT a, SHORT b)

     // TODO: Add your dispatch handler code here

     return ( a + b);

Now I have created a simple C# console application that references the generated COM file and when I try to use the method, the application stops with the error: Catastrophic failure(Exception from HRESULT: 0x8000FFFF(E_UNEXPECTED)).

Does anybody can give me hint why I am running into this error

I don't know whether this is considered as solving the problem or not but I found a workaround:

First instead of C# console application, I created C# windows form application. After creating the form, I have added the whole ocx as component in the toolbox. You do this by right-clicking the Toolbox types in Toolbox menu. In the new menu, you click Choose Items. This pops up new menu and in that select the COM tab and in that check your COM component and the COM component will be added to the Toolbox menu. Now drag and drop the component on the menu and you should be good to go.

This seems to be workaround that everybody is following. Not neat but that is the norm I think.