Connection to Exchange diconnected when using VSTO Add-In

Category: visual studio officetools


BeSt79 on Mon, 11 Jun 2018 10:30:12


My name is Benjamin, I am new to Outlook Add-In Development...

I am trying to develop a small Outlook 2016 Add-In via VSTO in Visual Studio Pro 2017.

I was able to get the addin working. The Add-Ins task is only create a new message with a defined signature. Therefore I added some buttons on a ribbon tab and add this tab to the Outlook Explorer Window.

Everythin works like a charm, besinde of the following problem:

When activating this addin Outlook and its connection to the Exchange Server gets very unstable. Suddenly the connection was lost and Outlook shows "Disconnected" on the bottom status bar. (I am using a german outlook, and there it reads "Getrennt" instead of "Verbunden mit Microsoft Exchange", when everything was fine).

I am sure, that the reason for this instability is the addin, because if I de-install the addin and start Outlook, everything is fine and stable.

Can anyone give me some hints, where I have to start the search, why my addin causes these problems?

Thank you



Terry Xu - MSFT on Tue, 12 Jun 2018 02:04:54

Hello Benjamin,

First, I would suggest you remove/disable all the other add-ins and then run the add-in to check if the issue is related to the add-in in case of any add-in conflict.

If the issue  does related to the add-in. I'm wondering if parts code of the add-in caused the issue.

I would suggest you create a new and blank Outlook add-in. Will the new add-in cause this issue?

If the new add-in does not cause the issue, I think there must be some code in your add-in caused this issue. Then I would suggest you comment your code part by part to confirm which part caused this issue.

Best Regards,


BeSt79 on Tue, 12 Jun 2018 09:49:58

Hi Terry

Thank you very much for your message.

I deactivated all other add-ins, so that only my own add-in is loaded. > Same error

Then de-installed my add-in and started a completely new VSTO-project. I left this project empty. No code in it beside of the "standard" function sceleton:

Public Class ThisAddIn

    Private Sub ThisAddIn_Startup() Handles Me.Startup

    End Sub

    Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown

    End Sub

End Class

But when "debugging" this add-in (or installing it) and starting Outlook: > Same error.

When showing the status window, the mentioned error code is: 0x80040115

So I am - at the moment - unable to develop a VSTO Add-In. That is very disappointing, because we switched from another email server to Exchange with Outlook mailny BECAUSE of the possible add-in-development.

Every help is very appreciated.

Best regards


BeSt79 on Tue, 12 Jun 2018 11:54:21

I found out, that the ExchangeServer records an error relating to the number of sessions:

Mapi session /o=OurDomain/ou=Exchange Administrative Group /cn=Recipients/cn=MyExchangeAccount with client type MoMT exceeded the maximum of 32 objects of type Session.

Surely I could raise the number of possible objects of type Session, but that would not be constructive - I rather should find out, why my Outlook client requerst so much sessions when starting an completely empty add-in...

Anybody any ideas?

Thank you


Terry Xu - MSFT on Wed, 13 Jun 2018 10:06:21

Hello BeSt79,

What's session number if you do not add any add-ins? What's the session number if you load an add-in? Except custom add-ins, MS Outlook also provide some built-in add-ins. Will they create any more sessions?

Best Regards,


BeSt79 on Wed, 13 Jun 2018 12:14:03

This morning I found out, that the problem only occurs on my dev machine.

I installed my add-in on a client machine for testing purposes. The add-in and Outlook worked normally.

I could imagine, that the problem occurs, when debugging the add-in and facing some errors, so that the Outlook application could not be exited correctly, but exited via "debug stop" in de Visual Studio. In this case, propably, the ressources and sessions are not released and are still blocked by some processes.

I also found out, that the standard "release timeout" for sessions on the exchange server is 2 hours by standard. So after some (long) time I can connect to Exchange even if the add-in is loaded. So I changed the session timeout time to a value, which microsoft recommends in another forum (5 minutes). The "orphaned" sessions on my dev machine should then be released sooner.

I think the problem is solved.

Terry Xu - MSFT on Thu, 14 Jun 2018 01:16:30

Hello Best79,

Glad to hear that your issue has been resolved. I would suggest you mark your solution to close the thread. If you have any other issue, please feel free to post to let us know.

Best Regards,