.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links


Posted By:      Posted Date: October 14, 2010    Points: 0   Category :ASP.Net

Hi frns, there is a try/catch block in my application. i just want to know the possibilities of getting inside catch block. In waht casese it can happen. Here is the code.

 if (_jobID == 0)
                    _jobID = Convert.ToInt32(qs[Indexes.JOBID]);
                    if (_jobID <= 0)
                        throw new Exception("Invalid CurrentJob Id");
                    throw new Exception("No parameters...");



View Complete Post

More Related Resource Links

SQL Server 2005 Try and Catch Exception Handling

I'm pretty excited to see that there is some real error handling for T-SQL code in SQL Server 2005. It's pretty painful to have your wonderfully architected .NET solution tainted by less-than-VBScript error handling for stored procedures in the database. The big difference being the addition of TRY..CATCH blocks. Let's take a look:

reader.getordinal("column_may_not_exist") how to catch the exception?



would any body please help me to catch the exception if the column doesnot exist as my table columns are not static.

sometimes its throwing me indexoutofrange exception as the column doesnot exist

thanks for the help guys

How to CATCH "Invalid postback or callback argument" exception?



How can I catch this exception? I do not want it to stop my page execution. Can/Should I do that?

Server Error in '/' Application.
Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally

Using the BDC API how to catch the returned code when executing a stored procedure?

using BDC API, how can i catch the return code a stored procedure returns?

I tried Entity.Execute to execute a generic method. However, it returns an empty Entity table.

I know you can do it by setting up an output variable. I prefer returning an integer for tracking errors.

Any ideas?



Catch button click event in different .aspx page.


I have a button which starts processing.
I want that when ever a button is click from page1.aspx .. a count down timer should start and displayed on page2.aspx.
I am thinking of using iframe to join 2 pages.

Please let me know your suggestions.


Add Release-Only try-catch to CLR languages

Deploying a software, it's a common practice to encapsulate top-most function calls and/or event handlers with general try-catch blocks to deliver an error description to the user instead of just having him/her see the software exiting unexpectedly when unexpected exceptions occur. Unfortunately, during debugging it is most annoying to reach these log entries or message boxes instead of having Visual Studio halt where the exception occured. At the time of writing it is possible to designate particular exception types to halt the debugger when they are actually thrown. But it becomes a nuisance when there are many exception types to be marked this way. Plus, it becomes contra-productive if there is a scenario when expected exceptions of the marked types occur regularly and "Continue" has to be selected again and again in the debugger. Thus, I'd like to suggest to add a new, Microsoft specific, "try" keyword to all of the CLR languages (plus C++), perhaps something like "__try". This new kind of try should create a try-catch block only when compiling in Release mode. (This behaviour might apply to other configurations as well. I suppose the Configuration Settings dialog to provide an additional checkbox column to provide an option to select whether a particular configuration will create a try-catch block or not.)   See here for

Unable to catch WCF EndpointNotFound exception in SecurityToken.GetToken( . )

