Hi - I am using Infopath 2007 and VB.
I have a form with several bits of code behind the Changed/Changing events. The form's permissions are set to automatically determine level required.
I have started getting errors when running code.....
Dim grp As String = "/my:ApplicationGroup/my:ApplicationContactsGroup/my:InvistaITContactGroup"
Dim concat As String = ""
Dim itgroup As XPathNodeIterator
Dim navout As XPathNavigator
itgroup = Me.CreateNavigator.Select(grp, NamespaceManager)
Dim norecs As Integer = itgroup.Count <-------- at this point I get the error
System.Security.SecurityException was unhandled by user code
Message="Request failed."
Source="Microsoft.Office.InfoPath.Client.Internal.Host"
StackTrace:
at Microsoft.Office.InfoPath.MsxmlNavigator.IsValidNode(MsxmlNode test)
at Microsoft.Office.InfoPath.MsxmlNavigator.MoveToFirstChild()
at MS.Internal.Xml.XPath.XPathChildIterator.MoveNext()
at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
at MS.Internal.Xml.XPath.Query.MoveNext()
at MS.Internal.Xml.XPath.Query.get_Count()
at MS.Internal.Xml.XPath.XPathSelectionIterator.get_Count()
at ApplicationIndex10.FormCode.Concatenate_Multiple_owner_fields(String grp, String fld1, String fld2, String fld3, String fld4, String punc, String concatfield)
at ApplicationIndex10.FormCode.InvistaITContactGroup_Changed(Object sender, XmlEventArgs e)
at Microsoft.Office.InfoPath.Internal.XmlEventHost.GenericProxy(Object genericDelegate, DataDOMEvent dataDOMEvent, InfoPathEvents type)
at Microsoft.Office.InfoPath.Internal.XmlEventHost.ChangedProxy(DataDOMEvent dataDOMEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._DataDOMEventSink_SinkHelper.OnAfterChange(DataDOMEvent pDataDOMEvent)
When I am running in debug mode and have had the exception I go into 'enable edit', and re-run exactly the same lines of code and it works ........ so can't get to the bottom of the problem.
I don't understand why accessing a group in my main data source would give this error - and why it doesn't run in debug - but once it has had the error and I run the same lines again it works - can anyone explain where I have gone wrong.....
This is happening in several places in the code. The consistent thing is that it is always on a .count of a navigator where the problem occurs.
Thank you.
Catharine