Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    London
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    file not found exception

    OK - this is more of a general .net question than specifically ASP.NET...

    Am trying to build a little app that adds items to Outlook if it's installed... which works fine if it is...

    For the purposes of demonstrating my problem I've created a 1 button form which does a test on clicking the button.

    Am trying to extablish whether Outlook is installed, by using the following Try, Catch
    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            testOutlook()
        End Sub
    
    
    
        Private Sub testOutlook()
            Dim objApp As Outlook.Application
    
            Try
                objApp = New Outlook.Application()
                Me.Button1.Text = "Outlook found"
    
            Catch e As System.IO.FileNotFoundException
                Me.Button1.Text = "Outlook not found"
    
            Finally
                objApp = Nothing
    
            End Try
    
        End Sub
    Problem is that the Try, Catch block is not catching the exception when run on a machine that doesn't have Outlook installed so I end up with an error dialog, not a message box with a cleaner error message.

    Anyone got any ideas?

    dominicall
    dominicall - confusing himself more and more each day

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What does the error message say?
    does this sig match?

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    London
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's the error message - in full...
    Code:
    See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.
    
    ************** Exception Text **************
    System.IO.FileNotFoundException: File or assembly name Interop.Outlook, or one of its dependencies, was not found.
    File name: "Interop.Outlook"
       at testOutlook.Form1.testOutlook()
       at testOutlook.Form1.Button1_Click(Object sender, EventArgs e)
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    Fusion log follows: 
    === Pre-bind state information ===
    LOG: DisplayName = Interop.Outlook, Version=9.1.0.0, Culture=neutral, PublicKeyToken=null
     (Fully-specified)
    LOG: Appbase = D:\
    LOG: Initial PrivatePath = NULL
    Calling assembly : testOutlook, Version=1.0.1381.24261, Culture=neutral, PublicKeyToken=null.
    ===
    
    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
    LOG: Post-policy reference: Interop.Outlook, Version=9.1.0.0, Culture=neutral, PublicKeyToken=null
    LOG: Attempting download of new URL file:///D:/Interop.Outlook.DLL.
    LOG: Attempting download of new URL file:///D:/Interop.Outlook/Interop.Outlook.DLL.
    LOG: Attempting download of new URL file:///D:/Interop.Outlook.EXE.
    LOG: Attempting download of new URL file:///D:/Interop.Outlook/Interop.Outlook.EXE.
    
    
    
    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 1.0.3300.0
        Win32 Version: 1.0.3705.288
        CodeBase: file:///c:/winnt/microsoft.net/framework/v1.0.3705/mscorlib.dll
    ----------------------------------------
    testOutlook
        Assembly Version: 1.0.1381.24261
        Win32 Version: 1.0.1381.24261
        CodeBase: file:///D:/testOutlook.exe
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 1.0.3300.0
        Win32 Version: 1.0.3705.288
        CodeBase: file:///c:/winnt/assembly/gac/system.windows.forms/1.0.3300.0__b77a5c561934e089/system.windows.forms.dll
    ----------------------------------------
    System
        Assembly Version: 1.0.3300.0
        Win32 Version: 1.0.3705.288
        CodeBase: file:///c:/winnt/assembly/gac/system/1.0.3300.0__b77a5c561934e089/system.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 1.0.3300.0
        Win32 Version: 1.0.3705.288
        CodeBase: file:///c:/winnt/assembly/gac/system.drawing/1.0.3300.0__b03f5f7f11d50a3a/system.drawing.dll
    ----------------------------------------
    System.Xml
        Assembly Version: 1.0.3300.0
        Win32 Version: 1.0.3705.288
        CodeBase: file:///c:/winnt/assembly/gac/system.xml/1.0.3300.0__b77a5c561934e089/system.xml.dll
    ----------------------------------------
    Microsoft.VisualBasic
        Assembly Version: 7.0.3300.0
        Win32 Version: 7.00.9502
        CodeBase: file:///c:/winnt/assembly/gac/microsoft.visualbasic/7.0.3300.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll
    ----------------------------------------
    
    ************** JIT Debugging **************
    To enable just in time (JIT) debugging, the config file for this
    application or machine (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.
    
    For example:
    
    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>
    
    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the machine
    rather than being handled by this dialog.
    Ignore the bits about JIT debugging - am having to test on a remote machine that doesn't have outlook on...

    To use outlook from the Windows form you have to add a reference to Outlook. I'd assumed that you could use a Try/Catch block and other sites on the web that I've looked at since trying this have said pretty much the same so am somewhat confused as to why it's throwing this error when I'm using the Try/Catch block with a specific expception in the Catch???

    dominicall
    dominicall - confusing himself more and more each day


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •