Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
Getting error while saving Toolbar DATA
posted

Hello

 I am getting following error when I am trying to save toolbar data into XML format. I am getting this error only in one form, for other form toolbars everything is working fine. Might be I have missed something while creating toolbar.  

 This is the error

{System.ApplicationException: Error encountered while serializing data into stream. ---> System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.

   at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)

   at System.Drawing.Image.Save(MemoryStream stream)

   at System.Drawing.Image.System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)

   at System.Runtime.Serialization.Formatters.Soap.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo, ObjectWriter objectWriter)

   at System.Runtime.Serialization.Formatters.Soap.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo, ObjectWriter objectWriter)

   at System.Runtime.Serialization.Formatters.Soap.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)

   at System.Runtime.Serialization.Formatters.Soap.ObjectWriter.WriteMembers(NameInfo memberNameInfo, NameInfo memberTypeNameInfo, Object memberData, WriteObjectInfo objectInfo, NameInfo typeNameInfo, WriteObjectInfo memberObjectInfo, Boolean isAttribute)

   at System.Runtime.Serialization.Formatters.Soap.ObjectWriter.WriteMemberSetup(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo, String memberName, Type memberType, Object memberData, WriteObjectInfo memberObjectInfo, Boolean isAttribute)

   at System.Runtime.Serialization.Formatters.Soap.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo, String[] memberNames, Type[] memberTypes, Object[] memberData, WriteObjectInfo[] memberObjectInfos)

   at System.Runtime.Serialization.Formatters.Soap.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)

   at System.Runtime.Serialization.Formatters.Soap.ObjectWriter.Serialize(Object graph, Header[] inHeaders, SoapWriter serWriter)

   at System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers)

   at System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Serialize(Stream serializationStream, Object graph)

   at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.SaveHelper(Stream stream, Boolean saveAsBinary, Boolean saveCustomizations)

   --- End of inner exception stack trace ---

   at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.SaveHelper(Stream stream, Boolean saveAsBinary, Boolean saveCustomizations)

   at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.SaveAsXml(Stream stream, Boolean saveCustomizations)

   at Allscripts.TouchWorks.Workspace.EditView.EditViewDialog.processDefineButtonsClick(TWButton oLayoutGroupButton, UltraTabControl oTab)

 

 

I am using following code to save ToolBarManager Data

try

            {

                MemoryStream ButtonLayoutStream = new MemoryStream();

               

                oWorkspace.WSToolbarsManager.SaveAsXml(ButtonLayoutStream, false);

                ButtonLayoutStream.Position = 0;

                StreamReader sr = new StreamReader(ButtonLayoutStream);

                sOriginalXML = sr.ReadToEnd();

                sr.Close();

            }

            catch (Exception ex)

            {

                MessageBox.Show("Error Serializing Toolbar: " + ex.Message);

                return;

            }

 

I have also enclosed the toolbar setting file in XML format. May be that can help you in creating similar toolbar.

Note-> An error was comming while uploading the XML file so I renamed it to Toolbar.txt. 

Please let me know where I have made the mistake.

 

Parents
No Data
Reply
  • 1065
    posted

    Hi,

    I'm getting the same error.

    - I created an own usercontrol which includes an ultratoolbarsmanager.
    - The control is placed into a tabcontrol which is docked into formA.
    - FormA is a mdi form whose parent is formB.

    When I close formB I'd like to save the toolbarssettings into a binary file. To do this I placed the code for saving the settings into my usercontrol's Dispose sub.

    So when I close formB the usercontrol's Dispose code is running and tries to save the settings. But the code is running twice. In the first time the saving works fine. But in the second time when it runs again into it the saving fails returning the message "Error encountered while serializing data into stream.". The second saving has overwritten my first correct savings and I could not use the file to reload the settings because the data couldn't be deserialized.

    What can I do? Where is the best place in code to save the settings by closing the main form 'formB'?

Children
No Data