# Can't use OCX components on x64 - failed to create AxHost

**URL:** <https://forum.commonvisionblox.com/t/cant-use-ocx-components-on-x64-failed-to-create-axhost/487>\
**Category:** .Net API\
**Tags:** activex\
**Created:** [July 3, 2018, 2:26pm UTC](https://forum.commonvisionblox.com/t/cant-use-ocx-components-on-x64-failed-to-create-axhost/487 "2018-07-03T14:26:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BaerTram](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/baertram/32/54_2.png) [@BaerTram](https://forum.commonvisionblox.com/u/BaerTram)\
**Post date:** [July 3, 2018, 2:26pm UTC](https://forum.commonvisionblox.com/t/cant-use-ocx-components-on-x64-failed-to-create-axhost/487/1 "2018-07-03T14:26:37Z")

</div>

So, I was plying around with OCX components, or rather I tried to do so unsuccessfully… I’m getting error pop-ups when trying to apply an OCX component to a form by dragging and dropping it over from the Toolbox. I get an error message that says “failed to create axhost”, see screenshot.

![failed%20to%20create%20component](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/d431a5d6e6a8f23285b2c94ba1546a60da47dec7.png)

Any suggestions on how to deal with that? The weird thing is, it worked in the past and I’m not sure what I’m doing wrong just now. Also, I can compile the CVB tutorials just fine but I can’t add any additional OCX components.

I’m using CVB 13 64bit, C# and VS 2015.

---

<div class="post-metadata">

**Author:** ![Frank](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/frank/32/42_2.png) [@Frank](https://forum.commonvisionblox.com/u/Frank)\
**Post date:** [July 4, 2018, 8:51am UTC](https://forum.commonvisionblox.com/t/cant-use-ocx-components-on-x64-failed-to-create-axhost/487/2 "2018-07-04T08:51:04Z")

</div>

This might be a Visual Studio issue. There are two ways you can compile for 64 bit: x64 as target platform and AnyCPU as target platform. If CVB 64 bit is installed, both variants should do the same, from what I understand.

Applying OCX to a form while the target platform is set to x64 worked fine in the past, for instance with VS 2008 and 2010. Though, the behavior seems to have change in 2015 and 2017.

Also, this is only an issue for OCX components of which VS does not yet have created the local wrappers and references like these ones here:

![image](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/2b01aa8ecdd2591fe061b3b009b4577d003bef91.png)

These wrappers and references are created by VS automatically when an OCX is placed on the form for the first time, as far as I know - Something about this behavior seems to have changed.

To sum up: change the target platform to AnyCPU and it all should work fine.

---

<div class="post-metadata">

**Author:** ![BaerTram](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/baertram/32/54_2.png) [@BaerTram](https://forum.commonvisionblox.com/u/BaerTram)\
**Post date:** [July 5, 2018, 7:47am UTC](https://forum.commonvisionblox.com/t/cant-use-ocx-components-on-x64-failed-to-create-axhost/487/3 "2018-07-05T07:47:53Z")

</div>

That worked, thanks!

I’m always a bit hesitant to use AnyCPU since I’m not really sure what it does. I only use x64 as target platform for 64 bit builds.

---

<div class="post-metadata">

**Author:** ![illusive](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/illusive/32/61_2.png) [@illusive](https://forum.commonvisionblox.com/u/illusive)\
**Post date:** [July 5, 2018, 9:02am UTC](https://forum.commonvisionblox.com/t/cant-use-ocx-components-on-x64-failed-to-create-axhost/487/4 "2018-07-05T09:02:24Z")

</div>

This is really weird behavior, and it would in fact be interesting to learn what the logic behind requiring _AnyCPU_ for ActiveX instantiation in the Forms Designer is (after all, the Forms Designer is still a 32 bit process and will always open and parse the type library of the installed 32 bit version of the ActiveX control). You’re right in that this used to work in the past.

One thing I’d like to point out is that _AnyCPU_ and _x64_ are not the same thing. You’re right if you say that they _feel_ like the same thing if you are launching your application built with _AnyCPU_ on a 64 bit system, but conceptually, _AnyCPU_ leaves the architecture decision to the operating system, whereas _x64_ will insist on an x86-64 based system. Therefore _AnyCPU_ programs may also start on a plain x86 operating system or even on one of the rare Windows ARM builds - as long as the things they depend on are available (which, for :cvb:, is unfortunately not that easy).

The fact that the :cvb: tutorials for the .Net languages for 64 bit are all set to _AnyCPU_ is more than anything else a coincidence: When the first C# and [VB.Net](http://VB.Net) tutorials were written some 15 years ago, _AnyCPU_ was the default that Visual Studio did come up with and it did not really make much of a difference which setting you chose for lack of a 64 bit operating system. When the first WOW-capable version of the 32 bit build of :cvb: was built, the tutorials for 32 bit were switched to _x86_, while those that entered the 64 bit build were simply left at _AnyCPU_…
