PC Review


Reply
Thread Tools Rate Thread

How to prevent Outlook add-in from being disabled?

 
 
Vidya
Guest
Posts: n/a
 
      21st Jul 2008
We have an Outlook 2003 addin written in VSTO 2005. We deploy into HKLM so
there is no manual way to disable the addin using Outlook Tools menu. In
production mode, the addin still gets disabled sometimes. We have found out
that one of the ways that user can disable the addin is by killing the
Outlook process while it is still loading. We have implemented ways to make
the addin start up faster and there is not much we can do there.

Are there other ways in which the addin can be disabled? If so, how can we
prevent the addin from being disabled? We implement ThisAddin_Startup and
ThisAddin_Shutdown methods and these are enclosed in try..catch blocks.

Thanks

 
Reply With Quote
 
 
 
 
keremskusmezer@gmail.com
Guest
Posts: n/a
 
      22nd Jul 2008
We had the same problem, therefore we also distribute a signed otm
file with our VSTO Addins For Outlook.

In the Application_Startup Event of the Application object inside our
otm file,
we check the registry entries for particular addins and if the addin
has been disabled , we change the registry settings correspondingly to
the normal state and force a restart in outlook with Application.Quit
command.

Public Function CheckOutlookAddins(SourceApplication As Application)
Dim csfKey As String
csfKey = RegRead(HKEY_CURRENT_USER, "Software\Nowhere\NoWhereAddin",
"CheckReinstall")
If csfKey = "1" Then
On Error GoTo Cleanup
Set generalApplication = SourceApplication
Dim outlookApplication As Application
Set outlookApplication = SourceApplication
Dim correctionResult As Boolean
Dim addinCount As Integer
Dim foundAddin As COMAddIn
addinCount = outlookApplication.COMAddIns.Count
For i = 1 To addinCount
If outlookApplication.COMAddIns(i).Description = CSFDescription
Then
Set foundAddin = outlookApplication.COMAddIns(i)
If Not foundAddin.Connect Then
On Error Resume Next
foundAddin.Connect = True
If Err.Number <> 0 Then
Err.Clear
Set foundAddin = Nothing
End If
On Error GoTo Cleanup
Exit For
Else
Exit For
End If
End If
Next

'Everything Running Fine Exit Loop
If foundAddin Is Nothing Then
Dim processResult As CreationStates
processResult = ProcessRegistryKeys()
Select Case processResult
Case CreationStates.CreationSuccess
If Not CheckOutlookAddinsStandalone(SourceApplication,
False) Then
CheckOutlookAddinsStandalone SourceApplication, True
End If
Case CreationStates.DllIsMissing
MsgBox ("Addin Dlls Missing. Registry Key Will Be
Disabled")
RegWrite HKEY_CURRENT_USER, "Software\Nowhere
\NoWhereAddin", "CheckReinstall", "0"
Exit Function
Case Else
GoTo Cleanup
End Select
Else
CorrectAddinStructure SourceApplication, foundAddin
End If

Exit Function

Cleanup:
Set outlookApplication = Nothing
Set generalApplication = Nothing
Set foundAddin = Nothing
MsgBox GetCurrentLanguageFromParameters & Err.Description
End If
End Function

On Jul 21, 11:09*pm, Vidya <Vi...@discussions.microsoft.com> wrote:
> We have an Outlook 2003 addin written in VSTO 2005. We deploy into HKLM so
> there is no manual way to disable the addin using Outlook Tools menu. In
> production mode, the addin still gets disabled sometimes. We have found out
> that one of the ways that user can disable the addin is by killing the
> Outlook process while it is still loading. We have implemented ways to make
> the addin start up faster and there is not much we can do there.
>
> Are there other ways in which the addin can be disabled? If so, how can we
> prevent the addin from being disabled? We implement ThisAddin_Startup and
> ThisAddin_Shutdown methods and these are enclosed in try..catch blocks.
>
> Thanks


 
Reply With Quote
 
keremskusmezer@gmail.com
Guest
Posts: n/a
 
      22nd Jul 2008
Do you have Threading Exception Handler or Application Exception
Handler installed?

On Jul 21, 11:09*pm, Vidya <Vi...@discussions.microsoft.com> wrote:
> We have an Outlook 2003 addin written in VSTO 2005. We deploy into HKLM so
> there is no manual way to disable the addin using Outlook Tools menu. In
> production mode, the addin still gets disabled sometimes. We have found out
> that one of the ways that user can disable the addin is by killing the
> Outlook process while it is still loading. We have implemented ways to make
> the addin start up faster and there is not much we can do there.
>
> Are there other ways in which the addin can be disabled? If so, how can we
> prevent the addin from being disabled? We implement ThisAddin_Startup and
> ThisAddin_Shutdown methods and these are enclosed in try..catch blocks.
>
> Thanks


 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      22nd Jul 2008
If Outlook has "hard disabled" an addin the only way to get it re-enabled
without the user re-enabling it from the Disabled Items dialog is to delete
the resiliency key in the registry when Outlook is not running or force a
restart. Merely changing the LoadBehavior value is not sufficient. And
deleting the resiliency key is not a good thing since it will also re-enable
any other disabled addins.

In addition, distributing an OTM file is also not the best way to go, that
overwrites any OTM file the user may have. If your code did that to my
Outlook VBA project I'd rip it out and never install it ever again.

You should handle all exceptions and use defensive programming where
possible to avoid any exceptions, that's the way to not get disabled.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


<(E-Mail Removed)> wrote in message
news:d6b17456-908e-429c-8674-(E-Mail Removed)...
We had the same problem, therefore we also distribute a signed otm
file with our VSTO Addins For Outlook.

In the Application_Startup Event of the Application object inside our
otm file,
we check the registry entries for particular addins and if the addin
has been disabled , we change the registry settings correspondingly to
the normal state and force a restart in outlook with Application.Quit
command.

Public Function CheckOutlookAddins(SourceApplication As Application)
Dim csfKey As String
csfKey = RegRead(HKEY_CURRENT_USER, "Software\Nowhere\NoWhereAddin",
"CheckReinstall")
If csfKey = "1" Then
On Error GoTo Cleanup
Set generalApplication = SourceApplication
Dim outlookApplication As Application
Set outlookApplication = SourceApplication
Dim correctionResult As Boolean
Dim addinCount As Integer
Dim foundAddin As COMAddIn
addinCount = outlookApplication.COMAddIns.Count
For i = 1 To addinCount
If outlookApplication.COMAddIns(i).Description = CSFDescription
Then
Set foundAddin = outlookApplication.COMAddIns(i)
If Not foundAddin.Connect Then
On Error Resume Next
foundAddin.Connect = True
If Err.Number <> 0 Then
Err.Clear
Set foundAddin = Nothing
End If
On Error GoTo Cleanup
Exit For
Else
Exit For
End If
End If
Next

'Everything Running Fine Exit Loop
If foundAddin Is Nothing Then
Dim processResult As CreationStates
processResult = ProcessRegistryKeys()
Select Case processResult
Case CreationStates.CreationSuccess
If Not CheckOutlookAddinsStandalone(SourceApplication,
False) Then
CheckOutlookAddinsStandalone SourceApplication, True
End If
Case CreationStates.DllIsMissing
MsgBox ("Addin Dlls Missing. Registry Key Will Be
Disabled")
RegWrite HKEY_CURRENT_USER, "Software\Nowhere
\NoWhereAddin", "CheckReinstall", "0"
Exit Function
Case Else
GoTo Cleanup
End Select
Else
CorrectAddinStructure SourceApplication, foundAddin
End If

Exit Function

Cleanup:
Set outlookApplication = Nothing
Set generalApplication = Nothing
Set foundAddin = Nothing
MsgBox GetCurrentLanguageFromParameters & Err.Description
End If
End Function

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      22nd Jul 2008
An addin gets disabled for one of 2 reasons. Either it has unhandled
exceptions, or it's running in the same AppDomain as another application
that has unhandled exceptions.

VSTO takes care of the AppDomain by loading your addin into its own
AppDomain. The rest is your defensive programming to first prevent
exceptions and then to handle any that still might arise.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Vidya" <(E-Mail Removed)> wrote in message
news:68284EED-E200-486B-B6EB-(E-Mail Removed)...
> We have an Outlook 2003 addin written in VSTO 2005. We deploy into HKLM so
> there is no manual way to disable the addin using Outlook Tools menu. In
> production mode, the addin still gets disabled sometimes. We have found
> out
> that one of the ways that user can disable the addin is by killing the
> Outlook process while it is still loading. We have implemented ways to
> make
> the addin start up faster and there is not much we can do there.
>
> Are there other ways in which the addin can be disabled? If so, how can we
> prevent the addin from being disabled? We implement ThisAddin_Startup and
> ThisAddin_Shutdown methods and these are enclosed in try..catch blocks.
>
> Thanks
>


 
Reply With Quote
 
Vidya
Guest
Posts: n/a
 
      23rd Jul 2008
Thanks Ken. Thats the approach we are trying to follow now (exception
handling in code). We are not able to put try..catch blocks in event handlers
though, especially the ones that have an Execute statement on a button or
menu item. The Execute statement won't run if its within a try..catch block.
Any idea why? Are we missing something?

thanks
vidya

"Ken Slovak - [MVP - Outlook]" wrote:

> If Outlook has "hard disabled" an addin the only way to get it re-enabled
> without the user re-enabling it from the Disabled Items dialog is to delete
> the resiliency key in the registry when Outlook is not running or force a
> restart. Merely changing the LoadBehavior value is not sufficient. And
> deleting the resiliency key is not a good thing since it will also re-enable
> any other disabled addins.
>
> In addition, distributing an OTM file is also not the best way to go, that
> overwrites any OTM file the user may have. If your code did that to my
> Outlook VBA project I'd rip it out and never install it ever again.
>
> You should handle all exceptions and use defensive programming where
> possible to avoid any exceptions, that's the way to not get disabled.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> <(E-Mail Removed)> wrote in message
> news:d6b17456-908e-429c-8674-(E-Mail Removed)...
> We had the same problem, therefore we also distribute a signed otm
> file with our VSTO Addins For Outlook.
>
> In the Application_Startup Event of the Application object inside our
> otm file,
> we check the registry entries for particular addins and if the addin
> has been disabled , we change the registry settings correspondingly to
> the normal state and force a restart in outlook with Application.Quit
> command.
>
> Public Function CheckOutlookAddins(SourceApplication As Application)
> Dim csfKey As String
> csfKey = RegRead(HKEY_CURRENT_USER, "Software\Nowhere\NoWhereAddin",
> "CheckReinstall")
> If csfKey = "1" Then
> On Error GoTo Cleanup
> Set generalApplication = SourceApplication
> Dim outlookApplication As Application
> Set outlookApplication = SourceApplication
> Dim correctionResult As Boolean
> Dim addinCount As Integer
> Dim foundAddin As COMAddIn
> addinCount = outlookApplication.COMAddIns.Count
> For i = 1 To addinCount
> If outlookApplication.COMAddIns(i).Description = CSFDescription
> Then
> Set foundAddin = outlookApplication.COMAddIns(i)
> If Not foundAddin.Connect Then
> On Error Resume Next
> foundAddin.Connect = True
> If Err.Number <> 0 Then
> Err.Clear
> Set foundAddin = Nothing
> End If
> On Error GoTo Cleanup
> Exit For
> Else
> Exit For
> End If
> End If
> Next
>
> 'Everything Running Fine Exit Loop
> If foundAddin Is Nothing Then
> Dim processResult As CreationStates
> processResult = ProcessRegistryKeys()
> Select Case processResult
> Case CreationStates.CreationSuccess
> If Not CheckOutlookAddinsStandalone(SourceApplication,
> False) Then
> CheckOutlookAddinsStandalone SourceApplication, True
> End If
> Case CreationStates.DllIsMissing
> MsgBox ("Addin Dlls Missing. Registry Key Will Be
> Disabled")
> RegWrite HKEY_CURRENT_USER, "Software\Nowhere
> \NoWhereAddin", "CheckReinstall", "0"
> Exit Function
> Case Else
> GoTo Cleanup
> End Select
> Else
> CorrectAddinStructure SourceApplication, foundAddin
> End If
>
> Exit Function
>
> Cleanup:
> Set outlookApplication = Nothing
> Set generalApplication = Nothing
> Set foundAddin = Nothing
> MsgBox GetCurrentLanguageFromParameters & Err.Description
> End If
> End Function
>
>

 
Reply With Quote
 
Vidya
Guest
Posts: n/a
 
      23rd Jul 2008
We dont use an otm file but we have a script to reenable the disabled addin
using Windows logon script. This is handled by our system admins. We also
parse the binary value in the resiliency key to read the entry corresponding
to our add-in and delete just that entry. It works. We are also looking into
creating another add-in in Outlook that might simply check for the registry
entry and reenable the original add-in. But these steps are after the fact
and does not prevent the add-in from getting disabled again in the future.

Thanks for your input though.

"(E-Mail Removed)" wrote:

> We had the same problem, therefore we also distribute a signed otm
> file with our VSTO Addins For Outlook.
>
> In the Application_Startup Event of the Application object inside our
> otm file,
> we check the registry entries for particular addins and if the addin
> has been disabled , we change the registry settings correspondingly to
> the normal state and force a restart in outlook with Application.Quit
> command.
>
> Public Function CheckOutlookAddins(SourceApplication As Application)
> Dim csfKey As String
> csfKey = RegRead(HKEY_CURRENT_USER, "Software\Nowhere\NoWhereAddin",
> "CheckReinstall")
> If csfKey = "1" Then
> On Error GoTo Cleanup
> Set generalApplication = SourceApplication
> Dim outlookApplication As Application
> Set outlookApplication = SourceApplication
> Dim correctionResult As Boolean
> Dim addinCount As Integer
> Dim foundAddin As COMAddIn
> addinCount = outlookApplication.COMAddIns.Count
> For i = 1 To addinCount
> If outlookApplication.COMAddIns(i).Description = CSFDescription
> Then
> Set foundAddin = outlookApplication.COMAddIns(i)
> If Not foundAddin.Connect Then
> On Error Resume Next
> foundAddin.Connect = True
> If Err.Number <> 0 Then
> Err.Clear
> Set foundAddin = Nothing
> End If
> On Error GoTo Cleanup
> Exit For
> Else
> Exit For
> End If
> End If
> Next
>
> 'Everything Running Fine Exit Loop
> If foundAddin Is Nothing Then
> Dim processResult As CreationStates
> processResult = ProcessRegistryKeys()
> Select Case processResult
> Case CreationStates.CreationSuccess
> If Not CheckOutlookAddinsStandalone(SourceApplication,
> False) Then
> CheckOutlookAddinsStandalone SourceApplication, True
> End If
> Case CreationStates.DllIsMissing
> MsgBox ("Addin Dlls Missing. Registry Key Will Be
> Disabled")
> RegWrite HKEY_CURRENT_USER, "Software\Nowhere
> \NoWhereAddin", "CheckReinstall", "0"
> Exit Function
> Case Else
> GoTo Cleanup
> End Select
> Else
> CorrectAddinStructure SourceApplication, foundAddin
> End If
>
> Exit Function
>
> Cleanup:
> Set outlookApplication = Nothing
> Set generalApplication = Nothing
> Set foundAddin = Nothing
> MsgBox GetCurrentLanguageFromParameters & Err.Description
> End If
> End Function
>
> On Jul 21, 11:09 pm, Vidya <Vi...@discussions.microsoft.com> wrote:
> > We have an Outlook 2003 addin written in VSTO 2005. We deploy into HKLM so
> > there is no manual way to disable the addin using Outlook Tools menu. In
> > production mode, the addin still gets disabled sometimes. We have found out
> > that one of the ways that user can disable the addin is by killing the
> > Outlook process while it is still loading. We have implemented ways to make
> > the addin start up faster and there is not much we can do there.
> >
> > Are there other ways in which the addin can be disabled? If so, how can we
> > prevent the addin from being disabled? We implement ThisAddin_Startup and
> > ThisAddin_Shutdown methods and these are enclosed in try..catch blocks.
> >
> > Thanks

>
>

 
Reply With Quote
 
Vidya
Guest
Posts: n/a
 
      23rd Jul 2008

No, what is this? Where can I get it? I googled, but couldnt find anything.
I have normal exception handling that .NET provides.

thanks

"(E-Mail Removed)" wrote:

> Do you have Threading Exception Handler or Application Exception
> Handler installed?
>
> On Jul 21, 11:09 pm, Vidya <Vi...@discussions.microsoft.com> wrote:
> > We have an Outlook 2003 addin written in VSTO 2005. We deploy into HKLM so
> > there is no manual way to disable the addin using Outlook Tools menu. In
> > production mode, the addin still gets disabled sometimes. We have found out
> > that one of the ways that user can disable the addin is by killing the
> > Outlook process while it is still loading. We have implemented ways to make
> > the addin start up faster and there is not much we can do there.
> >
> > Are there other ways in which the addin can be disabled? If so, how can we
> > prevent the addin from being disabled? We implement ThisAddin_Startup and
> > ThisAddin_Shutdown methods and these are enclosed in try..catch blocks.
> >
> > Thanks

>
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      23rd Jul 2008
I haven't tried calling Execute on a button inside a try...catch block so I
have no idea about that, but in other event handlers you can't do certain
things and the normal workaround is to enable a timer and set a flag at the
end of the event handler code. When the timer fires it's disabled and the
flag checked and if set you then call the code you want, in your case the
Execute call. That might work for you.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Vidya" <(E-Mail Removed)> wrote in message
news:68FE446B-72AA-4691-A24E-(E-Mail Removed)...
> Thanks Ken. Thats the approach we are trying to follow now (exception
> handling in code). We are not able to put try..catch blocks in event
> handlers
> though, especially the ones that have an Execute statement on a button or
> menu item. The Execute statement won't run if its within a try..catch
> block.
> Any idea why? Are we missing something?
>
> thanks
> vidya


 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      23rd Jul 2008
I'm not sure exactly what events Kerem was referring to but I usually put
one or two general event handlers like that into my code as catch-alls.

One I use is AppDomain.CurrentDomain.UnhandledException(). The other if I'm
doing a lot of thread manipulation is to add a
System.Threading.ThreadExceptionEventHandler() to my code.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Vidya" <(E-Mail Removed)> wrote in message
news:92FD2572-A7AB-4433-AE15-(E-Mail Removed)...
>
> No, what is this? Where can I get it? I googled, but couldnt find
> anything.
> I have normal exception handling that .NET provides.
>
> thanks
>
> "(E-Mail Removed)" wrote:
>
>> Do you have Threading Exception Handler or Application Exception
>> Handler installed?
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Registry Tip of The Day - How to Prevent The Vista Security Center Complaining About UAC Being Disabled Jon Wallace Microsoft Windows 2000 Registry 0 8th Oct 2008 02:07 PM
Prevent a window from moving when taskbar gets autohide disabled. =?Utf-8?B?S2VuRGV2?= Microsoft Dot NET Framework Forms 6 23rd May 2007 06:04 PM
Outlook B2TR Delete & Move to Folder option Disabled / Outlook Con =?Utf-8?B?Q2hhbmRyYQ==?= Microsoft Outlook Discussion 3 3rd Oct 2006 04:09 PM
how do I prevent a file from opening if user has disabled macros? =?Utf-8?B?bXdoMTEwNw==?= Microsoft Excel Programming 2 27th May 2005 12:50 AM
Prevent workbook from opening if macros are disabled bondie Microsoft Excel Misc 7 19th Nov 2003 08:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:50 PM.