Interesting problem that has occured the last couple of year - VB.Net and Outlook

Add-in Express™ Support Service
That's what is more important than anything else

Interesting problem that has occured the last couple of year - VB.Net and Outlook
Our Add-IN is not read to answer our calls 
Subscribe
petgre




Posts: 27
Joined: 2014-04-29
Hi, normally we use:

olApp = GetObject(, "Outlook.Application")
Has been working for at least ten years.
Late binding.

After the last years update of Outlook it will not really work.

It will always start Outlook (365, latest version) , but my add-in is not ready to answer my “hello”

So we tried to start Outlook as a new process:

Dim myProcess As New Process()
myProcess.StartInfo.FileName = sAPPPath ' path to Outlook
myProcess.Start()
myProcess.WaitForInputIdle()

The last row is not really true from our point of view 😊

Then continuing with our internal stuff.
At the end we say “hey” to our add-in.
Connection is established.

BUT, it you have a user with enormous number of inboxes, 10 thousands of deleted mail etc, Outlook is not read to say hallo to my application.

Do you have any idea how to start Outlook and WAIT until my add in is ready for action?

If we start Outlook first, everything is fine, but the users has been learned to start our application first.

I am getting nuts on this, spend enormous time to produce absolute nothing, so please HELP ME with any suggestions 😊

We are using :

Public Interface ICommunicationService
Sub SaySomething(text As String)
End Interface

At both ends, have been working for years.

And as I say, if Outlook is started first, everything is fine.

Works in both 32 and 64 bit versions of Outlook.
But now this!


Regards Peter!
Posted 11 Jun, 2021 02:47:29 Top
Andrei Smolin


Add-in Express team


Posts: 17740
Joined: 2006-05-11
Hello Peter,

petgre writes:
It will always start Outlook (365, latest version) , but my add-in is not ready to answer my “hello”



What do you mean by "not ready"?

I would research the startup sequence (if there are Explorer objects, what Outlook events your application receives before the add-in receives AddinStartupComplete) and try to get the very first Explorer.Activate event.

Also, consider changing the logic so that the "conversation" is initiated the add-in, not by the application.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 11 Jun, 2021 04:32:32 Top
petgre




Posts: 27
Joined: 2014-04-29
By not ready equal to my add in will not respond to calls from my application, due to long startup time. Even if Outlook seems to be ready!

Yes, we can change the startup sequence to the other way, but the user has always started our crm system first, who will then launch Outlook. I dont think the other way around is a good solution.

For some reason, on some users Outlooks, my add-in will not respond from the application call due to long startup time of Outlook.

If I start Outlook first, no problems at all. For me this is a indication that the add-in is not yet ready to answer?

Can I launch Outlook first and somehow be sure that it is up and running? myProcess.WaitForInputIdle() does not ensure this unfortunately.

One interesting thing is that we have never had any problems like this before, just CreateObject has alwas worked. It is the last year or two that this has given us a problem?

//Peter
Posted 11 Jun, 2021 06:25:13 Top
Andrei Smolin


Add-in Express team


Posts: 17740
Joined: 2006-05-11
Hello Peter,

I believe I miss something.

I assume you call your add-in using Application.COMAddins[strYourAddinProgId].Object.SomeMethod(). In that context, "my add-in will not respond" doesn't seem possible: either you get a response or you get an exception; this may occur immediately or after a delay.

petgre writes:
Can I launch Outlook first and somehow be sure that it is up and running?


Your add-in can send a message to your application thus confirming that it is ready to work.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 11 Jun, 2021 06:44:20 Top
petgre




Posts: 27
Joined: 2014-04-29
Correct, I got an exception.
But if I wait a while, and then "reconnect" manually, it works.
So, from my point of view, the add-in is not ready to answer the call, and then exception.

I use something I found many years ago, for intercomunication between two apps.


Something like this

Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Ipc
Public Class Form1

Private Sub cmdSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSend.Click
Dim ipcCh As New IpcChannel("myClient")
ChannelServices.RegisterChannel(ipcCh, False)

Dim obj As SharedInterfaces.ICommunicationService = _
DirectCast(Activator.GetObject(GetType(SharedInterfaces.ICommunicationService), _
"ipc://IPChannelName/SreeniRemoteObj"), SharedInterfaces.ICommunicationService)
obj.SaySomething(txtText.Text)

ChannelServices.UnregisterChannel(ipcCh)
End Sub

End Class
Posted 11 Jun, 2021 06:51:02 Top
Andrei Smolin


Add-in Express team


Posts: 17740
Joined: 2006-05-11
Hello Peter,

I've talked with our guys and they suggest that you regard your application as server and the add-in as client. Accordingly, the add-in should inform the server that it's started. We always use NamedPipeServerStream and NamedPipeClientStream classes to let the server communicate with the client; see https://docs.microsoft.com/en-us/dotnet/standard/io/how-to-use-named-pipes-for-network-interprocess-communication.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Jun, 2021 05:27:37 Top
petgre




Posts: 27
Joined: 2014-04-29
Hi Andrei

I will test this, having the same communication approach as today, but change the add-in to say "Started" to my application, and then inititiate the rest.

Thanks!

//Peter
Posted 14 Jun, 2021 05:34:30 Top
Andrei Smolin


Add-in Express team


Posts: 17740
Joined: 2006-05-11
Welcome!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Jun, 2021 05:57:52 Top
petgre




Posts: 27
Joined: 2014-04-29
Hi

I have tested it, now my Addd-in says STARTED to my application, no matter how long times it takes to start Outlook.
Seems to be working. If my application failes to connect, then the add-in says started. And the connection is established.

thanks a lot!

//Peter
Posted 16 Jun, 2021 03:26:59 Top
Andrei Smolin


Add-in Express team


Posts: 17740
Joined: 2006-05-11
Congratulations!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 16 Jun, 2021 06:23:36 Top