title: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)): ActiveX and C# Console Application
body: <p>So, I am playing around with ActiveX and C# and ways how both of them can work together. the thing is I have hit the wall right in the beginning with mentioned error. Steps I have followed:</p>
  
  <p>In VS2010 I selected MFC  ActiveX Control project. Then I added a method "SHORT Multiply( SHORT a, SHORT b);" by clicking the Add method option in the menu that pops when you right click _DProjectname under ProjectnameLib in solution explorer. The code for the method is as follows:</p>
  
  <pre><code>    SHORT CSampleProgramActivex01Ctrl::Multiply(SHORT a, SHORT b)
      {
        AFX_MANAGE_STATE(AfxGetStaticModuleState());
  
       // TODO: Add your dispatch handler code here
  
       return ( a * b);
      }
  </code></pre>
  
  <p>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 above mentioned error. I have searched the error on the internet but no clear solution is mentioned. Any help appreciated. If you guys want clarification, let me know.</p>