LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Report Generation Toolkit producing error -2147417842, "The application called an interface that was marshalled for a different thread."

Solved!
Go to solution

Hi everybody,

 

I've got an application that logs data to an Excel spreadsheet using the Report Generation Toolkit.  My VI's have worked fine in the past using Excel XP, but since I've upgraded to Excel 2007, I am getting COM errors like this one:

 

"Error -2147417842 occurred at The application called an interface that was marshalled for a different thread. in Excel_Insert_Text.vi"  That is the exact wording, even with the weird punctuation and capitalization.

 

The first occurrence of the error is not determinate.  Sometimes, up to 10 logging sessions, involving a new .xls file, can occur before this error pops up.  Once this error occurs, I must quit LabVIEW to resolve it.  If I try to do anything with Excel, I always get this error, although sometimes it comes out of different source VIs.  Excel_Open.vi is another.

 

These logging VIs have worked just fine until upgrading to Excel 2007.  I checked, and I was using a really old version of the Report Generation Toolkit, v1.0.1.  I read the documentation and had a big sigh of relief when I realized I needed to upgraded to v1.1.2 to get Excel 2007 support.  However, even after upgrading, I'm still getting the same errors.  I'm using LabVIEW 8.0.1, and I'm also building these VIs into an application.   The error occurs both in the LabVIEW IDE and in the built application.  Does anybody out there have any idea what I can do to fix this?  I googled a little, and discovered this is a COM error, but I can't find any references to the Report Generation Toolkit specifically.

 

Thanks,

Phil

0 Kudos
Message 1 of 10
(4,535 Views)

It might help to change the "Preffered Execution System" of the VI under the VI Settings to "Run in UI Thread".

 

 

Message 2 of 10
(4,514 Views)

Hi Christian,

 

I do not see that exact option listed, do you mean "user interface"?  I recognize the "Run in UI Thread" option, it's on the Call Library Function Node.

 

I checked, and my top-level VI has "same as caller" set, and I believe all my VIs are set to "same as caller".  Are you suggesting I change my top-level VI preferred execution environment to "user interface", or just the logging sub-VIs that use the Report Generation Toolkit?

 

Thanks,

Phil

0 Kudos
Message 3 of 10
(4,497 Views)

Hey,

 

Yes i mixed that up, its "user interface", so please set your top level VI to that one.

 

Thanks,

Christian

0 Kudos
Message 4 of 10
(4,483 Views)
Solution
Accepted by topic author Philip B

I think that fixes it!

 

Here's what I did: I left the top-level VI's preferred execution environment as "Same as caller".  I tried setting it to "user interface", but it seemed to slow the program down significantly.

 

Then I found every sub-VI that calls into the Report Generation Toolkit and set the preferred execution environment to "user interface".  All of the errors went away, and the program is much happier now.

 

Great guess on this one Christian, thanks!

Message 5 of 10
(4,467 Views)

Thanks guys, I run into the same error althought I didn't upgrade Excel (still running Excel 2003) and your solution worked fine. I still don't know why I started receiving this error.

 

Thanks again.

 

Ben64

0 Kudos
Message 6 of 10
(4,026 Views)

Thank you for the explanation. But i could not follow any of that . It would be really helpful if u could show it a video how that can be done .

0 Kudos
Message 7 of 10
(3,192 Views)

Creating a video is a lot of work so I'm not going to do that. But you do have some basic LabVIEW experience?

 

Every VI has a Properties dialog that you can open either from the menu "File->VI Properties" or with right click on the icon in the right upper corner of the front panel or diagram.

 

In there select the "Execution" setting from the "Category" drop down selection ring. And there you see a "Preferred Execution System" drop down slection box. Here you can select "user interface" for all the SubVIs in the project that call Report Generation functions.

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 10
(3,182 Views)

Dear Rolf Kalbermatter,

                                           Thank you for timely response. It works fine but as pointed earlier it slows down the speed of the program. Is there any way that can be tackled ?

0 Kudos
Message 9 of 10
(3,149 Views)

@pradeep3 wrote:

Dear Rolf Kalbermatter,

                                           Thank you for timely response. It works fine but as pointed earlier it slows down the speed of the program. Is there any way that can be tackled ?


You shouldn't just change te top level VI to run in the "user interface" thread, but only the subVI(s) which call the report generation functions. I hope you designed an application that uses subVIs diligently so that this shouldn't be a problem. If you didn't, you have more serious performance problems than the main VI being run in the user interface.

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 10
(3,145 Views)