views:

161

answers:

0

Hi,

I'm currently developing an application for Windows platform that will be able to play Quick Time videos. The targeted OS versions are Windows XP, Windows Vista and Windows 7.

I successfully used the Apple ActiveX QuickTime Control 2.0 (in C#) and everything works well on Windows XP.

However, on Vista and Windows 7 I'm facing problems with properly disposing the control. Here are the "steps to reproduce" : - I create the Quick Time control dynamically at runtime and I place it on a panel;

  • I successfully play videos with it;

  • At some point I close the application main form; the application windows is destroyed and the application will continue to run in the background (doing operations like syncing videos); at this point the control is disposed using IDisposable pattern; I can't explicitly dispose the Movie object (from the ActiveX control) because I get an exception like: "COM object that has been separated from its underlying RCW cannot be used."; I just use (AxQTOControlLib.AxQTControl) player.Dispose(); On Windows XP this is fine but not on Vista and 7

  • I restore my application (from tool bar where it was running in background) and try to open the video again; At this point an AccessViolationException "Attempted to read/write protected memory" is thrown;

My questions are:

  • Why is this happening only on Vista and Windows 7 ?

  • On XP is a hidden leak ?

  • What is the recommended way to dispose the control (with its movie object) when it is created at runtime ?

I'm now using an explicit Movie.Disconnect() call (although I don't now what this disconnect means because I could not find proper documentation) fallowed by a QuickTimeTerminate() call before the form is closed. While my method is working it is kind of design breaking so I would like to know a better way of doing this.

Thank you, Mosu'

Update: I just discovered that my method is not workink. I use to players: QuickTime control and Windows Media player control (both ActiveX) and when one fails to play a file the other one is used. I was seeing the output of WindowsMedia player and thinking the methos IS working. So my fix is not working at all.