7

I am using the axwindowsMediaPlayer object to show videos in a winform. In particular I want to play a playlist.

Everything works fine on my pc (win7) and used to work fine also in another pc with winXP (the pc of the final user).

But something happened a couple of days ago: on the XP PC I started to receive the following expcetion

Unhandled Exception:

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

System.Runtime.InteropServices.COMException

Stack Trace:
   at WMPLib.IWMPPlaylistCollection.newPlaylist(String bstrName)
   at BrinaS941.ScreenSaverVideo.ScreenSaver_Load(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Here the code that rises the exception:

private void ScreenSaverVideo_Load(object sender, EventArgs e)
{
    WMPLib.IWMPPlaylist playlist = VideoPlayer.playlistCollection.newPlaylist("myplaylist");
    WMPLib.IWMPMedia media;
    VideoPlayer.uiMode = "none";
    VideoPlayer.settings.volume = 10;
    [....]

The exception started to be risen while the application was working and now keep on having the same behavior.

I tried to reinstall Windows Media Player (11) on the XP machine, but nothing changed.

UPDATE:

I tried to comment the part of code related to the playlist (and use the method "URL" to set the video a want to play) and everything works fine. I am really puzzled...

Any help would be really appreciated. Thanks

muccix
  • 321
  • 1
  • 3
  • 10
  • (1) have you stepped through your code to see exactly the point of error? (2) have you checked that the 'screensavervideo' is compatible with XP? (3) have you tried a 'try-catch' caption? – jbutler483 Aug 06 '14 at 08:16
  • (1) No, because on my dev pc the error doesn't happen. But I am pretty sure the line that throws the exception is "WMPLib.IWMPPlaylist playlist = VideoPlayer.playlistCollection.newPlaylist("myplaylist");" becuse I tried to move the line "VideoPlayer.uiMode = "none";" before and it is executed correctly. (2) Yes, since it worked correctly since 2 days ago (3) I inserted the code inside a try-catch: so my application doesn't crash, but the video are never played – muccix Aug 06 '14 at 08:18
  • have a look in EventViewer it might give you a reason there – Colin Smith Aug 06 '14 at 09:05
  • Could the problem be linked to the fact that I am developing on a PC with Win7 and Media Player 12, while the application is running on Win XP with Media Player 11? – muccix Aug 06 '14 at 09:12
  • @colinsmith In the EventViewer I can not see anything useful. From what I understand the "WMPLib.IWMPPlaylistCollection" is an object contained in "Interop.WMPLib.dll" or in "AxInterop.WMPLib.dll" that I distribute with the application. Is there any reference in the dll of the pc that could be corrupted? – muccix Aug 06 '14 at 14:10
  • You might have a corrupted media player database. Can you create play lists using the Windows Media Application itself? See here how to reset: http://answers.microsoft.com/en-us/windows/forum/windows_7-pictures/windows-media-player-corrupted-playlists-after/c64b0c93-7e28-4b30-bdd6-9e1cdae85c01 ... or here ... http://www.hack7mc.com/2009/02/fix-corrupt-windows-media-player.html .... http://www.howardforums.com/showthread.php/873220 – Colin Smith Aug 06 '14 at 14:25
  • Thanks @colinsmith but unfortunately it doesn't solve the problem.. – muccix Aug 06 '14 at 14:58
  • Just to add that I tried to comment the part of code related to the playlist (and use the method "URL" to set the video a want to play) and everything works fine. I am really puzzled... – muccix Aug 06 '14 at 16:22
  • What .NET Frameworkversion are you targeting? WindowsXP-PC might be missing the required frameworkfiles. – Matthijs Aug 06 '14 at 16:31
  • .NET 3.5. Could it be possible that it is corrupted in the target machine? Should I try to reinstall it? – muccix Aug 07 '14 at 06:48
  • @Matthijs I removed and install again the .NET 3.5 Framework but nothing changed. Next step would be to install again Windows? – muccix Aug 07 '14 at 08:29

1 Answers1

10

I finally found the problem!

My fault was not to remove the playlist once used (with IWMPPlaylistCollection::remove method ). I realized that I had 2000 playlists ( myplaylist.wpl, myplaylist(1).wpl,..., myplaylist(1999).wpl) in my file system and probably there is a limit of 2000.

I don't know if it's a limit of the file system or of WMP.

Once deleted all the files everything started working again.

Thanks everyone for your help!

muccix
  • 321
  • 1
  • 3
  • 10
  • 2
    There is absolutely no possible way I would have found the solution to this problem if I hadn't read your answer. Thank you for coming back and posting the solution. – davehale23 May 03 '16 at 16:02
  • UNBELIEVABLE!! spent MONTHS on this. Was even more thrown off because I am on a Domain and for some reason if I start Visual Studio by shift/left-click the VS icon and run as a local account user) the problem the exception doesn't throw. And also, I left my app running all night last night & it was fine when i left and when i came in today it was stuck and kept getting stuck at the video (it's a slide-show that does images first, then videos, then starts over). Now it all makes sense -playing overnight it created all those playlist... THANKS SO MUCH FOR POSTING THIS!!!! – user1062142 Aug 30 '19 at 18:04