Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

Vote for DotNetNuke as your choice for winner of this year's PackT Open Source CMS Award
  Need Help?  
Professional technical support for DotNetNuke is available from DotNetNuke Corporation.
 


  Ads  
Engage Software - Training Partner for DotNetNuke
 


  Sponsors  

Meet Our Sponsors

Jango Studios - Skins, Modules and Hosting for DotNetNuke
eUKhost.com is commited to offer exceptional UK Windows Web Hosting solutions with quality 24x7 technical support.Our plans support ASP.Net, ASP, ASP.NET Ajax extensions, XML, MSSQL, MySQL, PHP,DNN, multiple domains and Shared SSL as standard.
SmarterTools
The Official Microsoft ASP.NET Website
Portal Webhosting - Hosting For Developers
Red-Gate Software
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  Is "Try Catch" slow?
Previous Previous
 
Next Next
New Post 6/21/2008 4:53 AM
User is offline cathal connolly
2546 posts
www.cathal.co.uk
5th Ranked










Re: Is "Try Catch" slow? 

i recommend you don't wrap entire pages/functions in try catch blocks, they should be used granularly i.e. wrap them around the individual instruction(s) that may fail. If there is an error in an area that's not wrapped up in a block it will bubble up scope, first to any enclosing block such as sub/function, then to the page, then to the application. If you want a "catch-all" at page level, better to add a delegate to a function or use the page_error event.

Cathal

 
New Post 6/23/2008 2:55 AM
User is offline FreeDotNetNuke
153 posts
freedotnetnuke.com
9th Ranked


Re: Is "Try Catch" slow? 

Cathal

Thank you very much for your recommendation. But:

  1. Everything ok with Try Catch for modules.
  2. Our thread was for httpModule

After detailed search we think that for httpModule enough one Try Catch block (like you said it will be like bubble). Some developers say that good code does not need Try Catch at all, because good code should verify everything what he use. We do not agreed with it, because there is not "ideal code", so will use one "Try...Catch" to protect.

Thanks for all who has helped :)

Sergey


Client always right!
Pages Administration with Drag&Drop for DotNetNuke
List Of All Modules From FreeDotNetNuke
 
New Post 6/23/2008 9:01 AM
User is offline Brandon Haynes
550 posts
everysport.net
8th Ranked


Re: Is "Try Catch" slow? 

Hi Sergey,

Maybe a bit more context would be useful.  Are you actually catching an exception during every httpModule call?  If so, that's not really an exceptional circumstance and you should handle the erroneous occurrence during your normal code flow.  Have you tried benchmarking with a release build?  What were the speed differences?

Here's another bit of advice that will probably cause some controversy: don't catch the base exception class (catch ex as System.Exception).  I wonder if that's not what you're already doing, and possibly obscuring some unanticipated exceptions.

Finally, don't wrap your entire method in one big Try-"Catch Exc as Exception" monster.  I know of one unnamed awesome application that does this all the time, and it drives me crazy!

Brandon


Brandon Haynes
BrandonHaynes.org
 
New Post 6/23/2008 9:09 AM
User is offline Brandon Haynes
550 posts
everysport.net
8th Ranked


Re: Is "Try Catch" slow? 

One more comment before I'm (probably) done -- Nick Guerrera discusses some good exception handling philosophy here in the context of static code analysis.  He deals mostly with exception handling from the framework perspective, and there are (arguably) some presentation-level exceptions, but it's a good primer.  Nick is a smart guy.

Be sure to read the comments, I recall some good ensuing discussion. 

Brandon


Brandon Haynes
BrandonHaynes.org
 
New Post 6/23/2008 10:26 AM
User is offline Charles Nurse
2769 posts
5th Ranked










Re: Is "Try Catch" slow? 

Cathal is correct to a degree in that Try/Catch in itself is not slow.

However, processing an exception is slower than having no exception.  So in summary. from slowest to fastest we have:

  1. Do not handle exception
  2. Handle the exception with Try/Catch
  3. Rewrite your code to avoid exceptions

If you find that you are getting an exception raised consistently then your code should be rewritten to avoid the exception. 

For instance, if you are getting a null reference exception from trying to access a property or method of a null object, then rather than use try/catch you should use -- if (object != null).  This would be much faster.

I realise that this is not always possible.

 


Charles Nurse
DotNetNuke Trustee,
Senior Architect, DotNetNuke Coporation
MVP (ASP.NET) and
ASPInsiders Member
View my profile on LinkedIn
See my Blog for Articles on .NET, DNN and Module Development

View my Blog
 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  Is "Try Catch" slow?
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Viva Portals, L.L.C.
Expert module development and graphic design.
www.continure.com
DNN Photo Gallery
DNN Photo Gallery is a truly unique photo management module released January 1st 2006. With DNN Photo Gallery you can REALLY integrate images into your existing portal and make them look like they were designed for your site.
DNN Photo Gallery
Swirlhost Inc.
Affordable DotNetNuke Hosting, Skin Development, Custom Module Development, and DotNetNuke Consulting. We will install your preference of DNN and now host with us and get a free license for the Swirl AJAX Chatroom Module.
www.swirlhost.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP