I think this function looks fine, the problem is likely elsewhere in the app.

By on 6/17/2010 6:45 AM ()

Sorry, I probably did not explain to well. My problem is that when I run the form with Application.run(form) the try/with block in the function is ignored and I get exceptions that should have been caught by the try/with block in the function above.

This is the exception that should have been caught by the try/with.
Thanks.

System.Net.WebException was unhandled by user code
Message=The remote server returned an error: (503) Server Unavailable.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenAndPush(Uri uri)
at System.Xml.XmlTextReaderImpl.PushExternalEntityOrSubset(String publicId, String systemId, String baseUriStr, Uri& baseUri, String entityName)
at System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset(String systemId, String publicId)
at System.Xml.XmlTextReaderImpl.DtdParserProxy.System.Xml.IDtdParserAdapter.PushExternalSubset(String systemId, String publicId)
at System.Xml.DtdParser.ParseExternalSubset()
at System.Xml.DtdParser.ParseInDocumentDtd(Boolean saveInternalSubset)
at System.Xml.DtdParser.Parse(Boolean saveInternalSubset)
at System.Xml.DtdParser.System.Xml.IDtdParser.ParseInternalDtd(IDtdParserAdapter adapter, Boolean saveInternalSubset)
at System.Xml.XmlTextReaderImpl.ParseDtd()
at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
at <StartupCode$LicentaRssFeedSearch>.$RssFeeds.clo@51-8.Invoke(String _arg6) in C:\Users\Isabela\documents\visual studio 2010\Projects\LicentaRssFeedSearch\LicentaRssFeedSearch\RssFeeds.fs:line 54
at Microsoft.FSharp.Control.AsyncBuilderImpl.args@720.Invoke(a a)
InnerException:

By on 6/17/2010 7:13 AM ()

The code still looks fine to me; any chance that the stack trace is coming from some older previously-compiled version of the code that does not have the try-with?

Also, are you sure the exception is actually unhandled (e.g. outside the debugger, the app dies), as opposed to this just being an artifact of how the debugger displays the exception?

What happens if you put a breakpoint on the :? WebException line?

Something is strange here; the code looks fine, so I think either the code does not match the running process, or the interpretation of what's happening in the running process is wrong.

By on 6/17/2010 7:26 AM ()

I have thought about that. The thing is that if I just run everything in the F# interactive everything works fine, catches all exceptions, results are as expected.
I just don't understand why those exceptions are unhandled when the function is surrounded by try/with
Thanks

By on 6/17/2010 7:37 AM ()

The line with :? WebException is never reached and the exception is still thrown.
Instead, I've cleaned the solution and then rebuilt it and the app seams to be working fine outside the debugger now. Hope it does not crash when I present it in front of the panel. Thanks

By on 6/17/2010 7:52 AM ()

Are you compiling this code, or running it from fsi?

If the latter, be sure to reset/restart your fsi session, to ensure you don't have some old/previous version of the code captured.

By on 6/17/2010 7:45 AM ()

It's strange and actually annoying to me:

-works when I'm running from the fsi
-works when I build the app and run the .exe file
-throws the unhandled exceptions when I debug it

By on 6/17/2010 7:59 AM ()

Are you sure the exception is unhandled when you debug it? If you press F5/continue debugging after the exception dialog in the debugger, does the app continue and the exception get caught? People often misunderstand what the debugger is telling them.

By on 6/17/2010 8:11 AM ()

I really didn't thought about that. Indeed you are right and if I press continue the app continues execution until the next exception. It seems I only had a problem about understanding the debugger. Thanks

By on 6/17/2010 9:44 AM ()

I have thought about that. The thing is that if I just run everything in the F# interactive everything works fine, catches all exceptions, results are as expected.
I just don't understand why those exceptions are unhandled when the function is surrounded by try/with

By on 6/17/2010 7:36 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper