Hi experts:
I meet a crash,when I debug following code:
private void FPAddin_ElementChangedEvent(AddIn sender, ElementChangedEventArgs eventArgs) { if (eventArgs.Change == ChangeTrackKind.Modify) { if (eventArgs.NewElement.ElementType == MSElementType.LineString) { base.ElementChangedEvent -= FPAddin_ElementChangedEvent; try { SupportForSupport sfs = new SupportForSupport((LineStringElement)eventArgs.NewElement); IECInstance instance = sfs.SwapECInstance;//find the exist instance and modify some value lock (instance)//i add this lock, avoid some crash,but the crash is still frequently { if (instance == null) { FPUtility.ShowErrorMessage("error"); return; } IDgnECInstance dgnecinstance = instance as IDgnECInstance; if (dgnecinstance == null) { FPUtility.ShowErrorMessage("error"); return; } Debug.WriteLine(String.Format("save changes to file")); if (dgnecinstance.WriteChanges() == StatusInt.Error) { FPUtility.ShowErrorMessage("Error"); } } } catch { FPUtility.ShowErrorMessage("Error"); } base.ElementChangedEvent += FPAddin_ElementChangedEvent; Debug.WriteLine(String.Format("Resume listen"));//when the crash happened, the debug line has show in the IDE. } } }
I used the code to do a test. the crash no happened each time. but it happens some time and especially when the Properties window is open.
I debugged the local code and got the following crash information:
0x000000005E68FC88 (ustation.dll)处(位于 OpenPlantModeler.exe 中)引发的异常: 0xC0000005: 读取位置 0xFFFFFF0005000018 时发生访问冲突。
crash happens in MicroStation CE(update 8) and OpenPlant modeler CE.
CE(update 9) is less crash than CE(update 8).
Hi,
I don't feel good when I see your code:
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point