Strange Behavior after installing addin - any ideas?

B

Bob Press

HI - I have just built an addin in VS.Net, using VB shared add-in. It is a
simple command bar button, that when clicked, opens a new email form with
the word 'secure' in the subject line. Works great. BUT....
now if I click on an email link on a web page, instead of OUtlook opening a
new email form, I get the dreaded "The operation failed. An object could not
be found" error. I have googled this error for hours, but cannot find a
resolution. I have reinstalled office, built a new oulook profile, no
difference.

Any ideas?


Thanks

Bob
 
T

Tom Rizzo [MSFT]

Are you trying to customize the toolbars on new mail items? It doesn't
sound like you are. What if you disable your add-in? Does it work then?
If so, there may be issues with unhandled exceptions in your add-in.

Tom
 
B

Bob Press

Thank you for your replies - The addin places a new button on the command
bar, that when clicked, opens a new email message with the word "secure" in
the subject line.

That's it - nothing fancy.

The problem is with normal behavior of outlook.

Now if I click on a "mail to" link on any web page, if outlook is closed, it
tries to open, but is stopped and shows the error message "The operation
failed. An object could not be found."

If outlook is open, it fails to open a new email form, as it normally should
when one click s on a "Mail To" link, and shows the error message "The
operation failed. An object could not be found."


Does the error message "The operation failed. An object could not be found."
mean that a dll is missing?

Uninstalling the addin, and reinstalling office does not help.

Here is the code for the addin.:

Imports Microsoft.Office.Core
Imports Extensibility
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports Outlook = Microsoft.Office.Interop.Outlook




<GuidAttribute("27616BF0-5F8A-4692-987B-E6A98843DE60"),
ProgIdAttribute("SecureEmailButton.Connect")> _
Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim WithEvents btnSecure As CommandBarButton
Dim applicationObject As Object
Dim addInInstance As Object


Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnBeginShutdown



Dim commandBars As CommandBars = applicationObject.ActiveExplorer().
CommandBars
Try

commandBars("Standard").Controls("btnSecure").Delete(System.
Reflection.Missing.Value)
btnSecure.Delete()
btnSecure = Nothing
Catch ex As System.Exception
MsgBox(ex.Message)
End Try


End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete
Dim oCommandBars As CommandBars
Dim oStandardBar As CommandBar
Dim activeExplorer = applicationObject.GetType().
InvokeMember("ActiveExplorer", BindingFlags.GetProperty, Nothing,
applicationObject, Nothing)

On Error Resume Next


oCommandBars = CType(activeExplorer.GetType().
InvokeMember("CommandBars", BindingFlags.GetProperty, Nothing,
activeExplorer, Nothing), CommandBars)

'End If

oStandardBar = oCommandBars.Item("Standard")


' In case the button was not deleted, use the existing one.
btnSecure = oStandardBar.Controls.Item("Secure Email")
If btnSecure Is Nothing Then

'btnSecure = oStandardBar.Controls.Add(, , , 1, True)
btnSecure = oStandardBar.Controls.Add(1)


With btnSecure
.Visible = True
.Caption = "Secure Email"
.Style = MsoButtonStyle.msoButtonIconAndCaption
.FaceId = 225 'lock icon



.Tag = "Secure Email"


.OnAction = "!<SecureEmailButton.Connect>"
End With
End If

' Display a simple message to show which application you started in.

' MsgBox("Started in " & applicationObject.Name & ".")

oStandardBar = Nothing
oCommandBars = Nothing
End Sub

Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.
ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.
IDTExtensibility2.OnDisconnection
On Error Resume Next
If RemoveMode <> Extensibility.ext_DisconnectMode.
ext_dm_HostShutdown Then _
Call OnBeginShutdown(custom)

applicationObject = Nothing
End Sub

Public Sub OnConnection(ByVal application As Object, ByVal connectMode
As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As
System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
applicationObject = application
addInInstance = addInInst

If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup)
Then _
Call OnStartupComplete(custom)
End Sub


Private Sub btnSecure_Click(ByVal Ctrl As Microsoft.Office.Core.
CommandBarButton, ByRef CancelDefault As Boolean) Handles btnSecure.Click
' Create an instance of the MailItem
Dim newMessage As Outlook.MailItem
newMessage = applicationObject.CreateItem(Outlook.OlItemType.
olMailItem)
newMessage.Subject = "[secure]"
newMessage.Display()
newMessage = Nothing
End Sub
End Class

