Invalid context for OM call

W

Wozza

I have a dropdown listbox, and am trying to change views based on the value
selected ... but am getting the error below. I read that there are no
restrictions on changing views in a Changed event ...?? Is this correct. If
so why am I getting this error?

System.Runtime.InteropServices.COMException
Invalid context for OM call.
at Microsoft.Office.Interop.InfoPath.SemiTrust.View.SwitchView(String
bstrName)
at
Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.SwitchView(String
bstrName)
at
Microsoft.Office.InfoPath.Internal.ViewInfoCollectionHost.SwitchView(String
name)
at PagingThruViews.FormCode.INDEX_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)

My code is (I have "View 1" and "View 2"):

public void InternalStartup()

{

EventManager.XmlEvents["/TEST/INDEX"].Changed += new
XmlChangedEventHandler(INDEX_Changed);

}

public void INDEX_Changed(object sender, XmlEventArgs e)

{

this.ViewInfos.SwitchView(@"View " + e.NewValue.ToString().Trim());

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SwitchView Error 2

Top