Not logging in application log

G

Guest

Hi,

I'm developing an asp.net application which logs the error in case of
exceptions.
In case of exception i'm getting the following error:
Error loading an Event Sink of type
'Microsoft.EnterpriseInstrumentation.EventSinks.LogEventSink'. The Event
Source of name 'Application' will not write events out to this Event Sink.
The following exception was returned during the load:

System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. ---> System.ArgumentException: An error occurred
determining if the Windows Event Log source of Application (Loan) exists on
machine .. This may be due to an incorrect machineName parameter. --->
System.Security.SecurityException: Requested registry access is not allowed.
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at System.Diagnostics.EventLog.FindSourceRegistration(String source,
String machineName, Boolean readOnly)
at System.Diagnostics.EventLog.SourceExists(String source, String
machineName)
at
Microsoft.EnterpriseInstrumentation.EventSinks.LogEventSink..ctor(IDictionary
parameters, EventSource eventSource)
--- End of inner exception stack trace ---
at
Microsoft.EnterpriseInstrumentation.EventSinks.LogEventSink..ctor(IDictionary
parameters, EventSource eventSource)
--- End of inner exception stack trace ---
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean
isBinderDefault)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder
binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes)
at System.Reflection.Assembly.CreateInstance(String typeName, Boolean
ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args,
CultureInfo culture, Object[] activationAttributes)
at
Microsoft.EnterpriseInstrumentation.EventSinks.EventSink.CreateNewEventSinks(DataRow[] eventSinkRows, EventSource eventSource)

Can you please help me with this.

Thanks in advance
Priya
 
N

Nick Malik [Microsoft]

The error is >>System.Security.SecurityException: Requested registry access
is not allowed<<

Writing to the event log only works if you have registered your event
source. With the Enterprise Library, this happens when you install your
app. If you used XCopy install, then you didn't register the event source.
So the EL tries to register it when you run the app. but that requires
access to the registry.
ASP.Net uses a machine account that doesn't have the right to write to the
registry.

You need to install your app.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
Priya said:
Hi,

I'm developing an asp.net application which logs the error in case of
exceptions.
In case of exception i'm getting the following error:
Error loading an Event Sink of type
'Microsoft.EnterpriseInstrumentation.EventSinks.LogEventSink'. The Event
Source of name 'Application' will not write events out to this Event Sink.
The following exception was returned during the load:

System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. ---> System.ArgumentException: An error
occurred
determining if the Windows Event Log source of Application (Loan) exists
on
machine .. This may be due to an incorrect machineName parameter. --->
System.Security.SecurityException: Requested registry access is not
allowed.
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at System.Diagnostics.EventLog.FindSourceRegistration(String source,
String machineName, Boolean readOnly)
at System.Diagnostics.EventLog.SourceExists(String source, String
machineName)
at
Microsoft.EnterpriseInstrumentation.EventSinks.LogEventSink..ctor(IDictionary
parameters, EventSource eventSource)
--- End of inner exception stack trace ---
at
Microsoft.EnterpriseInstrumentation.EventSinks.LogEventSink..ctor(IDictionary
parameters, EventSource eventSource)
--- End of inner exception stack trace ---
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture,
Boolean
isBinderDefault)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr,
Binder
binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes)
at System.Reflection.Assembly.CreateInstance(String typeName, Boolean
ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args,
CultureInfo culture, Object[] activationAttributes)
at
Microsoft.EnterpriseInstrumentation.EventSinks.EventSink.CreateNewEventSinks(DataRow[]
eventSinkRows, EventSource eventSource)

Can you please help me with this.

Thanks in advance
Priya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top