Need help working from home with your Bentley software? We're here to help - click here
The following error is generated when saving or validating a model file: Attempted to read or write protected memory.
Press Ctrl-C to copy details to clipboard:System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.at memcpy(Void* , Void* , UInt32 )at Haestad.DrawingStorage.GenericMemoryCollection`1.ToArray()at Haestad.Drawing.DrawingObjectTableModuleBase.Write(IStorageWriteStream astream)at Haestad.Drawing.PointDrawingObjectTableModule.Write(IStorageWriteStream astream)at Haestad.Drawing.TextDrawingObjectTableModule.Write(IStorageWriteStream astream)at Haestad.Drawing.MultiLineTextTableModule.Write(IStorageWriteStream astream)at Haestad.Drawing.AnnotationData.Write(IStorageWriteStream astream)at Haestad.Drawing.LayerDefinition.Write(IStorageWriteStream astream)at Haestad.Drawing.Domain.DrawingStorageElement.Write(IStorageWriteStream astream)at Haestad.Support.Storage.StorageFileBase.WriteElement(IStorageElement aelement)at Haestad.Support.Storage.BinaryStorageFileBase.WriteElement(IStorageElement aelement)at Haestad.Support.Storage.StorageFileBase.Write(IStorageElement aelement)at Haestad.Support.Storage.StorageManagerBase.Write(IStorageWriteContext acontext)at Haestad.Framework.Application.StorageProjectFileBase.Write()at Haestad.Drawing.Domain.DrawingFile.SaveAs(ProjectProperties app)at Haestad.Drawing.Domain.DrawingFile.Save(ProjectProperties app)at Haestad.Framework.Application.ProjectBase.Save(ProjectProperties app)at Haestad.Framework.Windows.Forms.Forms.HaestadParentForm.SaveProject(IProject aiproject)at Haestad.Framework.Windows.Forms.Forms.HaestadParentForm.SaveCurrentFile()at Haestad.Drawing.Control.Forms.GraphicalDrawingParentForm.menuButtonItemFileSave_Activate(Object sender, EventArgs e)at TD.SandBar.ToolbarItemBase.OnActivate()at TD.SandBar.ButtonItemBase.OnActivate()at TD.SandBar.ButtonItem.OnActivate()at TD.SandBar.ToolBar.OnItemRelease(ToolbarItemBase item, Point position)at TD.SandBar.ToolBar.OnMouseUp(MouseEventArgs e)at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)at System.Windows.Forms.Control.WndProc(Message& m)at TD.SandBar.ToolBar.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)
First, try compacting the database. To do this, close the model but leave the product open. Go to Tools > Database Utilities > Compact Database. Select the database file and choose the option to purge the model to save space. Once completed, open the model and see if the issue still occurs.
This is an indication that the output files are too large or numerous. Try creating a new folder and moving just the starter file and the database file (.wtg and .wtg.sqlite for the water products, .stsw and .stsw.sqlite for the storm and sewer products) to the new folder. Once done, open the model from the new folder location.
If that doesn't help, try importing the database into a new drawing. This is done by going to File > Import > (product name) database.
Lastly, you can also try deleting the engineering library database. Go to c:\users\<user name>\AppData\Roaming\Bentley\EngineeringLibraries and delete EngineeringLibraries.mdb and EngineeringLibraries.sqlite. Make sure the program is closed when you do this. When you open the program again, the files will get re-created. Note: Custom items in the engineering library will be lost if you do this.
Check the video card drivers associated with the computer. If possible, update the video card drive. If you have more than one driver, try changing the settings so one is the default that is used for the program.
If that doesn't help, review the model for missing or incorrect data. This could include references to deleted elements, such as the downstream pipe for a valve or pump or to the control node for a variable speed pump. Also check for missing or incorrect data like pipe lengths or pipe diameters.
In one case, an updated AMD driver caused this issue. Once the update was removed, the error went away.
If you have an NVIDIA graphics card, open the NDIVIA Control Panel and set the H&H product to launch each time using the NVIDIA card. This workaround has worked for at least one case of this error message.
In a case with the storm and sewer products, this error has also occurred when a hot start file was applied in the calculation options. When this was removed, the issue no longer occurred. Verifying the location and status of a hot start file would be a possible solution.