I have a set of WCF services that I am integrating with, I can not change them in any way because they are provided by a third party. I use a username/password scheme to authenticate with the services. If the services are not available I get an exception (EndPointNotFoundException) from the SecurityTokenProvider class that I can not catch. I understand why the exception is being thrown, I just need to know how I can handle it so that I can gracefully handle the errors in the user interface. Is there a way I can catch this exception or a better way to handle this scenario? The Exception The exception is thrown from System.IdentityModel.Selectors.SecurityTokenProvider : GetToken( TimeSpan timeout ) public SecurityToken GetToken(TimeSpan timeout) {    SecurityToken token = this.GetTokenCore(timeout);     if (token == null)    {        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.TokenProviderUnableToGetToken, this)));    }     return token;} The channel open part When I open the channel I have it wrapped in exception handling, but none of it seems to trap the SecurityToken exception. I am using the ExceptionHandlingProxyWrapperBase try{    this.Open();} catch( EndpointNotFoundException epnfe ){    // Handle the exception} catch( E

How to catch click from link inside widget

Hello,I have an ASP.NET (3.5) page. On the page there is a widget.  Here is the page code:<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Stiri.aspx.cs" Inherits="Stiri" Title="Stiri in Teleorman" %><asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><script language="javascript" type="text/javascript" src="http://www.presaonline.com/ajx/webmasters/get/0/?tidings_number=5&show_image=on&show_body=on&show_county="></script></asp:Content> The widget (script) displays a list of news from another website like this:---------------------------------------------------------title1 (as link)short descriptiontitle2 short description.............................................---------------------------------------------------------1. When a user clicks on one of the links in the above list I want to "catch" the link.2. ISSUE: When the link (from the list) is clicked the URL is opened in another browser tab3. If a user clicks on a link I want to redirect him not to the link's URL but to a page of my website.I

Catch Block question

What are the scenarios in which a t-sql catch block will not be called?   I have a SP which does partition management, sometimes i see that partitions have not been properly created... but still the catch block was never called. This is getting very hard to debug.   Can it be that in some timeout scenarios the catch block is not called?

try catch block

Hi Guys, I have a very simple question. whether to put the select stmt in try/catch or not? Its advantage,disadvantage if any will be of great help.~Technology Analyst~

Is it possible for one thread to catch an event thrown by another thread?

I have a very simple class (shown below) that monitors the mouse position on a separate thread to see if it is hovering over the same spot for more than a second.  I have to do this because the Windows Forms control I am using is an interop COM component that does not have or implement the MouseHover event. Anyway, the class that instantiates asrMouseHover (lets call it WinFormMain) adds a handler for the asrMouseHover.MouseIsHovering event.  The problem is, when this event is raised and caught, the handler in WinFormMain is running on the same thread as asrMouseHover.  I need it to run on WinFormMain... hence, is it possible for one thread to catch an event thrown by another thread.    Public Class asrMouseHover Public Event MouseIsHovering(ByVal sender As Object, ByVal e As System.EventArgs) Private _timer As System.Threading.Timer Private _xCoord As Int32 = 0 Private _yCoord As Int32 = 0 Public ReadOnly Property XCoord() As Double Get Return _xCoord End Get End Property Public ReadOnly Property YCoord() As Double Get Return _yCoord End Get End Property Sub New() Dim myTimerCallback As System.Threading.TimerCallback = New TimerCallback(AddressOf MyCallbackMethod) _timer = New System.Threading.Timer(myTimerCallback, Nothing, 1000, 1000) End Sub Sub MyCallbackMethod(ByVal s

How to catch Save Ribbon event from code-behind for the custom webpart

Hi there, How can a custom web part(sitting on top of PDP) catch the Save Ribbon event from code? I’ve been looking around for solution, but not yet find one…. Thank you, —JoeJoe

Catch Save Ribbon Event from code-behind for webpart control

Hi there, How can a custom web part catch the Save Ribbon event from code-behind? Thank you, —JoeJoe

Catch Save Ribbon Event from code-behind for webpart control

Hi there, How can a custom web part catch the Save Ribbon event from code-behind? Thank you, —JoeJoe

Try-Catch block cannot handle exceptions when contacting a Silverlight Client using net.tcp Duplex W

I have created a simple duplex WCF for Silverlight 4 clients, using net.tcp binding (.NET Framework 4.0)  The client interface is declared as <ServiceContract()> _ Public Interface IServiceClient <OperationContract(IsOneWay:=True)> _ Sub SendUpdate(ByVal allRecords As List(Of String)) End Interface while the service interface is declared as <ServiceContract(Namespace:="SilverlightService", CallbackContract:=GetType(IServiceClient))> _ Public Interface IService <OperationContract(IsOneWay:=True)> _ Sub Connect() End Interface The service code is implemented like: <ServiceBehavior(ConcurrencyMode:=ConcurrencyMode.Multiple, InstanceContextMode:=InstanceContextMode.Single)> _ <Activation.AspNetCompatibilityRequirementsAttribute(RequirementsMode:=Activation.AspNetCompatibilityRequirementsMode.Allowed)> _ Public Class Service Implements IService 'Keep the list of all the active/connected clients: Public _clients As List(Of IServiceClient) = New List(Of ITrackServiceClient) Public Sub Connect() Implements IService.Connect Dim client = OperationContext.Current.GetCallbackChannel(Of IServiceClient)() Dim clientExist = From p In _clients _ Where p Is client _ Select p If clientExist.Count() = 0 Then Monitor.Enter(_clients) _clients.Add(client) Monitor.E

How to Catch Bad JSON Request Payload in REST using WCF3.5

Hi, I'm using WCF 3.5 REST with JSON output. If I send the below request body {"persons": [{"fname":"John"}, {"fname":"sheena"}} to my web API, my REST service throws "500 - Internal Server Error". If you look at carefully, request is missing the ending square bracket & hence the error comes. Now, I would like to know how to catch this error??? So, far I've no luck in catching this error at all. I need to give 400 Bad Request error instead. How do I do that? Thanks!

Create an Event Handler to catch calls to Create.aspx

Hi, I want to research creating an event handler/reciever to catch calls (mouse clicks) to Create.aspx to prevent users having the ability to create new content. I've noticed in VS2010 the templates for Event Recivers you do not get anything similar that I could use as a starting point (List Events, List Item Events etc) Any ideas how I can define a new type of event receiver?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend