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  |  

AppTheory specializes in solutions based on the DotNetNuke platform and has 2 employees on the DotNetNuke Core Team.
  Need Help?  
Professional technical support for DotNetNuke is available from DotNetNuke Corporation.
 


  Ads  
Biz Modules provides professional business modules and solutions for DotNetNuke
 


  Sponsors  

Meet Our Sponsors

OnyakTech
The best choice for your web site host, email hosting, and domain registration.
CrystalTech Web Hosting™
Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
AspDotNetStoreFront - E-Commerce by Design - The Leading ASP.NET shopping cart platform for developers!
 


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
2638 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
156 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
Online now... Brandon Haynes
641 posts
everysport.net
7th 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
Online now... Brandon Haynes
641 posts
everysport.net
7th 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
2839 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.

 


DNNCovered.com - Your Offshore Dotnetnuke Partner
Dnncovered.com is the only Dotnetnuke offshore outsourcing center specializes in DNN skinning and module development with lowest pricing and quality service. Our staff is dedicated to websites based on DNN and our graphic designers are creative and imaginative well enough to provide customers the complete set of skinning solutions and packages
www.dnncovered.com
PointClick.Net DNN Solutions
DotNetNuke Hosting Platform for Business and personal use.
PointClick.Net Hosted Solutions
Advanced Web Portals by Infoscaler
Infoscaler is a California based company that provides advanced Web Portals, E-commerce Sites, Database Applications and Intranet Solutions on the DotNetNuke and Microsoft.NET platforms.
www.infoscaler.com

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