Outlook AddIn does not always load

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

Outlook AddIn does not always load
Outlook Addin loads only sometimes on F5 
Sri Potluri




Posts: 14
Joined: 2016-05-13
Hi,

I am having a problem developing an Outlook add-in.
I have observed this behavior:
When I click F5 on VS, sometimes the Outlook add-in is seen and the program has completed execution.
Other times when using F5 the add-in is not attached, the Ribbon doesn't show but the program is hung in Debugging mode.
I tried adding breakpoints, it does not break at breakpoints and I don't see the add-in show up at all with the program stuck in debugging mode.
When I Rebuild my code, the add-in shows up in Outlook but the program has completed execution and is not in debugging mode in VS.

I have checked the following so far:
-I registered the add-in and unregistered and registered it again a couple of times.
-The LoadBehaviour is 3 in the registry at Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\Addins \MyCustomAddin.AddinModule.
-I checked the Disabled Items list of my host application and I do not see the add-in as disabled.
-Checked the outlook.exe.config file in C:\Program Files (x86)\Microsoft Office\Office15 and it shows the <supportedRuntime version="v4.0.30319" />

My Environment:
-Windows 8 64 bit
-Visual Studio 2013
-Outlook 2013
-.NET Framework 4.5.1
Can someone please help me with this issue.
Posted 13 May, 2016 15:23:22 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Sri,

First off, make sure that your add-in gets loaded. Start the host application and check if your add-in is listed in the dialog opened via File | Options | Add-ins. If it is listed there, then note under what group heading. If it isn't, check File | Info | Slow and Disabled add-ins.


Andrei Smolin
Add-in Express Team Leader
Posted 16 May, 2016 07:47:54 Top
Sri Potluri




Posts: 14
Joined: 2016-05-13
Hi Andrei,

Thank you for the response. I see it listed under File | Options | Add-ins as a COM Add-in.
Posted 16 May, 2016 10:04:05 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Under what group heading?


Andrei Smolin
Add-in Express Team Leader
Posted 16 May, 2016 10:05:50 Top
Sri Potluri




Posts: 14
Joined: 2016-05-13
It is listed under Active Application Add-ins
Posted 16 May, 2016 10:09:39 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
I assume this means it works correctly.


Andrei Smolin
Add-in Express Team Leader
Posted 16 May, 2016 10:23:28 Top
Sri Potluri




Posts: 14
Joined: 2016-05-13
Is the behavior listed in my first message expected behavior?
I do not see the Ribbon when the application is running and also I am not able to set any breakpoints to debug.
Where can I start to look for a cause as to why the Ribbon is not seen?
Posted 16 May, 2016 10:27:59 Top
Sri Potluri




Posts: 14
Joined: 2016-05-13
Hi,

I declared some Public parameters in the class and I think this was causing the issue.
I removed them and added them as local variables inside methods and this solved the issue.
It was showing up and also the debugger seems to work fine.
Is there a way I can declare variables as Public without causing this issue?
Posted 16 May, 2016 10:43:17 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Thank you for letting us know.

Public parameters? Could you please provide an example of a parameter that caused this issue?


Andrei Smolin
Add-in Express Team Leader
Posted 17 May, 2016 06:09:37 Top
Sri Potluri




Posts: 14
Joined: 2016-05-13
Hi Andrei,

It works if the code is like follows:

Public Class AddinModule
Inherits AddinExpress.MSO.ADXAddinModule

#Region " Add-in Express automatic code "

'Required by Add-in Express - do not modify
'the methods within this region

Public Overrides Function GetContainer() As System.ComponentModel.IContainer
If components Is Nothing Then
components = New System.ComponentModel.Container
End If
GetContainer = components
End Function

<ComRegisterFunctionAttribute()> _
Public Shared Sub AddinRegister(ByVal t As Type)
AddinExpress.MSO.ADXAddinModule.ADXRegister(t)
End Sub

<ComUnregisterFunctionAttribute()> _
Public Shared Sub AddinUnregister(ByVal t As Type)
AddinExpress.MSO.ADXAddinModule.ADXUnregister(t)
End Sub

Public Overrides Sub UninstallControls()
MyBase.UninstallControls()
End Sub

#End Region

Public Shared Shadows ReadOnly Property CurrentInstance() As AddinModule
Get
Return CType(AddinExpress.MSO.ADXAddinModule.CurrentInstance, AddinModule)
End Get
End Property

Public ReadOnly Property OutlookApp() As Outlook._Application
Get
Return CType(HostApplication, Outlook._Application)
End Get
End Property


Private Sub AdxRibbonButton1_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles AdxRibbonButton1.OnClick
Dim oApp As Outlook.Application = New Outlook.Application
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI")
MessageBox.Show("Hello World!!!")
End Sub

If I declare oApp and oNS as Public and declare them outside method and inside the class, I see the issue.
Posted 17 May, 2016 13:27:18 Top