我收到以下异常.我在Registry编辑的Eventlogs上完全控制了Asp.net帐户.
[SecurityException:找不到源,但无法搜索部分或全部事件日志.无法访问的日志:安全.]
Run Code Online (Sandbox Code Playgroud)System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate) +664 System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate) +109 System.Diagnostics.EventLog.SourceExists(String source) +14 Microsoft.ApplicationBlocks.ExceptionManagement.DefaultPublisher.VerifyValidSource() +41
我想这是由于服务器上的一些配置问题?
我收到错误:
找不到源,但无法搜索部分或全部事件日志.无法访问的日志:安全性
当我在代码下运行以捕获Win 2K12 R2服务器IIS 8.5上的错误时
EventLog elog = new EventLog();
EventLog.CreateEventSource("MyApp", "Application");
EventLog.WriteEntry(Source, swError.ToString(), EventLogEntryType.Error);
Run Code Online (Sandbox Code Playgroud)
我已经完全访问HKLM\SYSTEM\CurrentControlSet\services\eventlog但它仍然没有工作.我该怎么做才能修好它?
在IIS 7下运行的ASP.Net 3.5似乎不允许开箱即用.
if (!EventLog.SourceExists("MyAppLog"))
EventLog.CreateEventSource("MyAppLog", "Application");
EventLog myLog = new EventLog();
myLog.Source = "MyAppLog";
myLog.WriteEntry("Message");
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用log4net写入Windows Server 2008 SP1上IIS7下的客户事件日志.但是,帐户似乎无权写入事件日志.有没有人有什么建议?
我有一个我用一些业务逻辑创建的库,包括写一个System.Diagnostics.EventLog实例.该库通常从Windows服务应用程序调用,但现在我正在尝试从我的ASP.NET MVC应用程序调用这些相同的库函数.
我在我的控制器中尝试了这个代码来创建我传递给需要写入日志的方法的EventLog实例.
Dim log = New EventLog("Application", My.Computer.Name, "MyMVCApp")
Run Code Online (Sandbox Code Playgroud)
当库方法中的代码尝试写入日志时,会生成以下错误:
[SecurityException: Requested registry access is not allowed.]
System.ThrowHelper.ThrowSecurityException(ExceptionResource resource) +51
Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +7462217
System.Diagnostics.EventLog.CreateEventSource(EventSourceCreationData sourceData) +366
System.Diagnostics.EventLog.VerifyAndCreateSource(String sourceName, String currentMachineName) +194
System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +205
System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type) +14
Run Code Online (Sandbox Code Playgroud)
我的Web应用程序在运行IIS 6的Windows Server 2003上作为网络服务用户运行.为了使网络服务用户能够访问注册表,我需要做些什么吗?
有没有更好的方法来创建一个用于ASP.NET MVC应用程序的EventLog实例?是否已经由我需要引用的框架创建了一个?
我似乎无法写入.NET中的事件日志.我得到以下异常:
System.Security.SecurityException:找不到源,但无法搜索部分或全部事件日志.无法访问的日志:安全性.
我不想访问安全日志.我该如何解决这个错误?谢谢!
我创建了一个C#windows服务,应该发送一些电子邮件,但是当我启动服务时,我收到消息'本地服务开始然后停止'......'如果他们没有工作可以自动停止某些服务'
为什么会这样?
namespace EmailService
{
public partial class EmailService : ServiceBase
{
private System.Timers.Timer _timer = null;
private DateTime _lastRun = DateTime.Now;
private int _timerIntervalValue;
public EmailService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["Timer"]))
{
throw new Exception("The timer value is not set in the app.config.");
}
else
{
_timerIntervalValue = Convert.ToInt32(ConfigurationManager.AppSettings["Timer"]);
}
_timer = new System.Timers.Timer(_timerIntervalValue);
_timer.Elapsed += OnTimedEvent;
_timer.Interval = Convert.ToInt32(_timerIntervalValue);
_timer.Enabled = true;
}
protected override void OnStop()
{
_timer.Stop();
_timer.Dispose();
}
private …Run Code Online (Sandbox Code Playgroud)