'System.ArgumentException' in VB.NET Add - in

I'm trying to write an Add -in for PowerPoint(2003) ib VB.Net
But I get an exception on the stage of "OnConnection" method of Connect class.
My code goes like this :  
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
        MsgBox("On Connection In MyAddin")
        'Instance of COM add-in
        addInInstance = addInInst
        'Check if we entered into PowerPoint
        If TypeOf application Is PowerPoint.Application Then
            PowerPointApp = CType(application, PowerPoint.Application)

        End If

        ' If you aren't in startup, manually call OnStartupComplete.
        If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then _
           Call OnStartupComplete(custom)

    End Sub


After debugging this method i get :
A first chance exception of type 'System.ArgumentException' occurred in PowerPointAddInn.dll

I have no idea why this happends - may be you kow the reason? ???
Who is Participating?
betocarranzaConnect With a Mentor Commented:
It is likely that the following is happening

Somewhere internally to .NET an exception is thrown and handled, however because you have the debugger attached you can see this by way of a FirstChanceException. Running without the debugger you wouldn't even be aware of this. In this instance I would ignore the exception and reevaluate if it appears during system testing.
Does the error actually stop your code from executing? Often FirstChanceExceptions won't prevent your code from running.
vbaprojectAuthor Commented:
You right - the error doesn't stop the code from executing but i'm trying to prevent future problems and thus i'm looking for an answer at the beginning.
I suspect the exception will be significant later on...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.