This project is read-only.

"File in use" error!

Topics: User Forum
Feb 19, 2007 at 12:51 PM
Hi guys,
I am having a problem palying back the created avi with windows media player for example. If i don't close the application, the file is in use, or it stays that way for
a random amount of time i believe.
This has become a problem to me since I create two avi's and then use splice again to join them. so when I try to add them it gives me media/file already in use. (as the HR return value).
this is the code i use to get the output:
Splicer.Renderer.IRenderer re = new Splicer.Renderer.AviFileRenderer(TL, outputfile, comp, null, null, null);
IAsyncResult res = re.BeginRender(null, null);
//re = null;

Any hints??

Thanks alot

Feb 19, 2007 at 2:43 PM

The file is not released until the comobjects are disposed of. This only happens when you dispose the renderer. Try calling re.Dispose().
Feb 20, 2007 at 7:42 AM
Edited Feb 20, 2007 at 7:54 AM

Thank you for the suggestion, the RenderEngine object doesn't have a Dispose() method!

I just tried something.
I added a GC.Collect(); after the re=null; statement, and it was no
use, still the file is being locked by another process.

Out of curiosity, would this mean that probably there are comobjects not released in the splicer sourcecode upon render finish?
(maybe the solution would be to do a marshal.releasecomobj -not sure if its the right method name :)- in the render endrender method.)

Thank you for the help, and if you have anymore thoughts let me know please.


Feb 20, 2007 at 8:40 AM

Thank you for the tip.
I went to the sourcecode and saw that the avifilerenderer did indeed implement
a destructor and dispose method.
So I noticed that the re object i am using is actually an IRenderer object created
with a "=new avirenderer(...)" method.
So I called the dispose method by casting the re object to AviRenderer and
it worked just fine.

Thank you again :)
Feb 21, 2007 at 12:00 AM
Apologies for chiming in late... Originally IRenderer did implement IDisposable, but I later removed it because it didn't necessarily make sense in all situations, I would suggest for you code that you just use the renderer classes directly, and obviously placing them inside a using statement will ensure cleanup i.e.

using (AviRender render = new AviRenderer(...))
// do whatever.
Jun 4, 2008 at 11:48 PM
I found this thread after I had the same problem.  I am using WindowsMediaRenderer in the asynchronous mode (BeginRender()).  In the RenderCompleted event I call WindowsMediaRenderer.Dispose().  The file produced stays locked for some time after the dispose call.  I hit this problem when I try to delete the created file immediately after the RenderCompleted event.  Note that I am trying to delete the file on the main thread, not in the RenderCompleted event.  It seems that dispose returns before the underlying DS thread has finished with the file.  I guess this is probably a limitation of DS.  Is there any tidy way to work around this?  I'm considering simply waiting for the file to be released before deleting it.