I
Istvan
Hi,
I'm trying to migrate my COM add-in from Outlook 2003 to 2007 (both on
Windows XP), using VS 2005 Professional and VSTO 2005 SE.
The add-in was originally developed on a machine with Outlook 2003
installed, using the built in Office 2003 - Outlook Add-In template in
VS2005/VSTO.
For the migration, I recreated the entire solution on a machine with Outlook
2007, VS2005 and VSTO, using the built in Office 2007 - Outlook Add-In
template in VS2005/VSTO.
I located the program line that is causing the problem and created this very
simple test program:
-------->>>
Public Class OutlookAddIn1
Private Sub ThisAddIn_Startup( _
ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Startup
Application.COMAddIns.Item("OutlookAddIn1").Object = Me
End Sub
Private Sub ThisAddIn_Shutdown( _
ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Shutdown
End Sub
End Class
--------<<<
The line
Application.COMAddIns.Item("OutlookAddIn1").Object = Me
is based on the KB 240768 article.
When I run the Add-In, I get the following exception:
-------->>>
Specified cast is not valid.
************** Exception Text **************
System.InvalidCastException: Specified cast is not valid.
at Microsoft.Office.Core.COMAddIn.set_Object(Object RetValue)
at OutlookAddIn1.OutlookAddIn1.ThisAddIn_Startup(Object sender, EventArgs
e) in
C:\__temp\Outlook_test\OutlookAddIn1\OutlookAddIn1\OutlookAddIn1.vb:line 8
at Microsoft.Office.Tools.AddIn.OnStartup()
at OutlookAddIn1.OutlookAddIn1.FinishInitialization() in
C:\__temp\Outlook_test\OutlookAddIn1\OutlookAddIn1\OutlookAddIn1.Designer.vb:line 67
at
Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecutePhase(String methodName)
at
Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecuteEntryPointsHelper()
at
Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.Microsoft.VisualStudio.Tools.Applications.Runtime.IExecuteCustomization2.ExecuteEntryPoints()
************** Loaded Assemblies **************
--------<<<
I couldn't find any information whether I'm missing something, doing
something wrong, this is not the way to implement a callback in Outlook 2007
add-ins, or whether it is a bug?
Any thoughts will be appreciated.
Thanks,
Istvan
I'm trying to migrate my COM add-in from Outlook 2003 to 2007 (both on
Windows XP), using VS 2005 Professional and VSTO 2005 SE.
The add-in was originally developed on a machine with Outlook 2003
installed, using the built in Office 2003 - Outlook Add-In template in
VS2005/VSTO.
For the migration, I recreated the entire solution on a machine with Outlook
2007, VS2005 and VSTO, using the built in Office 2007 - Outlook Add-In
template in VS2005/VSTO.
I located the program line that is causing the problem and created this very
simple test program:
-------->>>
Public Class OutlookAddIn1
Private Sub ThisAddIn_Startup( _
ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Startup
Application.COMAddIns.Item("OutlookAddIn1").Object = Me
End Sub
Private Sub ThisAddIn_Shutdown( _
ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Shutdown
End Sub
End Class
--------<<<
The line
Application.COMAddIns.Item("OutlookAddIn1").Object = Me
is based on the KB 240768 article.
When I run the Add-In, I get the following exception:
-------->>>
Specified cast is not valid.
************** Exception Text **************
System.InvalidCastException: Specified cast is not valid.
at Microsoft.Office.Core.COMAddIn.set_Object(Object RetValue)
at OutlookAddIn1.OutlookAddIn1.ThisAddIn_Startup(Object sender, EventArgs
e) in
C:\__temp\Outlook_test\OutlookAddIn1\OutlookAddIn1\OutlookAddIn1.vb:line 8
at Microsoft.Office.Tools.AddIn.OnStartup()
at OutlookAddIn1.OutlookAddIn1.FinishInitialization() in
C:\__temp\Outlook_test\OutlookAddIn1\OutlookAddIn1\OutlookAddIn1.Designer.vb:line 67
at
Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecutePhase(String methodName)
at
Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecuteEntryPointsHelper()
at
Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.Microsoft.VisualStudio.Tools.Applications.Runtime.IExecuteCustomization2.ExecuteEntryPoints()
************** Loaded Assemblies **************
--------<<<
I couldn't find any information whether I'm missing something, doing
something wrong, this is not the way to implement a callback in Outlook 2007
add-ins, or whether it is a bug?
Any thoughts will be appreciated.
Thanks,
Istvan