Link to home
Start Free TrialLog in
Avatar of PingPhotonics
PingPhotonicsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

C#.NET - Adding my ActiveX control to my Form throws an Exception

See the screenshot of the exception produced when I try and drag and drop my newly created and registered ActiveX control

My ActiveX control was originally written using Visual Studio 2003 for Windows XP (32-bit)
I used Visual Studio 2008 and recompiled it for 64-bit Windows. I set the platform to x64.
It compiled OK with no errors I then registered it OK from the command line (had to "Run as Administrator") using regsvr32.

I then added my ActiveX (*.ocx) control to by ToolBox. When I dragged my control onto my Windows form I  got the attached error (see the screenshot). The error starts off;

Failed to create component 'AxHost'. The error message follows: 'System .BadImageFormatException: A wrapper assembly is not registered for this type library. at System.Windows.Forms.Design.DocumentDesigner....

Any ideas whats happening here.  Anyone had a similar problem that they managed to fix?

Thanks
activeX-error.png
Avatar of Janusz Czopowik
Janusz Czopowik
Flag of United States of America image

It seems like your ocx image is either corrupted or built using format that is not up to the standard of the CLR, or it is built as 64-bit image in 32 bit app or possible vice versa.
Are you able to rebuild your ActiveX?
Avatar of PingPhotonics

ASKER

Hi John
Yes I have no problem rebuilding my ActiveX
Does problem persist after rebuilding?
ASKER CERTIFIED SOLUTION
Avatar of PingPhotonics
PingPhotonics
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial