Reenabling a Soft Disabled Addin

1. Create an Outlook add-in project with VSTO.

2. In the Startup event handler of ThisApplication, add the code in Listing 10.14.

Listing 10.14. Creating an error at startup

Private Sub ThisApplication_Startup(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.Startup

Dim first As Integer = 12 Dim second As Integer = 0

Dim DivideByZero As Integer = first / second MsgBox(DivideByZero)

End Sub

3. Press F5 to run the code. The message box does not display; the code throws a divide-by-zero exception, and, because it is not handled, the add-in is soft-disabled.

4. On the Tools menu In Outlook, click Options.

5. Select the Other tab in the Options dialog box, and then click Advanced Options.

6 In the Advanced Options dialog box, click COM Add-ins. The COM Add-ins dialog box will appear, as shown in Figure 10.15.

Figure 10.15. Soft-Disabled add-ins

Because the divide-by-zero error is hard-coded, you need to fix the error before reenabling the add-in. Otherwise, you could simply select the check box next to the disabled add-in to reenable it. If you just reenable it in this case, the code will attempt to run again, and the add-in will be disabled again. You can change the variable "second" to equal 4 and rerun the code. This time, a message box displays the value of the DivideByZero variable (which now divides by 4).

0 0

Post a comment