0

So I have an old ActiveX object that I want to create a testing harness around. I use C# with .Net primarily so I figured that would be the best language to use. The ActiveX object is used to perform various functions and return values; it's not something I would use as a form control.

I've made some attempts, all which have ended horribly. I tried creating a C# console app and getting the .ocx as a reference (it's registered with the system so I just used the list of com objects under references). I then created a class for the object. This class has a variable to hold the object (the variable is an interface and then initialized as an object) and one function which calls on a function inside the object. This returns "Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))" The control is not imbeded, nor can it be according to error messages, if that makes a difference.

My next attempt was to add the control as a form object, even though it really isn't (function wise at least; there is not graphical output). To do this I simply imported the .ocx as a control (right click on a control, select "choose items") and put it in the form. I then called the control in the constructor after InitializeComponent(). This ends up in "Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))". As I said earlier I have registered the class. I ran regsvr32 and it said everything was fine.

Any ideas? Am I going about this the wrong way or am I missing something stupid simple (or really complex)?

Dropn Fbombs
  • 119
  • 3
  • 15
  • 2
    Are you compiling as x86? – rene Apr 14 '14 at 20:35
  • 2
    Are you running on a 64bit Windows, by any chance? – Vince Apr 14 '14 at 20:35
  • That was it, atleast for the form version (only need one to work). I did the switch for the console one but still couldn't get it to work and had completely forgotten about switching the form to x86. Thank you! – Dropn Fbombs Apr 14 '14 at 20:43
  • 1
    The winform project works because its main method is marked with `[STAThread]` what is probably needed for your OCX. For reference look at [this](http://stackoverflow.com/questions/1361033/what-does-stathread-do) – rene Apr 14 '14 at 20:49
  • Thank you. I certainly need to learn more about interacting with COM objects. My experience has been very limited with them so far. – Dropn Fbombs Apr 14 '14 at 20:55

0 Answers0