|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Object ref not set to instance of an object...downloaded this example as a start point... http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnout2k2/html/odc_oladdinvbnet.asp But the onConnect method fails with Object reference to set to an instance...bla bla bla. Here is the code from the method as it exists in my addin (pretty much the same as the example) 'Extensibility.IDTExtensibility2 Event Stubs 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 Dim oApp As Outlook.Application Dim oType As Type Dim GetProgID As Object Dim MyProgID As String Dim oArgs As Object() 'Dim Reg As RegistryKey 'Dim WriteDiagnostics As Integer 'Dim strKey As String Try MsgBox("Mail manager conencted", MsgBoxStyle.Information) 'Use InvokeMember to get ProgID of addInInst object oType = addInInst.GetType GetProgID = oType.InvokeMember("ProgID", _ BindingFlags.Public Or BindingFlags.GetField Or BindingFlags.GetProperty, _ Nothing, _ addInInst, _ oArgs) MyProgID = CType(GetProgID, String) 'Convert application from generic object to Outlook.Application oApp = CType(application, Outlook.Application) 'Don't call InitHandler if Explorers.Count = 0 and Inspectors.Count = 0 If oApp.Explorers.Count = 0 And oApp.Inspectors.Count = 0 Then Exit Sub End If 'Evaluate ConnectMode Select Case connectMode Case ext_ConnectMode.ext_cm_AfterStartup Case ext_ConnectMode.ext_cm_CommandLine Case ext_ConnectMode.ext_cm_External Case ext_ConnectMode.ext_cm_Solution Case ext_ConnectMode.ext_cm_Startup Case ext_ConnectMode.ext_cm_UISetup End Select ' Initialize COMAddin object with this connect object to allow ' external clients to get access to exposed features oApp.COMAddIns.Item(MyProgID.ToString).Object = Me 'Call InitHandler m_BaseClass.InitHandler(oApp, MyProgID) Catch ex As SystemException MsgBox(ex.Message & " : " & ex.Message, MsgBoxStyle.Critical, "Mail Manager") End Try End Sub Russ Green wrote:
Show quoteHide quote > I'm trying to build a simple COM addin for Outlook using VB.NET 2003. I've What line is causing the error?> downloaded this example as a start point... > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnout2k2/html/odc_oladdinvbnet.asp > > But the onConnect method fails with Object reference to set to an > instance...bla bla bla. > > Here is the code from the method as it exists in my addin (pretty much the > same as the example) > > 'Extensibility.IDTExtensibility2 Event Stubs > 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 > Dim oApp As Outlook.Application > Dim oType As Type > Dim GetProgID As Object > Dim MyProgID As String > Dim oArgs As Object() > 'Dim Reg As RegistryKey > 'Dim WriteDiagnostics As Integer > 'Dim strKey As String > Try > MsgBox("Mail manager conencted", MsgBoxStyle.Information) > > 'Use InvokeMember to get ProgID of addInInst object > oType = addInInst.GetType > GetProgID = oType.InvokeMember("ProgID", _ > BindingFlags.Public Or BindingFlags.GetField Or > BindingFlags.GetProperty, _ > Nothing, _ > addInInst, _ > oArgs) > MyProgID = CType(GetProgID, String) > > 'Convert application from generic object to > Outlook.Application > oApp = CType(application, Outlook.Application) > > 'Don't call InitHandler if Explorers.Count = 0 and > Inspectors.Count = 0 > If oApp.Explorers.Count = 0 And oApp.Inspectors.Count = 0 > Then > Exit Sub > End If > > 'Evaluate ConnectMode > Select Case connectMode > Case ext_ConnectMode.ext_cm_AfterStartup > Case ext_ConnectMode.ext_cm_CommandLine > Case ext_ConnectMode.ext_cm_External > Case ext_ConnectMode.ext_cm_Solution > Case ext_ConnectMode.ext_cm_Startup > Case ext_ConnectMode.ext_cm_UISetup > End Select > > ' Initialize COMAddin object with this connect object to > allow > ' external clients to get access to exposed features > oApp.COMAddIns.Item(MyProgID.ToString).Object = Me > > 'Call InitHandler > m_BaseClass.InitHandler(oApp, MyProgID) > Catch ex As SystemException > MsgBox(ex.Message & " : " & ex.Message, > MsgBoxStyle.Critical, "Mail Manager") > End Try > End Sub > > Well I posted the question as I didn't know how to debug a COM addin from
VS.NET but I've since discovered the trick and found and fixed the problem. Thanks for replying though
Is there a difference between passing "" and passing Nothing to a Windows API ?
Moving a project from 2003 to 2005 UI Design question 2003 0r 2005 Time? Several TexBox in a form of an array Using GetOleDbSchemaTable and Visual Basic .NET for MS-Access and SQL Server Express TCP/IP Socket communication from multiple clients Help to Italy Need help with LastIndexOf |
|||||||||||||||||||||||