Results 1 to 3 of 3

Thread: exception not caught by try block?

  1. #1
    Steve Faust is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    May 2011
    Location
    Littleton, Colorado, United States
    Posts
    5
    Reputation
    0

    Question exception not caught by try block?

    I have a program that connects to and downloads some files (images & xml) off of a web server. Most of the time it works great, but for some reason I have some users reporting an unhandled exception with the stack trace:

    The remote name could not be resolved: 'links.keynotemanager.revolutiondesign.biz'
    at System.Net.HttpWebRequest.GetResponse()
    at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
    at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
    at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
    at RDES.KeynoteManager.BannerHandler.FindBannersFromL ocation(String BasePath)
    at RDES.KeynoteManager.BannerHandler.Initialize(Strin g BannerPath)
    at RDES.KeynoteManager.Frm_Main.LoadBanners(String BannerPath)
    at RDES.KeynoteManager.Frm_Main.Frm_Main_Load(Object sender, EventArgs e)
    at System.EventHandler.Invoke(Object sender, EventArgs e)
    at System.Windows.Forms.Form.OnLoad(EventArgs e)
    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
    at System.Windows.Forms.Control.CreateControl()
    at System.Windows.Forms.Control.WmShowWindow(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.Form.WmShowWindow(Message& m)
    at System.Windows.Forms.Form.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    Since it's intermittent and pretty rare I think it may just be due to server down time or some intermittent connection errors so I'm not terribly worried about that. The really strange thing, though, is that this entire method (FindBannersFromLocation) is enclosed in a try catch block and I have it set up (or thought I did) to handle the error properly in the catch block, but it doesn't seem to be catching it, it's just giving an unhandled exception.

    Anyone have any insight as to why it would not be catching this?

    FYI here is the relevant section of the code within the try block:
    Code:
             
    Dim resolver AsNewXmlUrlResolver
    
                
    IfMy.Settings.ProxyDomain = ""Then
    
                    
    'First attempt, use default credentials
    
                    resolver.Credentials = 
    CredentialCache.DefaultCredentials
    
                
    Else
    
                    
    Dim pd AsNewProxyData(My.Settings.ProxyDomain, My.Settings.ProxyUN, My.Settings.ProxyPW)
    
    
                    resolver.Credentials = 
    NewNetworkCredential(pd.UserName, pd.Password, pd.Domain)
    
                
    EndIf
    
                
    Dim settings AsNewXmlReaderSettings
    
                settings.XmlResolver = resolver
    
    
                
    Dim reader AsXmlReader = XmlReader.Create(IndxPath, settings)
    
    
                
    Dim xDoc AsNewXmlDocument
    
    
                xDoc.Load(reader)
    

  2. #2
    ss7thirty is offline VB.NET Forum Miyagee
    .NET Framework
    .NET 2.0
    Join Date
    Jun 2005
    Location
    New Jersey, US
    Posts
    455
    Reputation
    174
    Does your catch block look like this ?

    Code:
    Catch Ex as Exception

  3. #3
    Steve Faust is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    May 2011
    Location
    Littleton, Colorado, United States
    Posts
    5
    Reputation
    0
    yep,

    Code:
    Try
         'code above
    Catch ex as Exception
         'Do stuff with ex
    End Try

Bookmarks

Posting Permissions

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