From: " ctacke/>" on
Looking at the link you sent, it appears that calling
Marshal.FinalReleaseComObject and removing all event handlers should fix it.
That means that in your app cleanup, before exist, you should remove any/all
event handlers and then call FinalReleaseComObject on all instances of the
object you created.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com


"David Leahy" <DavidLeahy(a)discussions.microsoft.com> wrote in message
news:0A3C8525-9A6A-4FAE-9131-F89CAAEC0AAB(a)microsoft.com...
>
> Other people are having the same problem - check:
>
> http://objectmix.com/dotnet/98243-using-windowmediaplayer-object-smartphone-freezes-application.html
>
> They mention some Marshall release object but still can't seem to fix the
> problem ? Is there any other way to use media player in Compact Framework
> which is not affected by this problem ?
>
> Thanks
>
> David
>
>
> "<ctacke/>" wrote:
>
>> I assume the WMPLib is one generated following the COM interop webcast on
>> MSDN? There isn't one directly in the CF. My guess is that on close you
>> need to be cleaning up your COM references.
>>
>>
>> --
>>
>> Chris Tacke, Embedded MVP
>> OpenNETCF Consulting
>> Giving back to the embedded community
>> http://community.OpenNETCF.com
>>
>>
>>
>>
>> "David Leahy" <DavidLeahy(a)discussions.microsoft.com> wrote in message
>> news:FEE9A3A5-F65A-4CE2-BDAA-E142F39CDB29(a)microsoft.com...
>> > Here is my code:
>> >
>> > Public player As New WMPLib.WindowsMediaPlayer()
>> >
>> >
>> > Dim mypath As String
>> > mypath = GetAppPath()
>> >
>> >
>> > try
>> >
>> > If File.Exists(mypath) = True Then
>> > player.URL = mypath
>> > 'System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
>> > + "\media\change.mp3"
>> > MsgBox(player.URL)
>> > player.settings.volume = 100
>> > player.controls.play()
>> > End If
>> >
>> >
>> > Catch err As SqlCeException
>> > 'Insert error handling code here
>> > MessageBox.Show(err.Message)
>> >
>> > End Try
>> >
>> > Public Function GetAppPath() As String
>> > Return System.IO.Path.GetDirectoryName( _
>> >
>> > System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
>> > End Function
>> >
>> >
>> >
>> > The application hangs unless I comment all of the above code out
>> >
>> > Regards
>> >
>> > David
>> >
>> >
>> >
>> >
>> > "<ctacke/>" wrote:
>> >
>> >> How are you "running media player"? Though a Process class that just
>> >> executes it?
>> >>
>> >>
>> >> --
>> >>
>> >> Chris Tacke, eMVP
>> >> Join the Embedded Developer Community
>> >> http://community.opennetcf.com
>> >>
>> >>
>> >> "David Leahy" <DavidLeahy(a)discussions.microsoft.com> wrote in message
>> >> news:51F3ADBF-88AF-4B48-86F8-B20FA062287D(a)microsoft.com...
>> >> > Hi,
>> >> >
>> >> > When I run media player as part of my Compact Framework application
>> >> > (2.0)
>> >> > it
>> >> > runs fine, but when I try to exit the application it hangs and
>> >> > freezes
>> >> > the
>> >> > application - requiring a reboot - I've read somewhere that some
>> >> > Marshal
>> >> > com
>> >> > object can solve this, but I've no idea how - have you any other
>> >> > suggestions
>> >> > ? I've coding in VB.net
>> >> >
>> >> > Thanks
>> >> >
>> >> > David
>> >>
>> >>
>> >>
>>
>>
>>


From: David Leahy on
In case others have the same problem, I managed to get it to work using the
following code:

player.controls.stop()
player.close()

Dim answer As MsgBoxResult
answer = MsgBox("Do you want to quit now?", MsgBoxStyle.YesNo)
If answer = MsgBoxResult.Yes Then
FinalReleaseComObject(player)
player = Nothing
GC.Collect()
Application.Exit()
MsgBox("Application Exiting")
End If

Interestingly it doesn't work unless the final MsgBox statement is included
(which doesn't require a user to click OK) - I found this out by accident as
I was debugging with MsgBox !

David




"<ctacke/>" wrote:

> Looking at the link you sent, it appears that calling
> Marshal.FinalReleaseComObject and removing all event handlers should fix it.
> That means that in your app cleanup, before exist, you should remove any/all
> event handlers and then call FinalReleaseComObject on all instances of the
> object you created.
>
>
> --
>
> Chris Tacke, eMVP
> Join the Embedded Developer Community
> http://community.opennetcf.com
>
>
> "David Leahy" <DavidLeahy(a)discussions.microsoft.com> wrote in message
> news:0A3C8525-9A6A-4FAE-9131-F89CAAEC0AAB(a)microsoft.com...
> >
> > Other people are having the same problem - check:
> >
> > http://objectmix.com/dotnet/98243-using-windowmediaplayer-object-smartphone-freezes-application.html
> >
> > They mention some Marshall release object but still can't seem to fix the
> > problem ? Is there any other way to use media player in Compact Framework
> > which is not affected by this problem ?
> >
> > Thanks
> >
> > David
> >
> >
> > "<ctacke/>" wrote:
> >
> >> I assume the WMPLib is one generated following the COM interop webcast on
> >> MSDN? There isn't one directly in the CF. My guess is that on close you
> >> need to be cleaning up your COM references.
> >>
> >>
> >> --
> >>
> >> Chris Tacke, Embedded MVP
> >> OpenNETCF Consulting
> >> Giving back to the embedded community
> >> http://community.OpenNETCF.com
> >>
> >>
> >>
> >>
> >> "David Leahy" <DavidLeahy(a)discussions.microsoft.com> wrote in message
> >> news:FEE9A3A5-F65A-4CE2-BDAA-E142F39CDB29(a)microsoft.com...
> >> > Here is my code:
> >> >
> >> > Public player As New WMPLib.WindowsMediaPlayer()
> >> >
> >> >
> >> > Dim mypath As String
> >> > mypath = GetAppPath()
> >> >
> >> >
> >> > try
> >> >
> >> > If File.Exists(mypath) = True Then
> >> > player.URL = mypath
> >> > 'System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
> >> > + "\media\change.mp3"
> >> > MsgBox(player.URL)
> >> > player.settings.volume = 100
> >> > player.controls.play()
> >> > End If
> >> >
> >> >
> >> > Catch err As SqlCeException
> >> > 'Insert error handling code here
> >> > MessageBox.Show(err.Message)
> >> >
> >> > End Try
> >> >
> >> > Public Function GetAppPath() As String
> >> > Return System.IO.Path.GetDirectoryName( _
> >> >
> >> > System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
> >> > End Function
> >> >
> >> >
> >> >
> >> > The application hangs unless I comment all of the above code out
> >> >
> >> > Regards
> >> >
> >> > David
> >> >
> >> >
> >> >
> >> >
> >> > "<ctacke/>" wrote:
> >> >
> >> >> How are you "running media player"? Though a Process class that just
> >> >> executes it?
> >> >>
> >> >>
> >> >> --
> >> >>
> >> >> Chris Tacke, eMVP
> >> >> Join the Embedded Developer Community
> >> >> http://community.opennetcf.com
> >> >>
> >> >>
> >> >> "David Leahy" <DavidLeahy(a)discussions.microsoft.com> wrote in message
> >> >> news:51F3ADBF-88AF-4B48-86F8-B20FA062287D(a)microsoft.com...
> >> >> > Hi,
> >> >> >
> >> >> > When I run media player as part of my Compact Framework application
> >> >> > (2.0)
> >> >> > it
> >> >> > runs fine, but when I try to exit the application it hangs and
> >> >> > freezes
> >> >> > the
> >> >> > application - requiring a reboot - I've read somewhere that some
> >> >> > Marshal
> >> >> > com
> >> >> > object can solve this, but I've no idea how - have you any other
> >> >> > suggestions
> >> >> > ? I've coding in VB.net
> >> >> >
> >> >> > Thanks
> >> >> >
> >> >> > David
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
First  |  Prev  | 
Pages: 1 2
Prev: SIP Notifications
Next: RIL C#