Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I have a problem with my WPF application and it looks like this:

I have a third party application that has to work in the background.

When the mentioned application is started, my application can not open any WMV video clip (before I start this application or after I kill it - everything is ok and the video is playing fine).

The error I get from MediaElement.MediaFailed event is this:

Message: Cannot find the media file.<br />
Exception: System.Runtime.InteropServices.COMException<br />
Exception from HRESULT: 0xC00D1197


Maybe you will have some ideas that could help ... please do :)
Posted
Updated 5-Jan-11 0:48am
v2
Comments
Tarun.K.S 5-Jan-11 8:40am    
I think you are missing some reference.
Sergey Alexandrovich Kryukov 5-Jan-11 12:32pm    
And no, you're not missing any references (.NET references? or what, Tarun?), because normally your application plays the clip, but with missing references it would not even compile :-)

1 solution

Your explanation is clear (well, thank you, this is so rare!). At the same time, we don't know what that 3rd-party application does exactly. Do you know? What exactly this 3rd-party application does to the same WMV file you try to use in your MediaElement?

It looks like your third party application locks the same WMV file by opening it with exclusive access options and keeping file handle opened.
If you're really sure the right media file actually exists in both cases, your exception message is misleading. It happens in some cases.

You can validate directly if this is the case with the following code (when your 3rd-party application is running):

C#
StreamReader reader = new StreamReader("myMediaFile.WMF", false);
reader.Read(); //just one character
reader.Close();


If the file is locked by your third-party application, this code will throw exception.

You can test it from the other side: lock the file by some application, then try running your WPF application with MediaElement to see if it throws exactly same exception.

Please post your steps and results in comments to this Answer. Be prepared to output a complete exception dump (completed with full exception stack dump, with all inner exceptions, recursively) in some text file if more diagnostics is required.
 
Share this answer
 
Comments
karol 6-Jan-11 13:09pm    
Hi, thanks very much for your answer ! Unfortunately I can't check this today (I'm away from my work-pc) so I will surely give some feedback tomorrow. Of course I will check if something isn't locking my file but I don't think that this 3rd party application is even aware of this media file I'm opening (uless it has a file monitor of some sort) ... this media file is just really a sample wmv file copied with my compiled sample application (I started to check it with a simple application after I recognized this problem on my production application which suppose to cooperate with the 3rd party application).

And about this MediaElement COMException ... I checked it before and it looks just like the media file wasn't there (like I would give a wrong Uri as source).
Sergey Alexandrovich Kryukov 6-Jan-11 23:11pm    
This all looks strange. I don't know what else to say. Sorry I cannot see it immediately.

Not to worry. As I always say, if you're out of clever ideas, try a silly one. :-)
At times, it worked for me. Let's do those experiments first.
karol 7-Jan-11 8:46am    
I tried to read it as a stream and everything is ok ... it looks like there is something wrong with Media Player COM object ...
Sergey Alexandrovich Kryukov 7-Jan-11 12:42pm    
You mean you have situation when your 3rd-party application runs and problem is manifested in your application. At the same time you cannon play it, it that correct? Are you sure you detect it in the same situation?
If you're even a bit not sure (and you should be careful, because situation is very strange), can you do two changes: 1) insert the above check with the stream immediately before playing the file and make sure stream read is ok but playing throws exception; 2) catch exceptions to output full exception dump (to some text file). You provide full exception stack and all inner exception dump, recursively. Then post this exception dump, let's see what's in it.
Sergey Alexandrovich Kryukov 7-Jan-11 12:45pm    
Where was that sample media file? Same computer as the one running your application -- asking just in case?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900