none
Delete/ Re-Add custom Prop rows in Visio Shape RRS feed

  • Question

  • I've written a program in which I store properties in a Visio shape's custom property section.  shape.Cells("Prop.ThisProperty").   When the user selects the shape and clicks a button to pull up a form, he can choose different settings, which I want to store in the shape.   To accommodate, I first delete the old rows, then add new rows. 

    For the first and second edits, this works fine, but then the code gets stuck on this line (the second line shown below):

    Dim nameCell as String = NewVariableName

    box.Section(Visio.VisSectionIndices.visSectionProp).Row(intPropRowNext).Name = nameCell

    Here is the error I get:  {"Unexpected end of file."}

    System.Runtime.InteropServices.COMException was unhandled by user code
      ErrorCode=-2032466967
      Message=

    Unexpected end of file.
      Source=Microsoft Visio
      StackTrace:
           at Microsoft.Office.Interop.Visio.RowClass.set_Name(String lpLocaleSpecificName)
           at Visio_RefIt_AddIn_2010.FlexiViewerForm.EditBoxes() in C:\GINA DOCUMENTS\VSTO Documents\Visio_RefIt_AddIn_2010\Visio_RefIt_AddIn_2010\FlexiViewerForm.vb:line 809
           at Visio_RefIt_AddIn_2010.FlexiViewerForm.updateBtn_Click(Object sender, EventArgs e) in C:\GINA DOCUMENTS\VSTO Documents\Visio_RefIt_AddIn_2010\Visio_RefIt_AddIn_2010\FlexiViewerForm.vb:line 691
           at System.Windows.Forms.Control.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ButtonBase.WndProc(Message& m)
           at System.Windows.Forms.Button.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)
      InnerException:

    I've worked on this for four hours now.   Any help would be appreciated!

     


    Gina
    Tuesday, November 29, 2011 6:20 PM

Answers

  • Hello Gina,

    With the information you have posted there could be one or more suspected causes for the ‘Unexpected End of File’ message.  If the textbox is within a grouping, or the text lines are grouped, or the original textbox contained two lines you might have a pre-set property count for lines.  The expression ‘Row(intPropRowNext) implies an implicit  ‘next’ in the enumeration of PropRows. If you manually examine in the ShapePage or ShapeSheet the properties of the box shape do you see a row-count?

    The stack tract shows the problem occurs when executing the command
     
    at Microsoft.Office.Interop.Visio.RowClass.set_Name(String lpLocaleSpecificName).”
    The message might be the result of a use of an un-released object reference. The project uses .NET which doesn’t free object references the same way a straight COM automation process does. .NET uses garbage collection for unused references and perhaps you need to issue GC.collect and WaitForPendingFinalizers in order to synchronize the release of an object before you re-declare it and/or re-use it.

    I have inferred the context of your issue as working with a VSTO add-in with Visual Studio 2008 or Visual Studio 2010 and Visio 2010 based on earlier posts you have made about working with Visio. If that is incorrect please let us know. If none of the information above can be adapted to understanding your experience perhaps you could post more of your VB .NET code so someone could build a simple project similar to yours and reproduce the issue.

    We are looking forward to your response.

    Regards,
    Chris Jensen
    Senior Technical Support Lead

    • Edited by cjatmsModerator Wednesday, November 30, 2011 7:06 PM
    • Marked as answer by Gina1111 Wednesday, November 30, 2011 8:25 PM
    Wednesday, November 30, 2011 7:06 PM
    Moderator

All replies

  • Hi Gina,

    Thanks for your post.

    I'm writing to let you know that we are working on your issue now, and it might cause some time before we can response you with some valuables. So please be patient.

    Good day,


    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us
    Wednesday, November 30, 2011 6:53 AM
    Moderator
  • Hello Gina,

    With the information you have posted there could be one or more suspected causes for the ‘Unexpected End of File’ message.  If the textbox is within a grouping, or the text lines are grouped, or the original textbox contained two lines you might have a pre-set property count for lines.  The expression ‘Row(intPropRowNext) implies an implicit  ‘next’ in the enumeration of PropRows. If you manually examine in the ShapePage or ShapeSheet the properties of the box shape do you see a row-count?

    The stack tract shows the problem occurs when executing the command
     
    at Microsoft.Office.Interop.Visio.RowClass.set_Name(String lpLocaleSpecificName).”
    The message might be the result of a use of an un-released object reference. The project uses .NET which doesn’t free object references the same way a straight COM automation process does. .NET uses garbage collection for unused references and perhaps you need to issue GC.collect and WaitForPendingFinalizers in order to synchronize the release of an object before you re-declare it and/or re-use it.

    I have inferred the context of your issue as working with a VSTO add-in with Visual Studio 2008 or Visual Studio 2010 and Visio 2010 based on earlier posts you have made about working with Visio. If that is incorrect please let us know. If none of the information above can be adapted to understanding your experience perhaps you could post more of your VB .NET code so someone could build a simple project similar to yours and reproduce the issue.

    We are looking forward to your response.

    Regards,
    Chris Jensen
    Senior Technical Support Lead

    • Edited by cjatmsModerator Wednesday, November 30, 2011 7:06 PM
    • Marked as answer by Gina1111 Wednesday, November 30, 2011 8:25 PM
    Wednesday, November 30, 2011 7:06 PM
    Moderator
  • Thank you very much.  This answer is helpful.  As I worked with my code, I would do a row count of the custom properties, and the number of rows I could see always corresponded to the number the code returned.  When I looped through each row by number to perform operations, it worked perfectly some, then messed up.  It would consistently work in creating the shape, and editing it twice (deleting and adding rows each time), then it would give the error.

    Since writing this note, I've changed my approach.   I have re-worked my code for this particular application so that I never have to delete a row, and it works consistently well.  So I won't need further assistance on this.

    Thank you again.
    Gina


    Gina
    Wednesday, November 30, 2011 8:24 PM