0

I have made an MVC application where I use following line in one of the method:

EventLog ev = new EventLog();

It works fine on local but when I tried to run it on server, this line gave me following error:

Request for the permission of type 'System.Diagnostics.EventLogPermission,System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I am not able to understand the issue, can anyone please help me with it?

ediblecode
  • 11,293
  • 18
  • 63
  • 113
  • Try this post: http://stackoverflow.com/questions/712203/writing-to-an-event-log-in-asp-net-on-windows-server-2008-iis7. – freshbm Apr 12 '16 at 07:10

1 Answers1

1

You may need to simply ask for the correct security permissions prior to using the Event log, like so:

  EventLogPermission eventLogPermission = new EventLogPermission(EventLogPermissionAccess.Administer, ".");
  eventLogPermission.PermitOnly();

See here: support.microsoft.com bug article

dylansweb
  • 664
  • 4
  • 8