views:

735

answers:

1

I'm trying to figure out how to add some directshow capabilities to a C# application (.net cf 3.5 running on mobile 6 and up), and I'm having a hard time figuring out how to bridge the gap between using unmanaged c++ class(es) in managed C#.

I've already written the functionality I need in C++: Basically, I have a manager class that uses COM to tap into the needed directshow functionality. Quick Disclaimer: I'm new to COM, and I'm VERY new to integrating C++ with C#.

I'm really hoping that someone knowledgeable can suggest a basic strategy for me to research further. Here are some that I've looked into, and the problems I've found with them:

  1. Create a C++ DLL, then call into it from C#.
    PROBLEM: Since I'm working on a smart device platform, creating a managed C++ dll isn't an option, so C# unfortunately won't be able to call directly into my c++ dll. Is creating an instance of my unmanaged C++ "dshow manager" class from C# (via COM) the best option?

  2. Create a C++ DLL, then just Pinvoke/DLLImport the methods that are needed.
    PROBLEM: My solution has an event listener and stuff, so I need to maintain an instance of the manager class (see option 3), not just call into individual methods.

  3. Replicate the C++ class in C#, then just call the dshow methods via COM from C#. PROBLEM: This seems like the best option to me, but from what I've found here MSDN, I need to first "create managed definitions of com interfaces and types", and unfortunately I can't find the directshow TLB files to import via TLBImp.exe. All the WM6 SDK gives me are dshow LIBs, PDBs, and EXPs. I can't even find IDL files to create TLBs from, as some sites have suggested.

As it stands, I'm still looking into things, but kind of stuck now. Any suggestions? THANKS IN ADVANCE!

+2  A: 

You could probably look at the desktop DShow.NET library as a guide to porting. Alex Mogurenko's recent blog on playing audio and video with DShow on WinMo is also a good resource.

Edit: I guess I didn't directly answer the question on strategy. Yes, #3 is the way to go. Wrap DShow and call it, don't add yet another layer of confusing indirection (COM is confusing enough already).

ctacke
That Alex Mogurenko article was a BIG help, especially since he didn't go didn't seem to have to mess with all of that TLB file crap I was worried about. I think that's a very good starting point for me to work with. THANKS!