What's a C# Throw Exception?

How to Throw C# Exceptions Like a Major League Pro: Examples, Best Practices, and Everything You Need to Know

Angela Stringfellow Developer Tips, Tricks & Resources Leave a Comment

Practically everyone who has ever used a web page or an app has encountered an exception at one point or another, but they probably didn’t realize what it was. Exceptions are pretty common ways to handle unexpected inputs but are they always the right way to handle such problems? In this post, we’ll take a closer look at C# exceptions, …

How to Use Web.Config customErrors for ASP.NET

Matt Watson Developer Tips, Tricks & Resources Leave a Comment

The ASP.NET framework provides built-in settings to control how to respond when an application error occurs. This functionality is part of the Web.Config customErrors section. Configuration Options for Web.Config <customErrors> Like most web.config settings, customErrors can be configured within the Machine.config, root web.config or your application web.config file. Usually, it is set per application. CustomErrors supports the following modes: On – …

Get tips for error handling in ASP.Net

Best Practices for Error Handling in ASP.NET MVC

Matt Watson Developer Tips, Tricks & Resources Leave a Comment

Error handling is an important part of any application. ASP.NET provides several different ways to handle errors. In this article, we will review MVC error handling best practices. 5 Ways to do MVC Error Handling Between .NET, ASP.NET, and MVC there are several potential ways to handle application errors. Web.Config customErrors MVC HandleErrorAttribute Controller.OnException method HttpApplication Application_Error event Collect exceptions via …

Get tips to solve null reference exception

What is NullReferenceException? Object reference not set to an instance of an object

Matt Watson Developer Tips, Tricks & Resources Leave a Comment

Null reference errors are responsible for a good percentage of all application bugs. They are usually very simple problems caused by not adding additional logic to ensure that objects have valid values before using them.  Here are some ways to avoid NullReferenceException. The following code will throw a NullReferenceException if the variable “text” being passed in is null. You can’t call …

Understanding # of Exceps Thrown / Sec, and How to Find Exceptions

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

Exceptions can cause big performance problems. One of the most important performance metrics to track about your application is “# of Exceps Thrown / Sec“. It is available via Windows Performance Counters under the category .NET CLR Exceptions. In this article we will talk about exceptions, how to monitor your exception rate and find the actual exceptions being thrown. Is …

What is an Unhandled Exception, and How to Catch All C# Exceptions

Matt Watson Developer Tips, Tricks & Resources Leave a Comment

What is an Unhandled Exception? An exception is a known type of error. An unhandled exception occurs when the application code does not properly handle exceptions. For example, When you try to open a file on disk, it is a common problem for the file to not exist. The .NET Framework will then throw a FileNotFoundException. This is a simple example …

Software Error vs Exception – In Real World Examples

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

After 15+ years of software development, I still use the words error and exception interchangeably. But is there a difference between exceptions and errors? I think it is best to make the distinction with some examples of errors vs exceptions. Example #1: Dishwasher Errors Let’s use this example of a dishwasher. Both images depict a problem, or error, that happened with …

C# Exception Handling Best Practices

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

Welcome to Stackify’s guide to C# exception handling. In this article we cover the following topics: Basics about C# Exceptions, including examples Common .NET Exceptions How to Create Your Own Custom C# Exception Types How to Find Hidden .NET Exceptions C# Exception Logging Best Practices What is an Exception? Exceptions are a type of error that occurs during the execution …

Improve app troubleshooting

3 Ways to Improve Troubleshooting Exceptions

Craig Ferril Insights for Dev Managers Leave a Comment

Your application is perfect, flawless in every way and always works… right? It’s more likely you spend a fair portion of your time troubleshooting problematic behavior in your applications – probably more than you’d care to.  And that’s not because your code is necessarily buggy; it’s because applications have become far more complex than they used to be. Your company …

Error Logging and Application Metrics APIs Now in NuGet

Craig Ferril Insights for Dev Managers Leave a Comment

Giving you visibility and early awareness into everything that is happening with and around your application is our top priority. Sometimes those insights need to come from the code-level rather than external monitoring, and so to that end we are excited to announce our new metrics API and inclusion of all .NET Stackify libraries in NuGet! Using the Stackify Application …