using the WindowMediaPlayer object on smartphone freezes application

  • Thread starter Thread starter Cristi Berneanu
  • Start date Start date
C

Cristi Berneanu

Hello all,

I have made a .NET compact framework application for smartphone
devices which uses the WindowsMediaPlayer object to play a mp3 file.
Everything works fine until I call Application.Exit(). Then the
application won't exit completely and remains hanged, although in
TaskManager it doesn't show up anymore. This happens only when I use
the WindowsMediaPl;ayer object. Does anyone have any hints on what I
may be doing wrong?

Thanks in advance!
 
Steps to reproduce the problem:

1 - create a new Windows Mobile 5.0 Smartphone device application
2 - Add a reference to wmp.dll
3 - add this code anywhere:

WMPLib.WindowsMediaPlayer p = new
WMPLib.WindowsMediaPlayer();
p.URL = "\\Application Data\\Sounds\\Classic.wma";
p.controls.play();
System.Threading.Thread.Sleep(1000);
Application.Exit();

Could someone please confirm this so I know it isn't a problem on my
side?
 
I can confirm this behavior. Even calling Marshal.ReleaseComObject() on the
WMP instance has no effect. Also, calling this.Close() instead of
Application.Exit() will close the form, but the application still does not
terminate.

--
Neil Cowburn
Principal Partner
OpenNETCF Consulting, LLC.

http://www.opennetcf.com/
 
Marshal.FinalReleaseComObject fixes the problem. Also all event
handlers must be removed.
 
Back
Top