Thanks

Bob
 
S

Sue Mosher [MVP-Outlook]

That particular error message is quite non-specific. If you search the Microsoft Knowledge Base for your version of Outlook, you'll probably find several articles, all detailing different possible causes and cures. It may, in fact, not be related to the add-in directly at all. Your troubleshooting include creating a new mail profile.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Bob Press said:
Thank you for your replies - The addin places a new button on the command
bar, that when clicked, opens a new email message with the word "secure" in
the subject line.

That's it - nothing fancy.

The problem is with normal behavior of outlook.

Now if I click on a "mail to" link on any web page, if outlook is closed, it
tries to open, but is stopped and shows the error message "The operation
failed. An object could not be found."

If outlook is open, it fails to open a new email form, as it normally should
when one click s on a "Mail To" link, and shows the error message "The
operation failed. An object could not be found."


Does the error message "The operation failed. An object could not be found."
mean that a dll is missing?

Uninstalling the addin, and reinstalling office does not help.

Here is the code for the addin.:

Imports Microsoft.Office.Core
Imports Extensibility
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports Outlook = Microsoft.Office.Interop.Outlook




<GuidAttribute("27616BF0-5F8A-4692-987B-E6A98843DE60"),
ProgIdAttribute("SecureEmailButton.Connect")> _
Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim WithEvents btnSecure As CommandBarButton
Dim applicationObject As Object
Dim addInInstance As Object


Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnBeginShutdown



Dim commandBars As CommandBars = applicationObject.ActiveExplorer().
CommandBars
Try

commandBars("Standard").Controls("btnSecure").Delete(System.
Reflection.Missing.Value)
btnSecure.Delete()
btnSecure = Nothing
Catch ex As System.Exception
MsgBox(ex.Message)
End Try


End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete
Dim oCommandBars As CommandBars
Dim oStandardBar As CommandBar
Dim activeExplorer = applicationObject.GetType().
InvokeMember("ActiveExplorer", BindingFlags.GetProperty, Nothing,
applicationObject, Nothing)

On Error Resume Next


oCommandBars = CType(activeExplorer.GetType().
InvokeMember("CommandBars", BindingFlags.GetProperty, Nothing,
activeExplorer, Nothing), CommandBars)

'End If

oStandardBar = oCommandBars.Item("Standard")


' In case the button was not deleted, use the existing one.
btnSecure = oStandardBar.Controls.Item("Secure Email")
If btnSecure Is Nothing Then

'btnSecure = oStandardBar.Controls.Add(, , , 1, True)
btnSecure = oStandardBar.Controls.Add(1)


With btnSecure
.Visible = True
.Caption = "Secure Email"
.Style = MsoButtonStyle.msoButtonIconAndCaption
.FaceId = 225 'lock icon



.Tag = "Secure Email"


.OnAction = "!<SecureEmailButton.Connect>"
End With
End If

' Display a simple message to show which application you started in.

' MsgBox("Started in " & applicationObject.Name & ".")

oStandardBar = Nothing
oCommandBars = Nothing
End Sub

Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.
ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.
IDTExtensibility2.OnDisconnection
On Error Resume Next
If RemoveMode <> Extensibility.ext_DisconnectMode.
ext_dm_HostShutdown Then _
Call OnBeginShutdown(custom)

applicationObject = Nothing
End Sub

Public Sub OnConnection(ByVal application As Object, ByVal connectMode
As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As
System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
applicationObject = application
addInInstance = addInInst

If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup)
Then _
Call OnStartupComplete(custom)
End Sub


Private Sub btnSecure_Click(ByVal Ctrl As Microsoft.Office.Core.
CommandBarButton, ByRef CancelDefault As Boolean) Handles btnSecure.Click
' Create an instance of the MailItem
Dim newMessage As Outlook.MailItem
newMessage = applicationObject.CreateItem(Outlook.OlItemType.
olMailItem)
newMessage.Subject = "[secure]"
newMessage.Display()
newMessage = Nothing
End Sub
End Class

Thanks

Bob
 
B

Bob Press

Thanks, Sue - and yes, I have been through all the possible causes of the
error message in the MS Knowledge BAse. This behavior occurs after the addin
is installed, and I have found this to be the case on several machines.

Guess I'll keep googling.

Thanks

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top