PetShop中报错的处理(EventLog.SourceExists的使用)问题

用PetShop改了个网站,不过程序一出现错误的时候就保“注册表无法访问”的错,
------------------------------------------------------------------------
{
    EventLog m_enentLog=null;
行 14:    if(!( EventLog.SourceExists(ERROR_LOG_SOURCE)))
行 15:    {
行 16:     EventLog.CreateEventSource(ERROR_LOG_SOURCE, "Application");
------------------------------------------------------------------------
原来PetShop中的错误是要写到操作系统日志中的,在Erro.cs中:
None.gif public   class  Error
ExpandedBlockStart.gifContractedBlock.gif 
dot.gif //例如我的应用程序的名称是:comeday
InBlock.gif
  const string ERROR_LOG_SOURCE="comeday";
InBlock.gif  
public static void  Log(string message)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   EventLog m_enentLog
=null;
InBlock.gif   
if(!(EventLog.SourceExists(ERROR_LOG_SOURCE)))
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    EventLog.CreateEventSource(ERROR_LOG_SOURCE, 
"Application");
ExpandedSubBlockEnd.gif   }

InBlock.gif   
if(m_enentLog ==null)
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    m_enentLog
=new EventLog("Application");
InBlock.gif    m_enentLog.Source
=ERROR_LOG_SOURCE;
ExpandedSubBlockEnd.gif   }

InBlock.gif   m_enentLog.WriteEntry(message,System.Diagnostics.EventLogEntryType.Error);
ExpandedSubBlockEnd.gif  }

ExpandedBlockEnd.gif }

None.gif
解决方法:
在注册表
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application
加入:项“ comeday”(你的应用程序名称,我的是comeday)就OK了。

转载于:https://www.cnblogs.com/zhangjidong/archive/2005/07/18/195221.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值