C# – Is it possible to write an ActiveX control in C# .NET CF for windows mobile

activexccomcompact-frameworkwindows-mobile

We have a piece of legacy code in C# .NET, targetted for the Compact Framework. We would like to turn this code into an ActiveX control, which has to run on the .NET Compact Framework under Windows Mobile 5. Is it possible to implement such a control? If so, can anyone provice a good resource that explains how this can be done?

I have already searched a lot, but have not yet found a definitive answer or resource.

It would seem that this is perfectely doable on the full .NET Framework. I have also found that it is not possible to launch such a control from an unmanaged context. But otherwise, I cannot find the exact answer to my question.

Best Answer

The .NET CF does not support hosting. This means it is not possible for an unmanaged process (which most ActiveX containers such as Internet Explorer Mobile etc will be) to spin up a .NET CLR runtime when it requests your control be instantiated via the details specified within the registry. As such the .NET CF doesn't support the features the desktop version has for registering COM/ActiveX objects.

So in that respect it is not possible for you to create an ActiveX control usable by arbitary applications.

If your legacy code is C# based, what is the driving factor behind packaging it as an ActiveX control? Would a managed user control or class library be a suitable replacement?

Related Topic