Click here to Skip to main content
15,904,416 members
Home / Discussions / C#
   

C#

 
GeneralRe: Insert dataset into database Pin
PIEBALDconsult23-Jun-10 17:57
mvePIEBALDconsult23-Jun-10 17:57 
GeneralRe: Insert dataset into database Pin
shoubi23-Jun-10 18:07
shoubi23-Jun-10 18:07 
GeneralRe: Insert dataset into database Pin
PIEBALDconsult23-Jun-10 18:17
mvePIEBALDconsult23-Jun-10 18:17 
GeneralRe: Insert dataset into database Pin
shoubi23-Jun-10 19:21
shoubi23-Jun-10 19:21 
Questiongetting the local port as netstat in C# + small doubt on network connection Pin
manustone23-Jun-10 9:37
manustone23-Jun-10 9:37 
AnswerMessage Closed Pin
23-Jun-10 20:49
stancrm23-Jun-10 20:49 
GeneralRe: getting the local port as netstat in C# + small doubt on network connection Pin
manustone23-Jun-10 22:02
manustone23-Jun-10 22:02 
Question[newbie] EventLog log = new EventLog() does not work within catch {} block Pin
jon-8023-Jun-10 5:44
professionaljon-8023-Jun-10 5:44 
I'm trying to run this code within Visual Studio 2010, however, having set a breakpoint at line 39, the execution does not seem to get to line 39 where I have set a break point. As a matter of fact, when checking under Visual Studio 2010 Server Explorer > Servers > {puter name} > Application > ASP.NET 4.0.30319.0, there are no relevant events written. I also tried checking within the Windows Event Viewer. For Win XP (Control Panel > Administrative Tools > Event Viewer > Application sub node).

Is this a bug with .NET 4 or Visual Studio 2010? Does this issue happen to anyone else?

Confused | :confused:


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Diagnostics;

public partial class ErrorTestLog : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void cmdCompute_Click(object sender, EventArgs e)
    {
        try
        {
            decimal a, b, result;
            a = Decimal.Parse(txtA.Text);
            b = Decimal.Parse(txtB.Text);
            result = a / b;
            lblResult.Text = result.ToString();
            lblResult.ForeColor = Color.Black;
        }
        catch (Exception err)
        {
            lblResult.Text = "<b>Message:</b> " + err.Message + "<br /><br />";
            lblResult.Text += "<b>Source:</b> " + err.Source + "<br /><br />";
            lblResult.Text += "<b>Stack Trace:</b> " + err.StackTrace;
            lblResult.ForeColor = Color.Red;

            // Write the information to the event log.
            EventLog log = new EventLog();
            log.Source = "DivisionPage";
            log.WriteEntry(err.Message, EventLogEntryType.Error);
        }


    }
}


NOTE:
1. Beginning ASP.NET 3.5 in C# in 2008 - From Novice to Professional (ISBN: 978-1-59059-891-7) P.268 (306)
Jon

AnswerRe: [newbie] EventLog log = new EventLog() does not work within catch {} block Pin
Ennis Ray Lynch, Jr.23-Jun-10 5:59
Ennis Ray Lynch, Jr.23-Jun-10 5:59 
GeneralRe: [newbie] EventLog log = new EventLog() does not work within catch {} block Pin
jon-8023-Jun-10 6:23
professionaljon-8023-Jun-10 6:23 
AnswerRe: [newbie] EventLog log = new EventLog() does not work within catch {} block Pin
Abhinav S23-Jun-10 6:01
Abhinav S23-Jun-10 6:01 
GeneralRe: [newbie] EventLog log = new EventLog() does not work within catch {} block Pin
jon-8024-Jun-10 1:01
professionaljon-8024-Jun-10 1:01 
QuestionDirect X 9 from XNA? Pin
venomation23-Jun-10 5:25
venomation23-Jun-10 5:25 
AnswerRe: Direct X 9 from XNA? Pin
harold aptroot23-Jun-10 5:36
harold aptroot23-Jun-10 5:36 
QuestionTSR Pin
ayandelhi23-Jun-10 5:21
ayandelhi23-Jun-10 5:21 
AnswerRe: TSR Pin
Luc Pattyn23-Jun-10 5:26
sitebuilderLuc Pattyn23-Jun-10 5:26 
AnswerRe: TSR Pin
loyal ginger23-Jun-10 5:27
loyal ginger23-Jun-10 5:27 
AnswerRe: TSR Pin
Keith Barrow23-Jun-10 5:28
professionalKeith Barrow23-Jun-10 5:28 
AnswerHey Pin
Ennis Ray Lynch, Jr.23-Jun-10 6:00
Ennis Ray Lynch, Jr.23-Jun-10 6:00 
JokeRe: Hey Pin
Paladin200023-Jun-10 6:08
Paladin200023-Jun-10 6:08 
GeneralRe: Hey Pin
Keith Barrow23-Jun-10 6:10
professionalKeith Barrow23-Jun-10 6:10 
GeneralRe: Hey Pin
DaveAuld23-Jun-10 6:27
professionalDaveAuld23-Jun-10 6:27 
QuestionAccessing the user.config file on a newly installed application from the installer itself Pin
Kaare Tragethon23-Jun-10 5:10
Kaare Tragethon23-Jun-10 5:10 
AnswerRe: Accessing the user.config file on a newly installed application from the installer itself Pin
hwswin23-Jun-10 5:54
hwswin23-Jun-10 5:54 
GeneralRe: Accessing the user.config file on a newly installed application from the installer itself Pin
Kaare Tragethon23-Jun-10 6:28
Kaare Tragethon23-Jun-10 6:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.