Error Handling in petshop (using EventLog. sourceexists)

Source: Internet
Author: User
I used petshop to change a website, Program When an error occurs, the error "the registry cannot be accessed" is fixed,
------------------------------------------------------------------------
{
EventLog m_enentlog = NULL;
Row 14: If (! ( EventLog. sourceexists (error_log_source )))
Row 15 :{
Row 16: EventLog. createeventsource (error_log_source, "application ");
------------------------------------------------------------------------
The original error in petshop was to be written to the operating system log, in erro. CS: Public   Class Error
  { // For example, the name of my application is comeday.
Const   String Error_log_source = " Comeday " ;
Public   Static   Void Log ( String Message)
{
EventLog m_enentlog = Null ;
If ( ! (Eventlog. sourceexists (error_log_source )))
{
EventLog. createeventsource (error_log_source,"Application");
}
If (M_enentlog = Null )
{
M_enentlog=NewEventLog ("Application");
M_enentlog.source=Error_log_source;
}
M_enentlog.writeentry (message, system. Diagnostics. eventlogentrytype. Error );
}
}

solution:
in the registry
HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ Eventlog \ Application
, add the following item: " comeday " (your application name, my name is comeday.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.