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

Posted on 2007-07-21
Last Modified: 2012-08-14
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? ???
Question by:vbaproject
    LVL 2

    Expert Comment

    Does the error actually stop your code from executing? Often FirstChanceExceptions won't prevent your code from running.

    Author Comment

    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...
    LVL 2

    Accepted Solution

    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.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now