Click here to Skip to main content
15,908,775 members
Everything / Handling

Handling

Handling

Great Reads

by Aleksandrs Vorobjovs
Error Logging to the Windows Event Log using ELMAH
by Philip Laureano
How to dynamically intercept thrown exceptions with LinFu.AOP 2.0
by ManojKumar19
Server side logging for Silverlight applications using NLog 2.0
by Dholakiya Ankit
Logging database operations in Entity Framework and handling Exceptions

Latest Articles

by Dholakiya Ankit
Logging database operations in Entity Framework and handling Exceptions
by Shivprasad koirala
In this article we have discuss 6 ways of handling exceptions in ASP.NET MVC.
by Marla Sukesh
Supporting article for MVC step by step series. Here we will see detail demonstration on exception handling.
by ManojKumar19
Server side logging for Silverlight applications using NLog 2.0

All Articles

Sort by Score

Handling 

5 Mar 2012 by Aleksandrs Vorobjovs
Error Logging to the Windows Event Log using ELMAH
17 Dec 2013 by Maciej Los
This is quite often asked question. Please see my past answer: How to get sql tables columns in excel sheet after click button in c#[^]Have you read Code Project Quick Answers FAQ[^]? Probably NOT. Next time, please use SearchBox[^] at the right-top corner on this site.
24 Aug 2015 by CPallini
Quote:while(f1!=NULL && f2!=NULL)This is NOT a good stop condition while reading files. When the end-of-file is reached, its FILE pointer doesn't become NULL. The end-of-file condition is signaled by the getc() return value being EOF (see "getc" ). Change fromQuote: while(f1!=NULL &&...
20 Jun 2011 by CPallini
Have a look at the article: Microsoft Visual C++ and Win32 structured exception handling[^].
20 Jun 2011 by Niklas L
I don't know if this will help you, but you can make the VS debugger break when an exception is thrown. In the Debug -> Exceptions Dialog, you can select which exceptions to handle this way.This obviously only works when debugging. If you want to be able to trace to a log file, follow Mr...
8 Aug 2011 by Christian Graus
It's all you need. The delegate is an anonymous method. So, you use this syntax to create inline events. The real advantage is, any variables in the method that creates this, are visible to the delegate. Google anonymous methods if you need more help.I should add, this runs no faster or...
22 Dec 2011 by Sergey Alexandrovich Kryukov
This is expected behavior.Please understand that "Explorer" is a separate process, and the processes are well isolated. Even if you manage to stick its window into your form (this is possible in principle, but should be avoided by all means), you won't be able to integrate it functionally...
14 May 2012 by Prasad_Kulkarni
Please refer following some nice articles of CP:Exception Handling Best Practices in .NET[^]Using Try... Catch..., Finally![^]Also refer this:The finally Block[^]Exception Handling for C# Beginners[^]Exception handling in C# and ASP .Net[^]
15 Nov 2013 by Ron Beyer
The full path of the file that "opened" the program is available as the second (index 1) argument on the command line:Environment.GetCommandLineArgs[^]So the full path of the file is Environment.GetCommandLineArgs()(1)(Index 0 is the executable name/path).
3 May 2016 by CHill60
In the past I've approached this in three slightly different ways1. Each process had it's own folder for handling the files "owned" by that process. Files were moved from the central drop area into the processing folder, then once that process was finished the file was physically moved into...
21 Jul 2021 by Patrice T
First, you need to know that C manage nothing and forgive nothing, you are responsible of everything. Quote: The program works find till the character length 170 and above. when I define the character below 170 it is showing segmentation fault ...
20 Jun 2011 by Peter Weyzen
A colleague of mine (on a mac) has some code which can hijack the "throw" in order to produce a stack trace at the point the exception is thrown.I was wondering if there were some pre-built stuff for windows to accomplish the same?
27 Nov 2011 by Sander Rossel
Sorry to break this to you, but this is pretty much a coding horror.To create an Array of TextBoxes the following would have sufficed:' Creates an Array that has room for 3(!) TextBoxes.Dim textBoxArray(2) As TextBox' They still have to be set, like following:textBoxArray(0) = New...
11 Jan 2012 by DrBones69
Here are some assorted videos that show how to handle a few different scenarios.Hope it helps-DrB
12 Jan 2012 by Chris Meech
You could also look into inheriting from a CEdit class and write your own control. Then handle the WM_CHAR message and decide what you want to do with it. In a .h file you could have class CFloatEdit : public CEdit {public: // Message handler for WM_CHAR message. afx_msg void...
20 Jan 2012 by Sergey Alexandrovich Kryukov
By default, if you keep some file open, you cannot open it again with another file handle by just using its file name; the access will be denied, and for a very good reason. It will happen by default no matter what file or stream related classes are you using: Stream, FileStream, StreamReader,...
18 Mar 2012 by Wes Aday
You might try using a BackgroundWorker, http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx[^]
1 May 2012 by Ed Nutting
I implemented this one myself over the weekend from an adaptation of this[^] code:/*Copyright Edward Nutting. This may be adapted but all adaptations must at least credit myself and http://blog.trostalex.com/?p=114 as the original sources.*/import android.graphics.Point;import...
19 Jul 2012 by BobJanova
If you mean C, and not for example C++ with COM, events are not part of its methodology. Nor are interruptible threads or methods. I'd recommend that you expose the 'do one frame' function directly to the outside (i.e. so the C# library can call that), and manage the interruptible loop of...
21 Sep 2013 by phil.o
Technically, you are supposed to expose us a problem and ask for a formal question.Anyway, your textMouseDown method has an invalid signature if you want to use it as an eventhandler for MouseDown event:Private Sub TextMouseDown(sender As Object, e As MouseEventArgs) Dim myLabel As...
21 Sep 2013 by Fredrik Bornander
You need to change the signature of your textMouseDown method to match that of the event you're wiring up.Something like this might work for you; Dim textControl() As Label 'Array of label objects Dim txtcnt As Integer Public Sub addTextControl() txtcnt = txtcnt +...
4 May 2011 by Philip Laureano
How to dynamically intercept thrown exceptions with LinFu.AOP 2.0
14 Jun 2011 by ambika_clinton
Can anyone Please guide how to configure client side OpenVPn in C# or any other Language.The Motive is to set the same openvpn client side enviroment in my side but with same functionality .If this isn't possible the least expected is: Can client side gui can be customized in OpenVpn...
13 Jul 2011 by Christian Graus
Why are you asking us to do your job, instead of trying to do it yourself ? Post a SNIPPET of code and a precise question that starts with 'I tried to', not 'Give me the code'.
8 Aug 2011 by 94HellGate
i just found a piece(not enought to find it out) of code and i'm wondering how i can do this, because it's much better than a normal event in my caseconsole.BindCommand("!", delegate(GameTime gameTime, string[] args) { console.WriteLine(args[0]); ...
8 Aug 2011 by BillWoodruff
Hi, Christian is absolutely right, and an event definition can be even simpler using Lambda form in .NET 4.0://'SomeControl' stands for any control that exposes a 'KeyDown' eventSomeControl.KeyDown += (sndr,eArgs)=>{MessageBox.Show(eArgs.KeyCode.ToString());};In this example, you define the...
1 Sep 2011 by BillWoodruff
post-script:...
13 Sep 2011 by jim lahey
1st link searching google for "using gridview in asp.net":http://msdn.microsoft.com/en-us/library/aa479339.aspx[^]for ASP.net 4.0:http://msdn.microsoft.com/en-us/library/2s019wc0.aspx[^]
11 Nov 2011 by tonynhandv
I using MicrosoftReportViewer create report but press button Print then error "the handle is invalid"can us help me?
11 Nov 2011 by koolprasad2003
have you check[^]http://social.msdn.microsoft.com/forums/en-US/vsreportcontrols/thread/2820baf3-624c-42a8-bc42-89291f7ccd95/[^]
27 Nov 2011 by Member 4567888
I have created following class to create Textbox Array Dynamically.Below is TextBoxArray.VB filePublic Class TextBoxArray Inherits System.Collections.CollectionBase Private ReadOnly HostForm As System.Windows.Forms.Control Dim aTextBox As New System.Windows.Forms.TextBox...
22 Dec 2011 by Monjurul Habib
The following example first spawns an instance of Internet Explorer and displays the contents of the Favorites folder in the browser. It then starts some other instances of Internet Explorer and displays some specific pages or sites. Finally it starts Internet Explorer with the window being...
12 Jan 2012 by Mr. Tomay
Where is the best place to handle an CEdit control input text before it is displayed to the screen, so I can control the input text and make changes to it and finally display it to the screen ?Give me an example code please !
20 Jan 2012 by Jorge J. Martins
Hi guys, I really need some help or advise.I have an handler that my Silverlight App uses to deliver a copy of a certain Excel file to the end user in a "Viewing mode": public class Handler1 : IHttpHandler { public void ProcessRequest(HttpContext context) { ...
20 Jan 2012 by Jorge J. Martins
Yeah! It works.This is what it looks like after making that copy.The problem now is that the File.Delete isn't making it's job. Any clue? public class Handler1 : IHttpHandler { public void ProcessRequest(HttpContext context) { string filename =...
27 Feb 2012 by Jorge J. Martins
Got it working a while ago. Had to make it Assync.Here's how: public class Handler1 : IHttpAsyncHandler { string fullTempPath; public void ServeContent(HttpContext context) { string filename =...
18 Mar 2012 by GoyalGourav
Hi All,I am developing a desktop application on c# .net for .pdf file managing. A problem occur when i search any folder for .pdf, my application stopm responding for some time. I use xmlwriter to write data(i.e. file name,author name,subject).Also i have a label to show current scanning of...
18 Mar 2012 by Clifford Nelson
What you do is use a background worker, and pass the names of the files back in the ReportProgress. Here is something similar.public MainWindow() { InitializeComponent(); ItemsSource = new ObservableCollection() { "pme", "two", 3.ToString() }; DataContext =...
12 May 2012 by smrizvi1
I have a Books.txt file which looks like this. Book name---------------AuthorLord of the rings---------J. R R TolkiensTom sawyer--------------Mark twainJust after sunset---------Stephen kingThe shining--------------Stephen kingOliver twist------------Charles DickensHuck...
14 May 2012 by sandy4171
Hi all,Yesterday i face this question in my interview in corbus india........how to handle exception in Finally block....and where the control goes if error comes???? Please Reply if anyone know this
18 May 2012 by smrizvi1
Alright, now this is what i have. I have used the approach of bubble sorting then binary searching. what i want to do now is to search a particular BOOK from someone without using the bubble sorting or binary searching method and instead search all the records one at a time, from start till the...
19 Jul 2012 by mYashodhar
Hi currently I am writing a GUI which calls a C H.264 video decoder library. I want to stop the decoder as soon as it finishes decoding one frame and updating a buffer and then read this buffer from C# GUI and then display the same.How can I achieve this? , not much information is present on...
4 Aug 2012 by AbO_OsAmH
Hello ......I wont to ask how to handle right click in richtextbox in c#......for Example:when i click on right click mouse over richtextbox the programe will display a messageBox.Thanks A lot...
4 Aug 2012 by AbO_OsAmH
private void richTextBox1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { MessageBox.Show("you got it!"); } }This is the solution.
12 Nov 2013 by Member 2113297
Kinda new with C#, stupid question, i want to read in .bmp file data...or a binary file dataused regular C long time, this is giving me grief!I know this is probably the simplest question...but looking on line, cant find a simple answer?Want to do this programmatically...no dialog...
17 Dec 2013 by rockitabhinav
I am trying to copy contents of an excel sheet having blank cells as well. I want the contents to be stored in CSV format in a text file. I want to then search over find out one of the excel entries and raise a flag value for it. In other words, I want to count the number of occurences of a...
12 Mar 2014 by xprtgovind
how can i assign name of...
22 May 2014 by DFaeuster
Hello,since days I try to fire events from VB and catch them with C++ - unfortunately w/o any success. To my excuse: I am not a VB developer and do not know all the mechanisms used here.For your better understanding here is my current situation and what I achieved so far:I want to...
23 May 2014 by KarstenK
You should forward your callback function and some parameters up to the C++ App and do messaging via PostThreadMessageIt is best because it is non-blocking by packing the message in the message queue.
1 Jun 2014 by Stefan_Lang
Interrupts are Assembler, not C, and they are hardware dependend, i. e. must be adapted to the specific CPU you are writing the program for. The program will likely not run on machines with different CPUs, even if they run the same OS. You really shouldn't do that unless there is a very good...
13 Aug 2014 by Sergey Alexandrovich Kryukov
In "But it didn't catch the following exception" the "following" is not exception, period. The question makes no sense at all. Maybe you really have some exception somewhere, but your problem is not exception, but lack of understanding and the failure to present a comprehensive issue...
26 Aug 2014 by noahdi
I use Microsoft Enterprise Library to handle exceptions. i want to add a fault handler and select a class in the project that is defined as DataContract. i don't know how to tell the library to throw my custom fault exceptionThe picture showing the situation
29 Mar 2015 by Sergey Alexandrovich Kryukov
There is nothing more wrong that this cast. System.Windows.Forms (too bad you did not indicate what UI library you are using) windowed control wrap HWND; it cannot be a reference in principle, HWND is a native (unmanaged) code handle. In this library, HWND is of course...
1 Apr 2015 by JOTHI KUMAR Member 10918227
hi to all, 1) i need to throw a exception and give warning message i.e(if i processed or not) 2) if i click 'ok' need to processed or otherwise just click 'cancel'. 3) here im using formview and it just call insert method and then it throw the...
24 May 2015 by Zain Xd
The Program which i created to catch the input error.Catch works Fine but when i use do while to say user if you want to continue press 'y' or finish this press 'n' but when user enter any character expect 'n' it continue the same.when i debug this debugger ignore character input.This is the...
24 May 2015 by Richard MacCutchan
You do not check to see if the user pressed 'y', only if he/she did not press 'n'. So any character other than 'n' will continue the loop. You need to add another loop to check which character is pressed, something like: do { System.out.println("If yes press 'y'...
3 May 2016 by Gaurav_Chaudhary
Hi,I have numerous of tasks which run and process files and its possible that multiple task can process same file (parsing etc..).I want to process the file handling in such a way that we can know that particular file is processed by particular task and next time it won't process the...
12 Dec 2017 by tiwal
I have been able to create a CButton in a CView derived class, and it is visible. The problem is, no matter how and where I insert the ON_BN_CLICKED event management map entry, it seems the event is not fired or at least not propagated to the correct message map. This is my CView derived class...
12 Dec 2017 by Jochen Arndt
I have just tested it with a new MFC application and it works as expected: // ViewTestView.h class CViewTestView : public CView { // ... protected: CButton m_button; DECLARE_MESSAGE_MAP() afx_msg void OnButton(); }; // ViewTestView.cpp BEGIN_MESSAGE_MAP(CViewTestView, CView) //...
21 Jul 2021 by Sanre
Hello, I am doing a assignment. The task is: Quote: Open a text file and print its contents in command window, ask the user to replace the text from the text file to be written and save the text file. The program works find till the character...
21 Jul 2021 by OriginalGriff
You need to use the debugger repeatedly: first time to find exactly what is giving the segmentation fault, and then again to work out why. Probably, it's to do with your MAX value - since it's 170 and that's the point at which it starts to give...
28 Apr 2012 by ManojKumar19
Server side logging for Silverlight applications using NLog 2.0
8 Feb 2016 by Dholakiya Ankit
Logging database operations in Entity Framework and handling Exceptions
12 Nov 2013 by Sergey Alexandrovich Kryukov
Bitmaps (not just *.BMP) are opened with System.Drawing.Bitmap constructor:http://msdn.microsoft.com/en-us/library/0cbhe98f%28v=vs.110%29.aspx[^]."Or a binary file data"? There is no such thing. Everything, any file, is binary. You can open any file. What to do next? it depends. Please...
4 Dec 2014 by Shivprasad koirala
In this article we have discuss 6 ways of handling exceptions in ASP.NET MVC.
12 May 2012 by Richard MacCutchan
You could read the file into a hash_multimap[^] and then do a lookup based on the author name as key, but this will be limited by available memory. You may be better advised to use a database of some sort such that you can add, delete and update records as books are moved around. However, given...
4 Dec 2014 by Marla Sukesh
Supporting article for MVC step by step series. Here we will see detail demonstration on exception handling.
12 Apr 2016 by CHill60
The Exception class can provide a great deal of detail if you need it, including the line number and a complete stack trace. Examine the output from this code snippet for a demonstration:private void input_btn_Click(object sender, EventArgs e){ try { int x = 0; ...
12 Apr 2016 by David Knechtges
I am assuming you want to catch and do something with all unhandled exceptions within your code. I will leave it to you to put the proper using statements at the top of your files.Do something like this:In your main within program.cs near the beginning of the...
4 May 2011 by Martin Jarvis
Logging is the new Exception Swallowing
1 May 2012 by larssy1
Hi guys,,Anyone who could explain to me how they handle android / iphone / windows phone games with those onscreen joysticks?example image:http://imageshack.us/photo/my-images/265/26616423.jpg/[^]Yours Sincerely,Lars
2 May 2015 by Rahul83
Hi,I get an exception in Authorization module which i am handling in Application_Error handler (also i am calling Server.ClearError()) since i want to sent custom error page with some error info to user.I am surprised to see that final response sent to user have error response + response...
16 Nov 2013 by Allw
hi all,i have come across a problem, and i am not sure how to solve it Google is useless for this! (i use VB.net by the way and anything other than that right now will confuse me).So i need to be able to double click on a file, this file opens the program and the program in turn opens...
4 Aug 2012 by Sangramsingh Pawar
Go through following links you will get some idea about it.http://www.dreamincode.net/forums/topic/135857-how-do-add-a-right-click-menu/[^]http://stackoverflow.com/questions/6393040/how-do-i-change-what-appears-when-right-clicking-in-a-rich-text-box-in-c[^]
13 Aug 2014 by Mohammed Asaad
Look the following codestatic class Program { /// /// The main entry point for the application. /// [STAThread] [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlAppDomain)] static...
15 Nov 2013 by Sergey Alexandrovich Kryukov
Please see my comment about VB.NET vs C#. Here is the good news: you can easily and automatically translate one into another with 100% accuracy. There are on-line and off-line/stand-along solutions, so, first of all, pay attention for the open-source stand-along tool, ILSpy, which can easily...
22 Sep 2013 by Manoj K Bhoir
See this small example for Event Handling VB.net : Private _objLabel As Label Private _ControlId As Integer = 0 Public Sub AddLabelControl() _objLabel = New Label 'Create New Object Of Label Control _ControlId = _ControlId + 1 'Increase Control Id Count By 1 ...
1 Jun 2014 by Vivek_Maruxxxx
i want to use left, right, up and down keys of key board. so please tell me that how to use interrupt 21h in c.
29 Sep 2015 by Member 11898134
void mousecontrol_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { FrameworkElement modeitem = e.OriginalSource as FrameworkElement; ContextMenu modemenu = new ContextMenu(); clipboard_object = sender as...
22 Dec 2011 by Bojjaiah
you can try it//it's open Control Panel Process.Start ( "control.exe" );//it's open my computer Process.Start ( "explorer.exe" );//it's open Internet Explorer Process.Start ( "iexplore.exe" );
13 Jul 2011 by Vijay Pate
I am upgrading a code mentioned below: what I am trying to do is I have product register for 30 and at 25th day it will remind user to register for year or two it is mentioned in code Also I want to convert or add new code so that "Purchase Required" turn into "Available" by inserting...
13 Sep 2011 by TanmoyD
How to handle grid view in aspx page
20 Nov 2011 by Elman90
Yes, thanks for the advice, for everyone interested the event name is simply IsMinimized
22 Dec 2011 by contact97438
Hi Folks,I want to open explorer.exe on my control panel.I've succeeded for many other programs, like notepad, calc.exe, ... but when i try with explorer, an external windows explorer appears.Here's my code, some help please : Imports System.Runtime.InteropServicesPrivate...
11 Jan 2012 by Jochen Arndt
Controls are usually initialized in OnInitDialog of your dialog which is executed before the dialog is shown. It is not necessary to perform input tests before the control is shown, because the user can't enter anything.Input validation is usually performed in OnOK.This is rather trivial...
11 Jan 2012 by «_Superman_»
Edit controls send the EN_UPDATE notification code to the parent dialog after its text has changed and before the text is displayed. This is the notification you probably want to handle.Check out its documentation here -...
21 Sep 2013 by asjadathick
Dim textControl() As Label 'Array of label objectsDim txtcnt As IntegerPublic Sub addTextControl() txtcnt = txtcnt + 1 'Integer keeps track of number of instances created ReDim textControl(txtcnt) Me.Controls.Add(textControl(txtcnt)) AddHandler...
12 Feb 2015 by getrelax
I have windows application that manipulates treeview; on select of a node from the treeview it gets the selected node. The code looks private MethodInfo[] methodInfo;private ParameterInfo[] param;private void treeview1_AfterSelect(object sender, TreeViewEventArgs e) { …. ...
12 Feb 2015 by Sergey Alexandrovich Kryukov
To start with, TreeViewEventArgs is System.Windows.Forms.TreeViewEventArgs. It is totally unrelated to ASP.NET, so just forget it. Formally, this is the answer to your question: there is no use.Now, there is no such thing as "returns error". Nothing "returns error" in modern programming....
12 Feb 2015 by getrelax
I didn’t say TreeViewEventArgs, I said TreeNodeEventArgs which is System.Web.UI.WebControls.TreeNodeEventArgs. As I mentioned in the question the first part of the code shows the windows implementation and the second part is web implementation. And my question is how can I use...
29 Mar 2015 by justbegin123
So as of now, I've managed to successfully get the x and y coordinates.Inside the panel code. POINT cursorPos; GetCursorPos(&cursorPos); int x; int y; x = cursorPos.x; y = cursorPos.y; ...
24 Aug 2015 by Member 11932208
/* Here is my code. please check it and reply me(e-mail) where is/are the mistake i have created! */#include#include#includevoid main(){ FILE *f1, *f2, *f3; char ch1,ch2; clrscr(); f1 = fopen("a.txt","r"); if(f1 == NULL) ...
12 Apr 2016 by ByeByeByeByeBye
I would like to save a lot of time and space in my C# application not to surround each single line of code with a "try...catch" construct to avoid errors. It obscures my code and to type it each time is tiring off. I seek to do some global error handling.Example (VB 6): On Error Resume Next....