代码如下
EventLog log = gcnew EventLog();
try
{
log.Source = "我的应用程序";
log.WriteEntry("处理信息1", EventLogEntryType::Information);
log.WriteEntry("处理信息2", EventLogEntryType::Information);
throw gcnew System::IO::FileNotFoundException("readme.txt文件未找到");
}
catch (System::IO::FileNotFoundException ^exception)
{
log.WriteEntry("处理信息2", EventLogEntryType::Error);
}
我这样写了后会报错:无法将参数 1 从“System::Diagnostics::EventLog ^”转换为“System::String ^”
就是那个EventLog log = gcnew EventLog();这里