Two very bad errors

F

FrankS

Using SP1 with VB managed code.

I have two recurring errors that do not seem to follow any logic or pattern.
I am getting closer to production and MUST resolve these remaining two bugs.
I really need some help. Thanks.
----------------------------------------------------------------
The first fails with almost every complex template. It happens with quite
often however not in the same templates or views or at the same point. These
are complex VB programs that build repeating tables from code from an
XMLDataDocument.

Error: System.Runtime.InteropServices.InvalidComObjectException COM object
that has been separated from its underlying RCW can not be used.

----------------------------------------------------------------
Second: This one is weird. If I change to a view (that has a repeating
table) and add a row using xcollection: insert. It fails. However if I put a
button on the view and launch the insert with the exact same code - it does
not fail.

Error: System.Runtime.InteropServices.COMException InfoPath has encountered
an error. The operation failed.
 
F

FrankS

Thanks Greg. The weird part is that if I switch the view and populate fields
i.e. textboes (in the new view) it works just fine. However if the view
contains a repeating table when I do the insert it dies. But not all the
time!! Only most of the time but sometimes it works fine. Can you elaborate
 
F

FrankS

Thanks Greg. You have bailed me out again! The flag did the trick. :)

Any thoughts on the “COM object has been separated from its underlying RCWâ€
error? I read in the newsgroup it was fixed in SP1 but it fails all over
these Managed Code templates with SP1. The weird part it is not consistent
and does not fail at all some times. Any ideas?

Greg Collins said:
Remember, these are two different beasts. The ExecuteAction is an oddball in InfoPath -- it works on the view and not the data. When you set text box values, you are working ont the data. The data always exists. When you are using ExecuteCommand, you are working on the view -- which has to be built and is constantly being refreshed.

Keep in mind, I haven't tried this yet...

In the OnSwitchView event handler, set some flag: fSwitchedToViewFoo = true;
In the OnContextChange event handler check if the flag is true then do you ExecuteAction call, and reset the flag:
if(true == fSwitchedToViewFoo)
{
XDocument.View.ExecuteAction(...);
fSwitchedToViewFoo = false;
}

It is my understanding that ExecuteAction will not occur until after OnSwitchView has finished and the view is completely drawn.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Thanks Greg. The weird part is that if I switch the view and populate fields
i.e. textboes (in the new view) it works just fine. However if the view
contains a repeating table when I do the insert it dies. But not all the
time!! Only most of the time but sometimes it works fine. Can you elaborate
I believe your second issue is just timing. You are likely using the OnViewSwitch event handler to attempt the ExecuteAction command. I believe at this point the view has not been fully created, so your insertion will fail, as ExecuteAction is unique in InfoPath as it works on Views rather than Data (this is kind of an awkward thing to deal with).

I haven't tried it, but you might be able to set a flag in the OnViewSwitch event handler and then check for this flag in the OnContextChange event handler to perform the insert.

Please let us know if this works.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Using SP1 with VB managed code.

I have two recurring errors that do not seem to follow any logic or pattern.
I am getting closer to production and MUST resolve these remaining two bugs.
I really need some help. Thanks.
----------------------------------------------------------------
The first fails with almost every complex template. It happens with quite
often however not in the same templates or views or at the same point. These
are complex VB programs that build repeating tables from code from an
XMLDataDocument.

Error: System.Runtime.InteropServices.InvalidComObjectException COM object
that has been separated from its underlying RCW can not be used.

----------------------------------------------------------------
Second: This one is weird. If I change to a view (that has a repeating
table) and add a row using xcollection: insert. It fails. However if I put a
button on the view and launch the insert with the exact same code - it does
not fail.

Error: System.Runtime.InteropServices.COMException InfoPath has encountered
an error. The operation failed.
 

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

Top