While processing the drawing files in batch mode, the below given statement raise 'AccessViolationException' [Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]. But the same statement works for spare Drawing files. How to fix this issue?
acadDB.SaveAs(outputPath & "\" & dwgName.ToString & ".dwg", True, DwgVersion.Current, Nothing)
Please elaborate, the code looks correct but does it work on some files or none?
Hi,
I assume you read/write drawing using ReadDwgFile.
Before saveas command check open drawing file already close and released in memory.
I have the same issue and I sove this using below code.
Hope this will help.
If this code not help, please explain your issue little more.
code:
string tempFileName = System.IO.Path.GetTempFileName(); acadDB.CloseInput(true); // save as temp file acadDB.SaveAs(tempFileName, DwgVersion.Current); // dispose the database // now replace System.IO.File.Copy(tempFileName, File_name_path, true); // and erase the temp file System.IO.File.Delete(tempFileName);
Thanks,
thenndral