Groups | Blog | Home
all groups > visual studio .net enterprise tools > may 2004 >

visual studio .net enterprise tools : EIF and Web Serivces



Graham Allwood
5/7/2004 1:06:23 AM
I think this must be a faq, but can I find the answer - no.

I successfully used the logging app block in my windows app (sample test),
but I'm now putting it in to my web services. When I try am raise an event
from the web services I'm getting an Error in the event log from EIF, saying
that the LogEventSink cannot be used because a Security Exception was thown,
as below:


Event Type: Error
Event Source: Enterprise Instrumentation
Event Category: None
Event ID: 0
Date: 07/05/2004
Time: 00:55:11
User: N/A
Computer: GRAVYXP
Description:
Error loading an Event Sink of type
'Microsoft.ApplicationBlocks.Logging.EventSinks.LogEventSink,
Microsoft.ApplicationBlocks.Logging.EventSinks, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=490cbe481ee0124d'. 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.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 System.Diagnostics.EventLog.SourceExists(String source)
at
Microsoft.ApplicationBlocks.Logging.EventSinks.LogEventSink.CreateEventSourc
e()
at
Microsoft.ApplicationBlocks.Logging.EventSinks.LogEventSink..ctor(IDictionar
y 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)

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.


Thanks for any help.

Graham

Alf Tore Haaland
5/9/2004 1:29:23 PM
You need to run InstallUtil.exe.

See Event Security in the Enterprise Instrumentation doc.


Logging Events to the Windows Event Log
The ASPNET account does not have sufficient privileges to register a
Windows Event Log event source, but does have sufficient privileges to
write events to the Application Event Log assuming the event source has
already been registered by an administrator. To ensure events are logged
as expected to the Application Event Log, make sure that the local user is
a local administrator before running InstallUtil against the application's
instrumented assemblies. For more information, see Registering an Event
Source and Assembly Installation with InstallUtil.exe.

Enterprise Instrumentation automatically registers Event Log event sources
for you as it scans your instrumented assemblies during this installation
phase, provided you have implemented a standard ProjectInstaller class.

Note It is not sufficient to deploy an ASP.NET Web application to a
server via file-copy alone. You must run Installutil.exe against the
application's instrumented assemblies to ensure the Event Log event
sources are registered.


On Fri, 7 May 2004 01:06:23 +0100, Graham Allwood
[quoted text, click to view]



--
Graham Allwood
5/9/2004 5:04:13 PM
OK, found the problem. The documentation probably tells me this but this is
what I've found:

The EIF will attempt create Event log sources (in the event log) if the
config file specifies an eventSource that doesn't already exist. In the case
of web services running under ASPNET account there is insufficient
permissions for this user to actually create a new event log source.

So a few pointers.

- In a web application there should be a project installer class that
creates the event log sources based on the EIF config file you are using.
- If you use the default Event Source name 'Application' then events will
appear from the source 'Application (<app name>)'. To have the event source
named something explicit then define an eventSource in the config file as
you want it to appear in the event log. Create the event source in the
project installer class. When raising the event, construct a new EventSource
instance passing you event source name in to its ctor and use that instance
to raise your event.

If I have got this wrong can someone tell me, but this is what seems to be
happening for me!!!

Hope this helps someone.

Regards

Graham

[quoted text, click to view]

Graham Allwood
5/9/2004 7:42:12 PM
Many thanks Alf. See me reply today (to myself) which duduced the same
thing. However, I did try creating a class derived from ProjectInstaller but
when I ran InstallUtil it only seemed to generate a new config file, not
register new event sources. Hence the reason I am creating the event sources
myself in my installer class.

Regards

Graham

[quoted text, click to view]

AddThis Social Bookmark Button