Any COM interop experts out there?


I’ve been spending some time trying to get Windows Media Player to work in a remoted mode from C#. There’s a C++ example in the WMP9 SDK named WMPML that does it, but it uses some special interfaces.

To get it to work, I need to register an IWMPRemoteMediaServices object with the WMP player, but despite setting it through SetSite(), my IServiceObject implementation is never called to return the type.

Anybody with some experience on the internals of AxHost and how this stuff works?

Comments (10)

  1. Roy J. Salisbury @ VsDevCentral says:

    I’m not familier with the particular interface, but I do know of one big GOTCHA when doing conversions. So far I have only found this issue in anyhting that involves IOleWindow (or anything that derives from it), but it MUST be in V-Table order to be correctly called. For the longest time I could not figure out why GetWindow was never being called and as soon as I swapped the "ContextSensitiveHelp" decleration with the "GetWindow" decleration in the interface, everything was fine. Anything like that going on here?

  2. I never succeed at this task (I tried). I would love to see a blog post if you make WMP to run remoted and be able to control it.

  3. Lonnie McCullough says:

    Its soooo messy. AxHost doesn’t really provide all the things to do what you want to do so what I ended up doing was writing a really thin C++ COM object wrapper around the remoted MP object that imlemented all the interfaces (IWMPRemoteMediaServices, hosting stuff) and simply fowarded everything to the actual host. All told its about 100 lines of C++ code that all lives in a header file 😉 AxHost to answer your question does not support such site extensibilty mechanisms ( at least I haven’t turned any up )

  4. Lonnie McCullough says:

    Oh yeah the important part is that I now use RemoteMediaPlayer object in my C# projects instead of the real media player. HTH

  5. Nicholas Allen says:

    I also ended up having to write a C++ shim for the control to get anything to work. I’ve lost the mail now, but I was told WMP10 would be "better" about this when I complained. The WMP10 SDK should be at least beta quality by now but I haven’t looked at it yet.

  6. Matthew W. Jackson says:

    I remember back when I read that WMP9 would support .NET I was excited. Finally, a big program from Microsoft that fully supports a managed interface.

    Then I install the SDK only to find that it’s a Primary Interop Assembly. I can’t even begin to express how disappointing this was.

    But if WMP10 fixes the problem, all will be good.

    Now let’s see what can they do about replacing all of the COM Shell Extension API with Managed libraries. I hope this is in the works for Longhorn.

  7. J. Daniel Smith says:

    Hopefully with a C# guy joining the WMP team, we’ll see vast improvements in the .NET area.

    It is nice to see Eric struggling with some of the stuff those outside of Microsoft have to deal with every day. 🙂 .NET and C# sure are great, but it can be far too difficult when it comes time to use the technology in a legacy real-world application.

  8. Last August, I wrote a post talking about my efforts to create a remotable version of Windows Media Player…

Skip to main content