Saskia Brand

Hi all,

I have a problem involving Word automation and the use of Paint.

The situation is:
A Word-document is being manipulated through automation. When I open Paint and copy (part of) the picture, I get a 'call was rejected by callee' error from the VB2005 application automating Word.

When I use sleep(100) and retry (resume) the statement, it works fine. However, as long as the Paint session is open, every action I perform on Word will require a second try. Since there's quite a lot of them, this will slow the application down considerably. As soon as Paint is closed, the Word-automation continues without errors.

Interesting detail: this application was upgraded from VB6, with only minimal changes. This problem did not occur in VB6.

Does anyone have any idea what causes this and/or how this can be solved
(Apart from forcing users to close Paint or use some other program for getting their screen captures, that is...)

Technical details:
Using XP SP2, Word 2003 SP2 and VS2005 Pro.

Thanks in advance,
Saskia Brand


Re: Visual Basic Interop and Upgrade RPC_E_CALL_REJECTED during Word automation from VB2005 when copying in Paint...

Jeff Tindall

You are not alone. I was able to replicate the issue, but don't have a good resolution (other than don't have MS Paint open). In my scenario, the environment is:

.NET 2.0 - C#
Word 2003
Windows XP Pro

I don't recall having this issue on the 1.1 Framework (but I have not verified yet).

Good luck, I hope someone can come up with a why...
~Jeff




Re: Visual Basic Interop and Upgrade RPC_E_CALL_REJECTED during Word automation from VB2005 when copying in Paint...

MSFT Abel Valadez

Is your application marked as STA or is not marked at all If so, try to change it to be an MTA and try it again.

http://msdn2.microsoft.com/en-us/library/system.mtathreadattribute.aspx

Hope this helps,






Re: Visual Basic Interop and Upgrade RPC_E_CALL_REJECTED during Word automation from VB2005 when copying in Paint...

Saskia Brand

I tried this on my test-app (I've been able to reproduce the problem at home) and unfortunately it didn't help much. The error changed from RPC_E_CALL_REJECTED to RPC_E_SERVERCALL_RETRYLATER, but that's it.

FYI, here's how I've reproduced this at home. Take a form (Form1) with a button (Button1) and paste the following code:

Public Class Form1
Dim mwrdapp As Word.Application
Dim blnContinue As Boolean = False

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
mwrdapp = New Word.Application
mwrdapp.Documents.Add()
mwrdapp.Visible = True
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Do
Try
mwrdapp.ActiveDocument.Range.Text &= "test copying in Paint" & vbCrLf
mwrdapp.ActiveDocument.SaveAs("c:\test.doc")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
Loop
End Sub
End Class

Run the app and click button1. You'll see "
test copying in Paint" being written to Word continuously. Now, open Paint, select an area of the canvas and copy it. Instant error...





Re: Visual Basic Interop and Upgrade RPC_E_CALL_REJECTED during Word automation from VB2005 when copying in Paint...

MSFT Abel Valadez

Does this only happen while debugging or does it happen if you run your application outside of the debugger too






Re: Visual Basic Interop and Upgrade RPC_E_CALL_REJECTED during Word automation from VB2005 when copying in Paint...

Saskia Brand

We actually found out through users saying the application 'kept crashing'. When we went to the user and looked at what they were doing we noticed the connection to Paint. So, this happens while debugging as wel as in the published application.



Re: Visual Basic Interop and Upgrade RPC_E_CALL_REJECTED during Word automation from VB2005 when copying in Paint...

MSFT Abel Valadez

If this also happens when running the application outside of the debugging environment, then it is a problem with either Word or Paint not responding to messages. Unfortunately, I am unable to help in this instance.