.NET CF, AxHost, and PDC

Saw the keynote this morning?  I did!  Like the demo that included hosting the Windows Media Player ActiveX control inside of a .NET Compact Framework app?  I did!  Wonder how they did that considering that CFv2 doesn't include some of the classes you'd use to that on the desktop (such as AxHost)?  I did!  Think they were faking it?  I asked around...

Here's the secret:  the demo leveraged the implementation of those classes that Alex Fienman built for OpenNETCF.  Alex's webcast on this topic can be seen here and the associated code can be downloaded here.

Our developer community rocks!  What I love most about my job is getting to interact with cool folks like Alex who really make the Windows Mobile platform shine.


ps: it turns out that contrary to what I told everyoe who asked over the past few weeks, I'm not at PDC.  was going to do a demo in the wednesday keynote but decided to give that spot back to mike hall and stay in redmond with my dev/test teams who are hitting some critical deadlines this month on a brand new app & API set for windows mobile.  can't say what it is  yet (we aren't even talking about it at pdc) but you can definitely count on it making a huge splash in the mobile software industry next year.

Comments (13)

  1. .NET CF, AxHost, and PDC [Via:

    windowsmobile ]

    ASP.NET 2.0 Beta2 to RTM changes

    [Via: Jackie Goldstein…

  2. MDeevi says:

    Hi Robert,

    We are trying to migrate our CF1.0 project to Visual Studio 2005 Beta2, it is causing a lot of problems with UI – all screens have to be re-drawn with the new controls (the code seems to still work). Please let us know is there any upgrade or converion tools available.

    Kinldy also provide us some information about smooth migrating techniques from older .Net CF applicaitons to .Net 2.0 CF



  3. Andreas Viklund says:


    I have downloaded the AxHost project and deployed it on both a Pocket PC 2003 SE Emulator and a Windows Mobile 5.0 Emulator using Visual Studio 2005 Beta 2. But I cant get it to work!

    Everytime I press the "Media Player Demo"-button I get the same error:

    "Method not found: AllocHGlobal


    Since I am using the VS 2005 beta 2 I have renamed the two methods:

    Marshal.AllocHGlobal() ==>



    Marshal.FreeHGlobal() ==>


    but it still complains that "Method not found: AllocHGlobal…"

    What could be wrong? Is it possible to run the project on an emulator? On the webcast Axek is running the project on a Pocket PC 2003 emulator.

    Do I have to install something more or do I hve to make any other configurations on the emulator to get the project to work?

    Best regards

    Andreas Viklund

  4. Sunio says:

    I run demo application and get error message on my device:

    "An unhandled exception of type ‘System.Runtime.InteropServices.COMException’ occurred in OpenNETCF.Windows.Forms.AxHost.dll

    Additional information: Class not registered."

    I have installed Microsoft Windows Media Player 8.x for Pocket PC SDK.

    What is problem?

  5. Christos says:

    <No video when trying to host WMPCEOXC (MP8)>


    Mr. Feinman has done an excellent job and the code runs fine with MP10. However, I am trying to make it work for PocketPCs that don’t have media Player 10. I know that MP9 does not have an OCX interface. I am trying with Media Player 8 (the WMPCEOCX.dll distributed through the Media Plaeyr for CE SDK by Microsoft). This is a proper ActiveX control that I can successfuly host on Pocket Internet Explorer and through Odyssey’s CFCOM in .NET CF. I can get the control to show on a form (VB) but when I open a file I get the audio playing fine but it displays no video.

    Do you have any hints on what I should do?

    Have you tried this solution with this previous version of Media Player? I think it would be very useful for many, since Microsoft does not distribute MP10 and many vendors (e.g. HP) do not offer upgrades for most of their devices to Windows Mobile 2003 SE (incl WMP10).

    … a few details:

    From the WMPPktPC SDK I get the PlayerOCX.idl. I run MIDL to create the .tlb file, which I reference in my project. I create a class (AxWMP8) that inherits from AxHost (as shown in the webcast) and I write the simple code for properties FileName, AutoStart and Play. Everything BUT the video display works.

    I noticed in the CFCOM implementation that on their WMPCE library they have .recompose method that is not part of the Media Player OCX – do you think this is important?

    Anyway, sorry for being so long, If you can offer any help it will be highly appreciated.


  6. Ola says:

    Great code just what I was looking for.

    But oh yes there is always a but. My activeX dll does not support onClick, but I sure what it, does anyone know how to add onClick to an application? I have tried to add a control above and making it invisible, but in windows mobile 5 this is not possible.

  7. Greg says:


    I also have the class not registered problem. This is because of the shockwave flash player activex control not being installed on the device/emulator. Media player works because the ocx is obviously installed with pocket pc.

    I have an Activex control I use in a .NET app for the desktop environment, that I want to port to the mobile environment.

    I followed Mr Alex Feinmans webcast and created the .cs file from an desktop ocx using Aximp. Now how do I register the ocx when deploying to the emulator? What I did was manually enter in the clsid in the registry (for deploying to an actual device you can add the registry settings to the cab file). Is this the only way – because it didn’t seem a simple matter getting the control to self-register.

    This solves the class not registered – but now I dont know what to do next because pointing to the ocx file in the registry results in a ‘BadImageFormatException’ and ‘Make sure the file image is a valid managed assembly’. Is this because the ocx is not suited to the compact framework? What should I register on the device?

    Any help appreciated

  8. Hany Ismail says:

    When using the media player control 10 on a smart phone, the play controls – volume, play/pause and next/Previous track are missing. Is there any way to make them appear once again?

  9. bigma says:


    Addd this interface in your code.

       [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]


       public interface IWMPControls



           IWMPMedia currentItem { get; set; }


           int currentMarker { get; set; }


           double currentPosition { get; set; }


           string currentPositionString { get; }


           void fastForward();


           void fastReverse();


           bool get_isAvailable(string bstrItem);


           void next();


           void pause();


           void play();


           void playItem(IWMPMedia pIWMPMedia);


           void previous();


           void stop();


    After this, you can use play/pause and next/Previous track.

  10. anne says:

    I use Alex Fienman code and i can play windows media player in my windows mobile 5.0 pda. But flash player in C# has some problem. i can switch to the flash player demo windows and i can see flash lite 2.1 for flash 7 content. But when i opened a flash file, it crashed because ocx is null. So i am wondering this may be clsid problem for flashlite 2.1 and then i changed to EB8B5B8E-EDB9-4180-9E2E-F8F1632DC171. i recompiled my program and then i found that the application can’t show flash demo form. i don’t know how to slove this problem. if someone can help me, i really appreciate it.

    thanks a lot


  11. Synced says:

    Same here I don’t know whats wrong with Flash Lite & Alex’s sample.

  12. Carlo De Paulis says:

    I have integrated  Mr. A. Fienman code in my application and Media Player works fine when the PDA screen orientation is set in portrait mode. As soon as I switch orientation to Landscape the PDA hangs and it isn’t possible to stop the application from debug mode and the only way to reset the PDA is turning it off.

    I am using as test bed PDA an HTC P3300.

    Thinking the problem was the obsolete version of WMPLIB.DLL I have substituted it with WMPOCX.Dll, creating all the event methods as required by the new OCX signatures. In this case I haven’t changed the AX Hosting library and nothing has changed.

    So I have the doubt that the hosting library has some problems and it is not able to manage the screen size changing from 240X320 to 320X240..

    Has anybody experienced the same problem? Is there any work around?

    I am starting to investigate the HostingLibrary code , but if in the mean time someone has a solution to this problem I would kindly appreciate.

    Thanks so much in Advance for your cooperation.

    Carlo DE PAULIS


  13. mpbejo says:

    I used the Aximp.exe with Axis ActiveX to have the .cs file, I compiled the project and I have my AxAxisMediaControlLib in the Visual Studio Designer.

    I added the object in my form, built without error, but when I try to run the application i have this error: COMExecption Class not registered  in HostingLybrary.dll

    Somebody know how to fix it

    Thank You very much

Skip to main content