对数据库操作异常,会在操作系统的日志记录,但是我找不到相应的代码。

解决方案 »

  1.   

    please share to us.thanks
      

  2.   

    using System;namespace PetShop.ConfigTool
    {
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class ConfigConsole
    {
    /// <summary>
    /// An application to help configure the .NET Pet Shop when it is deployed
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main(string[] args) { // Print to the console what this application is
    System.Console.WriteLine("Microsoft .NET PetShop Blueprint Application - Setup\n"); // Try to configure the event source for error logging
    if (PetShopEventLog.CreateEventSource()) {
    System.Console.WriteLine("'" + PetShopEventLog.EVENT_LOG_SOURCE + "' Event Source created successfully.");
    }
    else {
    System.Console.Error.WriteLine("Error in creating the: '" + PetShopEventLog.EVENT_LOG_SOURCE + "' Event Source. This requires administrator privileges.");
    } // Encrypt the database connection strings 
    PetShopConnectionString.EncryptConnectionString();
    System.Console.Error.WriteLine("Database connection strings have been encrypted in:\n\t'" + PetShopConnectionString.CONFIGFILE + "'"); System.Console.WriteLine("PetShop Configuration is complete.\nHit <enter> key to exit."); // wait for the user to press enter
    System.Console.Read();
    }
    }
    }
      

  3.   

    using System;
    using System.Diagnostics;
    using System.Configuration;namespace PetShop.ConfigTool
    {
    /// <summary>
    /// Summary description for EventLog.
    /// </summary>
    public class PetShopEventLog
    {
    public static string EVENT_LOG_SOURCE = ConfigurationSettings.AppSettings["Event Log Source"]; /// <summary>
    /// Creates the PetShop Event Source. This requires administrator privileges
    /// because it needs to write to the registry hive.
    /// </summary>
    /// <returns>If the event source was created successfully true is returned, otherwise false.</returns>
    public static bool CreateEventSource() {
    // make sure we have an event log
    if (!(EventLog.SourceExists(EVENT_LOG_SOURCE))) {
    try {
    EventLog.CreateEventSource(EVENT_LOG_SOURCE, "Application");
    return true;
    }
    catch (Exception) {
    return false;
    }
    }
    else { // the event source already exists
    return true;
    }
    }
    }
    }
      

  4.   

    ConfigTool/PetShopEventLog.cs这个文件