Click here to Skip to main content
15,891,607 members
Everything / General Programming / Exceptions

Exceptions

exceptions

Great Reads

by Giovanni Scerra
Patterns to prevent null reference exceptions
by Jasper Lammers
A method to easily toggle the way exceptions are being handled (either being thrown or handled by custom code), while still conserving the stack trace when exceptions are not being thrown.
by Marco Bertschi
This tip presents an easy way of verbosely converting an exception and its inner exceptions to a string in order to get access to all details.
by Amogh Natu
This tip provides one solution to the exception "Configuration system failed to initialize" in C#

Latest Articles

by Dev Leader
Secret of Task EventHandlers
by Bruno van Dooren
Symantec can cause valid applications to crash and be gone without a trace
by Mark Pelf
We explain how to debug and get more information on the generic Exception “Failed to enable constraints.
by Greg Utas
Keeping a program running when it would otherwise abort

All Articles

Sort by Updated

Exceptions 

27 Sep 2010 by #realJSOP
Your future is still in question. They're trying to find out how much *you* know - NOT how much we know. If you can't handle this simple task, maybe you should consider another line of work.
8 Feb 2011 by #realJSOP
Does your DLL call ConfigurationManager.OpenEXEConfiguration()? If so, try putting a try/catch block around it and just eat the exception.
9 Feb 2011 by #realJSOP
Try removing the web service reference from your app, and then re-adding it.
19 Mar 2011 by #realJSOP
Google found 142,000 references to this exception:http://www.google.com/search?q=linq+row+not+found+or+changed+exception&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a[^]
25 Mar 2011 by #realJSOP
try{ string[] files = Directory.GetFiles("C:\MyDir", "*.*", SearchOption.AllDirectories); // do something with your file array}catch (UnauthorizedAccessException){ // this eats the exception but it will still stop}catch (Exception ex){ // you can handle all...
28 Mar 2011 by #realJSOP
Do this:public delegate void TestEventHandler(); public static event TestEventHandler OnTestEvent = delegate{}; At that point, you an just call OnTestEvent() ewithout the if block.By the way, you really should have - at the VERY least) the following parameters (even if you...
1 Sep 2011 by #realJSOP
Just out of curiosity, have you tried moving to .Net 4 and see if the behavior persists (just as a test)?
5 Dec 2016 by #realJSOP
Put a try/catch block around the call to that method, and in the catch section, display the exceptions message property to the user.
31 Jan 2017 by #realJSOP
Set the project's target to x86.
1 Dec 2018 by #realJSOP
I know - it's unfortunate that you have to actually write some code, but that's how it goes. Put a try/catch block around the code that's attempting to insert the new user, and in the catch part, show a message box that shows "User name already exists.", and let that be that. At the same time.
21 Oct 2011 by 0bx
Been wasting a lot of time on this. I think it 'should' work, but I can't find what's wrong with it.protected int Checkscore(Node x) { string[] numbers = x.GetProperty("answers").Value.Split(';'); int score = 0; foreach (string n in numbers) ...
2 Jan 2022 by 0x01AA
How is about to check wheter val bmp = BitmapFactory.decodeResource(context.getResources(), resourceId, opts) returns a 'not null' value? And in case it returns null you need to investigate why...
5 May 2010 by 4277480
try { aboutDlg.ShowDialog(this); } catch { }This will make the error not appear however this is not recommended as the whole purpose of try and catch is to identify rising...
6 Sep 2018 by @k5hu
I am new to Struts. I have installed all the struts2 plugins in Netbeans 8.1. The server that I'm using is Glassfish 4.1.1. When I run the following code I get: HTTP Status 500 - Internal Server Error type Exception report messageInternal Server Error descriptionThe server encountered an...
18 Mar 2011 by AB7771
Hi all,I have been trying to read an Excel file using Oledb, but it throws the following exception when I try to open the connection:"'objConn.ServerVersion' threw an exception of type 'System.InvalidOperationException'"Any pointers on this will be appreciated.
22 Aug 2014 by abacrotto
I have a strange behaviour in the binding of some controls in my solution. The control is a TextBox control that handles numeric behaviours. I am working with a decimal textbox for instance. When I do bind the control to the Decimal property (sometimes to the .Text property too) the .NET...
17 Aug 2012 by Abey Thomas
This is an issue which can happen for a variety of reasons - but how do you find the right one?
13 Aug 2018 by Abhijeet P Singh
hello everyone.. I created a WPF app using c# in which I have context menu with images.. I am using custom action to launch my application after installation.. As App launches first time it gives me exception System.IO.FileNotFoundException but when it is launched manually by double clicking...
21 Jul 2010 by Abhinav S
Check if any of the values in the cells are null.If they are you need to modify your code to check for null conditions before using ToString().
8 Nov 2010 by Abhinav S
String EMail=request.getParameter("E-Maild ID");You are getting the wrong E-mail Id (there is an extra d in your name). Thus this email id is probably null.
6 Jan 2011 by Abhinav S
See here[^] for more information on this exception.
6 Jul 2011 by Abhinav S
You can always look at the stacktrace via code. For more information, see here[^].
20 Aug 2011 by Abhinav S
Try posting this in the article you are referring to.The author will be able to answer this quicker that way.Incidentally, you have not put a link to the article here, so no one knows which article you are talking about.
10 Jan 2012 by Abhinav S
Try to debug your code and see where the error occurs. This will help you narrow down the problem.
13 Jan 2013 by Abhinav S
This error may actually have nothing to do with the size of the excel. One of the rows after row 20000 may have some data that may be of a different type. It will be worth doing a quick data validation of the Excel file.
7 Jun 2014 by Abhinav S
Convert.ToInt does not check if an input is really an integer or not.To check type, use a Int.TryParse.To be cautious about cultures, go through Check If A String Value Is Numeric[^].
11 Feb 2015 by Abhinav S
Code formatting is not correct. Just check the closing braces.
5 Jan 2016 by Abhinav S
Try How to properly release Excel COM objects: C# code examples[^].
9 Apr 2014 by Abinash_Sahoo
You can use Server.ScriptTimeout to set request timeout value (you may set it just before performing the DB operation) and try if it solves your issue. Like:Server.ScriptTimeout = 3600; //set request timeout to 60 min
6 Feb 2014 by Adamanteus
Intercepting SEH exceptions in C++ program
24 Jun 2010 by Adrabi Abderrahim
in easy words!if .Net get you 1Mbyte (Just Example) of memory to store data and you want to store 1.1Mbyte this throw StackOverflowException like if you use array and you get IndexOutOfRangeException, easy?what's or where's problem?you've get us just your "BackTrack" method and on-one...
20 Jun 2012 by Aero72
Dear all,I'm pretty sure I know what the problem is....could I please ask for your time and consideration as to the optimum course of actionI have an application which gets data from a USB source and stores that data in a list. For convenience during development, I made it a public...
18 Apr 2011 by Aerryc
Using Rama Krishna Vavilala's article as a reference, I have been working on developing a data repository model for use at my orgnaization and, with one exception, it works as expected. I have included a simple version of the model that illustrates the issue.The question: Why do references...
21 Mar 2015 by Afzaal Ahmad Zeeshan
You should try wrapping the name between [] and then trying it again. Such as, [ApplicationName] and then try. If doesn't work, please change the column's name inside your database table and try something else.
26 Aug 2015 by Afzaal Ahmad Zeeshan
Short answer: Your application does not have permission to read or access a location for the code. The program is thus inaccessible, causing this exception. This exception comes from Windows Runtime, so behind the scenes of .NET framework (which usually backs up ASP.NET) there are components of...
26 Aug 2015 by Afzaal Ahmad Zeeshan
Indeed that is the problem, the problem in real is not with your database file itself but with the connection. The SQL Server itself was not found, perhaps: 1. SQL Server version-mismatch 2. SQL Server existence3. Access permissions would be a cause to this. In my opinion, option 2...
7 Jun 2013 by Ahmed Bensaid
Hello,I think you'll need to raise the exception yourself like this :if ((double.IsInfinity(result)) || (double.NaN(result))) { throw new ArithmeticException();}
10 Jan 2011 by Ajay Vijayvargiya
25 Jun 2013 by Akmal Abbas Naqvi
This is my Code , i publish my Windows Application Form with ClickOnce , There is a button in form it is supposed to start an installation of the Screen Share software when it is clicked.Here is my Publish Folder Path : \\192.168.0.1\PUBLiC\Akmal\ProcessEndLastFTP\Here is my Installation...
23 Jan 2012 by akul123
I want to add 1000 images (each size is (40 to 100) KB) in a panel at run time in a desktop application. At first user browses all the images and load them on a panel. When it loads images one after another then memory usage shown in the task manager increases rapidly and after a certain number...
9 Feb 2011 by Al-Farooque Shubho
An effort to derive a basic Exception Management design guideline for N-Tier ASP.NET applications
28 Mar 2011 by Alan N
You seem to imply that you have implemented a handler forSystem.AppDomain.CurrentDomain.UnhandledException which will trap unhandled exceptions occurring on non UI threads.Use System.Windows.Forms.Application.ThreadException to trap UI thread exceptions.Alan.
3 Oct 2012 by Alan N
If the Start method returns false then there is no process available. The only time I have observed this is when UseShellExecute was true and StartInfo.FileName was a shortcut, i.e. something.lnk.I wonder if this is your situation as I see that you assign a variable called 'link' to...
13 Oct 2012 by Alan N
I was looking into this yesterday when I had a similar problem. If you open the published source code Timer.cs[^] and scroll down to the MyTimerCallback method you'll see that the event invocation has an empty catch block.Although I had never noticed it before, the behaviour is documented...
15 Apr 2011 by Albin Abel
In a repository frameworks (which is usually for larger projects which need agile testing) usually the repository, business model, services and presentation all will be treated as separate projects. In domain driven design the business model is the core and independent and other layers above it...
3 Nov 2012 by Ali_100
Hi friends i am getting outofmemoryexception, Here is my code which is in italic i have to optimized these nested loops to avoid the exception.I am telling the background here ,I have a condition in which i have Dataset A,Dataset B and Dataset C.Dataset A is parent & the remaing are childs,I...
23 Apr 2013 by Ali_100
I am getting the exception , i cant able to understand that,,I copied it from Event viewer.Log Name: ApplicationSource: ASP.NET 4.0.30319.0Date: 4/23/2013 5:17:51 PMEvent ID: 1309Task Category: Web EventLevel: WarningKeywords: ClassicUser:...
24 Apr 2013 by Ali_100
I solved it by the help of this linkhttp://www.devexpress.com/Support/Center/Question/Details/Q343381[^]
11 Apr 2017 by aliwpf
Hi there . i write following code : catch (SocketException se) { if (se.SocketErrorCode == SocketError.TimedOut) { //my logic } } catch (WebException we) { } and...
18 Apr 2011 by All Time Programming
Hi, In my C# application, I got to call web service via https and perform peer verification using a ".crt" file. If I add request.ClientCertificates.Add(x5092Obj); then I get exception :WEB Excep : The underlying connection was closed: Could not establish trust relationship for the...
8 Jun 2011 by All Time Programming
Friends, I have solved the problem. Looking at no responses here, thought to share the procedure with all of you over here. You can get to know how to work out with Web Services via HTTPS taking care of SSL Peer Verification at : SSL Peer Verification[^]Hope it helps.
6 Aug 2018 by amagitech
If you think you will use custom exceptions in another project you should seperate them to another project. If you use them just for your one project it doesn't matter. It depends your coding style.
27 Jul 2012 by amineel9
hi everyone, i'm trying to retrieve my contacts , using ContentResolver.query(..)the problem is, i have like 5000 contacts, and when running, it runs out of memory, it's working fine though with something like 1000 contacts, what should i do here is the code for the cursorfinal...
1 Mar 2014 by Amogh Natu
This tip provides one solution to the exception "Configuration system failed to initialize" in C#
12 Jan 2013 by Andreas Gieriet
Exception c0000005 seems to be an Access Violation[^] exception.This likely to be caused by buffer overrun.Especially look for scanf reading beyond your max buffer length[^].Read the data with a width [^] to avoid buffer overflow while reading.Finally, the allocation of the dict0 and...
6 Aug 2012 by AndroidVivek
Go to setting manage application and click on one by one application and transfer it into the card memory...Don't forget to make sd card...
21 Oct 2011 by André Kraak
The solution given by Mehdi Gholam works, but this alternative also solves your problem.protected int Checkscore(Node x) { char[] delimiter = {';'}; string[] numbers = x.GetProperty("answers").Value.Split(delimiter, StringSplitOptions.RemoveEmptyEntries); ...
13 Mar 2014 by Andy Neillans
Exceptionless.com goes opensource; so how do you host it yourself?
22 Sep 2020 by angusmax
I have a long sequence of calculations (using variables of type "double") where some operations might result (depending on input values) in "NaN" or "Infinity".Since I don't want to add something like the following:if ((double.IsInfinity(result)) || (double.NaN(result))) {...}after...
23 Jun 2015 by Annihilated
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO namespace JUSTFORPRACTICE { public class a { public static void Main() { try...
7 Dec 2011 by Anoop_Ravindran
Hi all,I have a .net 4.0 windows application which is migrated from .net 3.5. This windows application is using a third party DLL file (from Windows\system32\MyScanner.dll) which is used to connect with a scanner attached to the system through USB port. This application is working...
9 Feb 2011 by antti.arrak
My console program loads a dll to different appdomain.That dll communicates with webservice but it gives a exception :On GetWebRequest()"exePath must be specified when not running inside stand alone exe.at System.ConfigurationManager.OpenExeConfigurationInternal(.....)".As far as I...
23 Aug 2011 by Armando de la Torre
How to load an image from the filesystem and save it into a Database
27 Jan 2023 by Arnaav PL
Design a class ReserveTicket with an instance variable seatsavailable, and a method void reserve ( int numberofseats). If `numberofseats' is greater than `seatsavailable' then throw a user defined exception SeatFullException otherwise throw a...
5 May 2015 by arora.abhishek
In this tip, you will learn the new feature of C# 6.0, Exception Filtering.
16 Mar 2017 by Arthur Minduca
How to handle faults in WCF without declaring them explicitly
17 Jul 2014 by ArunRajendra
This is not a browser problem but the data. The data contains some non numeric values. You need to validate before processing.
12 Apr 2010 by asdf999
Hi,I have a C#.NET WebApplication which implements MVC Architecture.I need to implement Exception Handling to my application.I have included Try Catch Blocks and few Exception Messages , but I dont think that is sufficient .Can anyone suggest best way to implement exception...
11 Oct 2013 by ASP.NET Community
This article presents a way to log and mail the errors from any web page.It logs following details -Control on which the error is raisedPage
11 Oct 2013 by ASP.NET Community
Introduction There had been much discussion on how to make your application compatible with the IIS7 Integrated mode. To know how to make your
11 Oct 2013 by ASP.NET Community
WCF provides us a facility to specify the fault behavior of our service. It provides a FaultException Class. Whenever our service implementation
11 Oct 2013 by ASP.NET Community
Using Response.Redirect and Response.End in Try...Catch blockIn ASP.NET if you are using Response.End - Used for terminating page execution or
11 Oct 2013 by ASP.NET Community
ASP.net provides facilities in web.config for specifying error pages when an exception occurs, for example:           
11 Oct 2013 by ASP.NET Community
Global.asax, is the global file in the web application, which offers application level events to be registered. There are many of the events in this
31 Jan 2011 by AspDotNetDev
Perhaps you need to remove the control from its old parent first? Something like:m_ctrlContainer.Parent.Controls.Remove(m_ctrlContainer);this.Controls.Add(m_ctrlContainer);
9 Jul 2013 by AsthaS
Hi all..I am writing a code in c++. All I want to do is catch all the exception that can possibly occur in the code. I am using try-catch block for that. My problem is the code does not reach the catch block until and unless I give an explicit throw in the try block. For doing this I have...
15 Apr 2015 by Aswin_kumar
Hello,I am trying to connect to the Database from the application and its not happening at all. The same DLL is working fine in QA and production.When debugging I understood the SQL connection is always closed.when I checked the below line of code,public static SqlConnection...
18 Mar 2010 by Avi Berger
sksksksksksksk...
11 Nov 2018 by Aydin Homay
Hi I am more suspicious to the below line: ComboboxState.SelectedValue.ToString() Could you please do a favor and re-write your code in this way: var userId = currentUser.UserID; var firstName = TextboxFirstName.Text; var lastName = TextboxLastName.Text; var address = TextboxAddress.Text;...
13 Nov 2018 by Aydin Homay
Hi, The information that you provided is not enough and to complicated. You are referring to several problems. Let`s make progress step-by-step. Follow my solution and leave comments I will read and change/improve the solution according to your progress until we get it solve. Ok? So first,...
12 Mar 2014 by B. Clay Shannon
In the code below:catch (Exception ex){ MessageBox.Show(string.Format("Msg = {0}; StackTrace = {1)", ex.Message, ex.StackTrace)); request.Abort(); return null;}..."ex.StackTrace" is grayed out. Why?
25 Nov 2013 by Balachandar Jeganathan
Exception handling using custom attributes and stacktrace.
17 Oct 2013 by basurajkumbhar
"select Recordno, uhnumber,uhbuilding,uhlocation from hydrantmaintain WHERE CONVERT(DATE,unndate)= '" & Today.Day & "'"You can try this .I Hope this will help you.
25 Apr 2013 by Bernhard Hiller
Use your own Exceptions. Create appropriate exception classes inheriting from System.Exception or System.ApplicationException or other, and add your ErrorCode property. Thrown the exception when appropriate in the Business Layer. In the Presentation Layer, you need some try...catch blocks, and...
13 Jun 2013 by Bernhard Hiller
I guess C:\Temp is an existing folder, and hopefully you set the access rights correctly - hence C:\Temp is not an acceptable name for a file. I see that your function uses CreatePackage(filePath As String while the you call WordprocessingDocument.Create(_filename. Did you mix up the...
27 Oct 2014 by Bernhard Hiller
You could wrap the call in a try-catch block. But I do not recommend to swallow (i.e. ignore) the execption - better get the COM exception code, and its meaning with Word Interop, to eventually get rid of the reason of failure.
12 Jul 2016 by Bernhard Hiller
Microsoft office programs are not safe for use in Windows services / IIS. You should use the Microsoft.Office.Interop library only when you have a program with a GUI running in a user session. Try to find a library which can work with the MS Project files without calling MS...
12 Jul 2013 by BHEEM SEN YADAV
I have a PictureBox on my Form in windows appliation and i am setting imagelocation property of PictureBox then i am facing this issuepictureBox1.ImageLocation = @"c:\2.jpg";my image is more than 7 mb and the i am facing issue " out of memory exception"
14 Apr 2014 by bijaynayak
Additional information: Cannot create instance of 'Window1' defined in assembly 'ViewVideo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Window1.xaml' Line 1 Position 9.
12 Mar 2014 by BillWoodruff
The problem here is an infestation by a demon. That demon caused you to forget to put a matching close-curly-brace on the second place-holder in your formatted string:MessageBox.Show(string.Format("Msg = {0}; StackTrace = {1})", ex.Message, ex.StackTrace));
5 Dec 2016 by bjay tiamsic
Hi, I have the code below but is it possible to return the exception message from C# class file to aspx.cs so I can return it to use with a customized message box? (ie. customized message box would be a modal in bootstrap)What I have tried:Here is how I call the method in class...
9 Aug 2011 by BlackJack99
Hi, I am trying to write data into SQL server using WCF service in Silverlight, but when i tried to do it, i get this exception:System.ServiceModel.CommunicationException was unhandled by user code Message=The remote server returned an error: NotFound. StackTrace: at...
9 Aug 2011 by BlackJack99
Finally got it to work! followed the solution here: http://forums.silverlight.net/t/40770.aspx[^]seems like i only need to increase the size limit...
21 Jun 2011 by BobJanova
Log the exception when it occurs. The standard ToString of an exception includes the exception type.
2 Dec 2013 by Borja Prado
WinRT Apps exception logging with WinrtErrLog and Google Spreadsheets.
9 Jan 2014 by bowlturner
throw new Exception(v.ToString()); if it's C#
22 Apr 2013 by Brady Kelly
A handy way to raise an exception without having to call String.Format for the exception message
27 May 2011 by Brian Risley
I think the documentation on TransactionAbortedException is a little lacking as to when it can happen.It DOES NOT happen if you do not do a Scope.Complete on your initial transaction. In other words, failure to execute Scope.Complete means that it will silently exit a transactionscope using...
30 May 2011 by Brian Risley
How to do transaction scope exception handling.