0

I deployed an MVC4 application (that uses SignalR) to a server. SignalR works fine when I run it on my dev machine but when I run it after deploying it to the server I get the following error. I think it has to do with something not having permissions to write to the Event Log. I looked at this answer but those solutions did not work for me. Can someone shed some light?

System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique. Inaccessible logs: Security.

Server stack trace: at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate) at System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate) at System.Diagnostics.EventLogInternal.VerifyAndCreateSource(String sourceName, String currentMachineName) at System.Diagnostics.EventLogInternal.WriteEvent(EventInstance instance, Byte[] data, Object[] values) at System.Diagnostics.EventLog.WriteEvent(EventInstance instance, Object[] values) at System.Diagnostics.TraceSource.TraceEvent(TraceEventType eventType, Int32 id, String format, Object[] args) at Microsoft.AspNet.SignalR.Transports.TransportHeartbeat.<>c__DisplayClass2.b__1(String key, ConnectionMetadata old) at System.Collections.Concurrent.ConcurrentDictionary2.AddOrUpdate(TKey key, TValue addValue, Func3 updateValueFactory) at Microsoft.AspNet.SignalR.Transports.TransportHeartbeat.AddConnection(ITrackingConnection connection) at Microsoft.AspNet.SignalR.Transports.ForeverTransport.ProcessReceiveRequest(ITransportConnection connection) at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(HostContext context) at Microsoft.Owin.Host.SystemWeb.OwinCallContext.Execute() at Microsoft.Owin.Host.SystemWeb.OwinHttpHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object extraData)

Exception rethrown at [0]: at Microsoft.Owin.Host.SystemWeb.Infrastructure.ErrorState.<>c__DisplayClass1.b__0(Exception ex) at Microsoft.Owin.Host.SystemWeb.CallContextAsyncResult.End(IAsyncResult result) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) The Zone of the assembly that failed was: MyComputer

Community
  • 1
  • 1
Ray
  • 4,679
  • 10
  • 46
  • 92
  • Possible duplicate of [System.Security.SecurityException when writing to Event Log](http://stackoverflow.com/questions/1274018/system-security-securityexception-when-writing-to-event-log) – Michael Freidgeim Feb 24 '17 at 03:07

2 Answers2

1

For testing you can set an admin user as Identity of your application pool. By default the value is ApplicationPoolIdentity.

enter image description here

If it works you should add permission for the Network Service and add it as user of your app pool. You should add permission to this user on this registry key : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security

Quentin Roger
  • 6,410
  • 2
  • 23
  • 36
  • I tried that but I still get the same error. I also notice that when this error is generated, the app pool shuts down, so I always have to restart it. – Ray Mar 31 '16 at 16:11
  • Wait a minute, maybe I misunderstood your answer. But when I changed the app pool identity to NETWORK SERVICE and gave it Full Control permission to the above registry key, it worked. I always thought that the identity ApplicationPoolIdentity "uses" the NETWORK SERVICE account behind the scenes. – Ray Mar 31 '16 at 16:20
  • Sorry my answer is a little unclear(I ll update my answer when Im back at home) . Im glad that helped anyway. – Quentin Roger Mar 31 '16 at 16:40
0

Another fix for this is to run Visual Studio as Administrator.