views:

767

answers:

3

I'm creating a C#.Net application which I want to be able to compile for "All CPUs". I also want to include a specific ActiveX control in the UI of this app, but the ActiveX control I'm trying to use does not support 32 bit. Is there some trick or work around I can use to use get this control to work?

What about embedding the ActiveX control in a Web-browser control? Would this even work?

A: 

You can't load 32 bit components in a 64 bit application, but you can wrap the component in its own process and use IPC to leverage the features of the component. Of course this may not be feasible depending on the actual component.

Brian Rasmussen
A: 

You have to run the ActiveX control in a separate 32-bit process. That's going to be difficult, it would have its own window that isn't going to be part of the UI of your 64-bit process. Although it is expressly forbidden by the SDK docs, you can try to take advantage of the Windows 3 appcompat built into the SetParent() API function. It might work.

You'll have lots of additional trouble, communicating between processes is tricky enough (you'll need Remoting or WCF), the hard part is dealing with exceptions. One process bombing with the other one surviving and never noticing that something is wrong is not going to be pretty.

Perhaps the Platform Target option starts sounding attractive?

Hans Passant
+1  A: 

Unless the ActiveX component has a 64 bit version, you cannot use it in your 64 bit application or in a 64-bit WebBrowser control. The reason is clear that 64-bit process cannot load 32-bit things.

In your case, you have to compile your application as 32-bit (x86) instead of Any CPU.

You may wonder why there is a 64-bit WebBrowser. That's simply because Microsoft ships a 64-bit IE along with 64 bit Windows.

Lex Li