I have developed an application that converts many files from .wtv to .ts using C# in WPF.
I have been able to get this to work; but only by using the InvokeMember technique - using the TypeLib DLL throws an error..
I am having an issue where the last file to be processed remains locked even after closing the file explicitly:
object[] vrd_filesave = new object[2];
vrd_filesave[0] = OutputFilename;
vrd_filesave[1] = null;
ret2 = (bool)vrd_type.InvokeMember("FileSaveAs", System.Reflection.BindingFlags.InvokeMethod, null, vrd_program, vrd_filesave);
if (ret2)
{
ret3 = 0;
do
{
ret3 = (int)vrd_type.InvokeMember("OutputGetState", System.Reflection.BindingFlags.GetProperty, null, vrd_program, null);
Thread.Sleep(TimeSpan.FromSeconds(1));
} while (ret3 != 0);
isSuccess = true;
}
else
{
isSuccess = false;
//MessageBox.Show("File " + file.FullName + " failed to save.", "Information",
// MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
vrd_type.InvokeMember("FileClose", System.Reflection.BindingFlags.InvokeMethod, null, vrd_program, null);
This is the code. The lock remains even after I do the following:
vrd_type.InvokeMember("ProgramExit", System.Reflection.BindingFlags.InvokeMethod, null, vrd_program, null);
if (vrd_program != null)
{
Marshal.ReleaseComObject(vrd_program);
}
if (vrd != null)
{
Marshal.ReleaseComObject(vrd);
}
Have I got the FileClose wrong? I'm surprised the lock is still there after exiting the program.
Tony
I have been able to get this to work; but only by using the InvokeMember technique - using the TypeLib DLL throws an error..
I am having an issue where the last file to be processed remains locked even after closing the file explicitly:
object[] vrd_filesave = new object[2];
vrd_filesave[0] = OutputFilename;
vrd_filesave[1] = null;
ret2 = (bool)vrd_type.InvokeMember("FileSaveAs", System.Reflection.BindingFlags.InvokeMethod, null, vrd_program, vrd_filesave);
if (ret2)
{
ret3 = 0;
do
{
ret3 = (int)vrd_type.InvokeMember("OutputGetState", System.Reflection.BindingFlags.GetProperty, null, vrd_program, null);
Thread.Sleep(TimeSpan.FromSeconds(1));
} while (ret3 != 0);
isSuccess = true;
}
else
{
isSuccess = false;
//MessageBox.Show("File " + file.FullName + " failed to save.", "Information",
// MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
vrd_type.InvokeMember("FileClose", System.Reflection.BindingFlags.InvokeMethod, null, vrd_program, null);
This is the code. The lock remains even after I do the following:
vrd_type.InvokeMember("ProgramExit", System.Reflection.BindingFlags.InvokeMethod, null, vrd_program, null);
if (vrd_program != null)
{
Marshal.ReleaseComObject(vrd_program);
}
if (vrd != null)
{
Marshal.ReleaseComObject(vrd);
}
Have I got the FileClose wrong? I'm surprised the lock is still there after exiting the program.
Tony