Attempted to read or write protected memory - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Attempted to read or write protected memory

Last post 05-07-2007 07:07 AM by erinselena. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 04-26-2007 01:57 PM

    Attempted to read or write protected memory

    Hello Everyone,

    My infopath form has a button in which you can click it and give a number , that number is the number of "clones" or copies of an infopath node to add to the XML (in a repeating section). When the user clicks this "clone" button they enter the number and then my code behind loops as many times as they've requested and inserts the node that many times into the repeating section. This works great however if the user requests to clone a node 10 times i get the followign error... is there anything i can do here to fix this?  I should also mention that i am using infopath 2007 and hosting the form in a 2005 windows form. The code that actually does this is inside my windows form.

    Thanks!

    {"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}

    [System.AccessViolationException]: {"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}

    Data: {System.Collections.ListDictionaryInternal}

    HelpLink: null

    InnerException: null

    Message: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

    Source: "Microsoft.Office.InfoPath.Client.Internal.Host.Interop"

    StackTrace: " at Microsoft.MsoOffice.InfoPath.MsxmlInterop.NativeHelpers.InsertBefore(Char* , IXMLDOMNode* , IXMLDOMDocument3* )\r\n at Microsoft.MsoOffice.InfoPath.MsxmlInterop.MsxmlNodeImpl.InsertBefore(String strXml, MsxmlNode refChild)\r\n at Microsoft.Office.InfoPath.MsxmlWriter.Close()\r\n at System.Xml.XmlWellFormedWriter.Close()\r\n at System.Xml.XPath.XPathNavigator.InsertAfter(XmlReader newSibling)\r\n at System.Xml.XPath.XPathNavigator.InsertAfter(String newSibling)\r\n at DataCollectionClient.frmDataCollection.NotifyHostEventHandler(Object sender, String notification) in C:\\_dev\\Tablet-Exterior\\Data Collection Application\\DataCollectionClient\\ExternalInspection.cs:line 828"

    TargetSite: {Int32 Microsoft.MsoOffice.InfoPath.MsxmlInterop.NativeHelpers.InsertBefore(Char*, IXMLDOMNode*, IXMLDOMDocument3*)}

     

  • 05-02-2007 05:44 AM In reply to

    Re: Attempted to read or write protected memory

    nobody has any ideas here???
  • 05-04-2007 06:02 AM In reply to

    Re: Attempted to read or write protected memory

    Further to this. Here is the method that i am using that generates this exception. The line that is actually the culprit is this newRow.InsertAfter( newRow.OuterXml ); and it seems to only be happening on my machine , not many others can duplicate (although we've only run it on 4 machines). Does anyone have any idea as to what i can do to fix this on my machine or even what the cause might be?

     

    XPathNavigator newRow;
                                XPathNavigator temp;
                                XPathNavigator nav;

                                string newIdNumber;
                                int total = 0;

                                XPathNodeIterator attIterator = formControl1.XmlForm.MainDataSource.CreateNavigator( ).Select( Constants.ATTACHMENT_ASSET_INSTANCE + "[text()='" + identifier + "'" + "]", xmlnsm );
                                IList<XPathNavigator> listOfAttachments = new List<XPathNavigator>( );
                              
                                //make a list of all the attachments for this asset, this will be used later when we actually insert the new node
                                //cannot insert inside of an XPathNodeIterator, that's why we create a list to use first.
                                while ( attIterator.MoveNext( ) )
                                {
                                    attIterator.Current.MoveToParent( );
                                    nav = attIterator.Current.Clone( );
                                    listOfAttachments.Add( nav );
                                    System.Windows.Forms.Application.DoEvents( );
                                }

                                //now actually create the clones
                                for ( int i = 0; i < cloneD.NumberClones; i++ )
                                {
                                    total = i + 1;
                                    lblClone.Text = total.ToString() + " of " + cloneD.NumberClones.ToString( );
                                    System.Windows.Forms.Application.DoEvents( );
                                    //create the new cloned row
                                    newRow = formControl1.XmlForm.MainDataSource.CreateNavigator( ).SelectSingleNode( Constants.ASSET_INSTANCE_ID + "[text()='" + identifier + "'" + "]", xmlnsm );
                                    newIdNumber = Guid.NewGuid( ).ToString( );
                                    newRow.MoveToParent( );
                                    newRow.InsertAfter( newRow.OuterXml );
                                    newRow.SelectSingleNode( "./my:ass_InstanceID", xmlnsm ).SetValue( newIdNumber );

                                    //create the new attachment row if there are any attachments
                                    for ( int j = 0; j < listOfAttachments.Count; j++ )
                                    {
                                        temp = listOfAttachments[j];
                                        temp.InsertAfter( temp.OuterXml );
                                        temp.SelectSingleNode( Constants.ATTACHMENT_SURVEY_ITEM, xmlnsm ).SetValue( newIdNumber );
                                        System.Windows.Forms.Application.DoEvents( );
                                    }
                                }

  • 05-04-2007 06:54 AM In reply to

    Re: Attempted to read or write protected memory

    Hi erinselena,

    Once I too got the problem with InsertAfter method in one project at that time i used the Append method and is worked, try that once.

     

    Hope this will help you.

    B.Shiva Prasad
    InfoPath Dev,
    http://www.ggktech.com
    India
  • 05-07-2007 07:07 AM In reply to

    Re: Attempted to read or write protected memory

    The only method i can find is appendChild and when i use that i get a "schema validation error", any idea what that means?
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.