User (Legacy) Posted January 26, 2005 Report Share Posted January 26, 2005 I have a chart with annotations and a custom button on the toolbar to export these annotations. . If I initialize annotations, perform a data import and then try to add and enable a custom toolbar command, I get an exception saying cannot reference disposed object G. The data import is from a memory stream that does not contain extensions. For example: //Init annotations annotx = new AnnotationX(); annotx.Enabled = true; Extensions.Add(annotx); ... //Import the settings MemoryStream ms = new MemoryStream(config); Import(FileFormat.XML, ms); ..... //Create a toolbar command for saving annotations Command saveAnnotationCommand = annotx.Commands.AddCommand(saveAnnotationCommandID); saveAnnotationCommand.Text = "Save Annotations"; int picIndex = annotx.Commands.AddPicture(imageList1.Images[0]); saveAnnotationCommand.Picture = picIndex; saveInsertPosition = annotx.ToolBarObj.Length; annotx.ToolBarObj.InsertAt(saveInsertPosition); annotx.ToolBarObj[saveInsertPosition] = saveAnnotationCommandID; annotx.ToolBarObj.Commands[saveAnnotationCommandID].Enabled = false; //<<Exception generated here If I reinitialize annotations again after the Import command, the exception is not generated and the annotations work normally. The export command used prior to the import did not include extensions, so I expected my existing annotations to be preserved. MemoryStream ms = new MemoryStream(); this.FileMask = FileMask.Colors | FileMask.Elements | FileMask.Fonts | FileMask.General | FileMask.Multi | FileMask.Scale; this.Export(FileFormat.XML, ms); It would seem that the import command is changing the annotation extension which requires me to reinitialize my toolbar even though the export stream does not include annotations. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.