Writing Events using System.Diagnostics.EventLog...

D

David Conorozzo

I am able to create new sources using CreateEventSource.
I can call GetEventLogs, I can delete sources, I can see
if sources exist BUT, as soon as I try a "WriteEntry", I
get an exception:

{System.InvalidOperationException}
[System.InvalidOperationException]:
{System.InvalidOperationException}
HelpLink: Nothing
InnerException: {System.ComponentModel.Win32Exception}
Message: "Cannot open log for source {0}. You may not
have write access."
Source: "System"
StackTrace: " at
System.Diagnostics.EventLog.OpenForWrite()
at System.Diagnostics.EventLog.WriteEvent(Int32
eventID, Int16 category, EventLogEntryType type, String[]
strings, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID, Int16
category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID, Int16
category)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID)
at FormRouter.Global.LogError(String sError) in
c:\inetpub\wwwroot\FormRouter\Global.asax.vb:line 79"
TargetSite: {System.Reflection.RuntimeMethodInfo}

The inner exception is:
{System.ComponentModel.Win32Exception}
[System.ComponentModel.Win32Exception]:
{System.ComponentModel.Win32Exception}
HelpLink: Nothing
InnerException: Nothing
Message: "Access is denied"
Source: Nothing
StackTrace: Nothing
TargetSite: Nothing




I don't quite understand. I am running .NET v.1.1.4322.
I am developing using VS .NET 2003. I am running Windows
2003 Server Enterprise.
 
K

Kevin Spencer

What account is your app running under? What are the permissions for this
account?

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
D

Damian

Kevin, we're having the same problem here. The ASP.NET application,
currently installed on Windows 2003 Server, used to work fine on
Windows 2000.

We've set the Impersonate parameter to TRUE.

Kevin Spencer said:
What account is your app running under? What are the permissions for this
account?

--
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

David Conorozzo said:
I am able to create new sources using CreateEventSource.
I can call GetEventLogs, I can delete sources, I can see
if sources exist BUT, as soon as I try a "WriteEntry", I
get an exception:

{System.InvalidOperationException}
[System.InvalidOperationException]:
{System.InvalidOperationException}
HelpLink: Nothing
InnerException: {System.ComponentModel.Win32Exception}
Message: "Cannot open log for source {0}. You may not
have write access."
Source: "System"
StackTrace: " at
System.Diagnostics.EventLog.OpenForWrite()
at System.Diagnostics.EventLog.WriteEvent(Int32
eventID, Int16 category, EventLogEntryType type, String[]
strings, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID, Int16
category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID, Int16
category)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID)
at FormRouter.Global.LogError(String sError) in
c:\inetpub\wwwroot\FormRouter\Global.asax.vb:line 79"
TargetSite: {System.Reflection.RuntimeMethodInfo}

The inner exception is:
{System.ComponentModel.Win32Exception}
[System.ComponentModel.Win32Exception]:
{System.ComponentModel.Win32Exception}
HelpLink: Nothing
InnerException: Nothing
Message: "Access is denied"
Source: Nothing
StackTrace: Nothing
TargetSite: Nothing




I don't quite understand. I am running .NET v.1.1.4322.
I am developing using VS .NET 2003. I am running Windows
2003 Server Enterprise.
 
G

George Birbilis

hi guys,
you have to use "regedt32" (not regedit!!!) and give to the ASPNET user (or
the impersontated user if you use impersonation I suppose) the appropriate
rights to the EventLogs you want in the registry

don't have the info handy at the moment, try searching for "regedt32"
"asp.net" "log" using Copernic Agent Basic (it's free) from www.copernic.com

if you can't still find it, e-mail me privately and I can post more on this
thread searching my favorites entries

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
George Birbilis <[email protected]>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ QuickTime VCL and ActiveX controls (for PowerPoint/VB/Delphi etc.)
+ Plugs VCL and ActiveX controls (InterProcess/Internet communication)
+ TransFormations, VB6 forms to ASP.net WebForms convertion
http://www.kagi.com/birbilis
+ Robotics
http://www.mech.upatras.gr/~robgroup
.........................................................................
Damian said:
Kevin, we're having the same problem here. The ASP.NET application,
currently installed on Windows 2003 Server, used to work fine on
Windows 2000.

We've set the Impersonate parameter to TRUE.

"Kevin Spencer" <[email protected]> wrote in message
What account is your app running under? What are the permissions for this
account?

--
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

David Conorozzo said:
I am able to create new sources using CreateEventSource.
I can call GetEventLogs, I can delete sources, I can see
if sources exist BUT, as soon as I try a "WriteEntry", I
get an exception:

{System.InvalidOperationException}
[System.InvalidOperationException]:
{System.InvalidOperationException}
HelpLink: Nothing
InnerException: {System.ComponentModel.Win32Exception}
Message: "Cannot open log for source {0}. You may not
have write access."
Source: "System"
StackTrace: " at
System.Diagnostics.EventLog.OpenForWrite()
at System.Diagnostics.EventLog.WriteEvent(Int32
eventID, Int16 category, EventLogEntryType type, String[]
strings, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID, Int16
category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID, Int16
category)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID)
at FormRouter.Global.LogError(String sError) in
c:\inetpub\wwwroot\FormRouter\Global.asax.vb:line 79"
TargetSite: {System.Reflection.RuntimeMethodInfo}

The inner exception is:
{System.ComponentModel.Win32Exception}
[System.ComponentModel.Win32Exception]:
{System.ComponentModel.Win32Exception}
HelpLink: Nothing
InnerException: Nothing
Message: "Access is denied"
Source: Nothing
StackTrace: Nothing
TargetSite: Nothing




I don't quite understand. I am running .NET v.1.1.4322.
I am developing using VS .NET 2003. I am running Windows
2003 Server Enterprise.
 
L

Lucas

I followed steps in
http://www.c-sharpcorner.com/Code/2003/Sept/ErrorLoggingInASPNet.asp
I added my user (because we are impersonating) and ASPNet user with Full
Control over this registry setting.
Nothing different happened

Any idea?

Thanks

Lucas

George Birbilis said:
hi guys,
you have to use "regedt32" (not regedit!!!) and give to the ASPNET user (or
the impersontated user if you use impersonation I suppose) the appropriate
rights to the EventLogs you want in the registry

don't have the info handy at the moment, try searching for "regedt32"
"asp.net" "log" using Copernic Agent Basic (it's free) from www.copernic.com

if you can't still find it, e-mail me privately and I can post more on this
thread searching my favorites entries

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
George Birbilis <[email protected]>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ QuickTime VCL and ActiveX controls (for PowerPoint/VB/Delphi etc.)
+ Plugs VCL and ActiveX controls (InterProcess/Internet communication)
+ TransFormations, VB6 forms to ASP.net WebForms convertion
http://www.kagi.com/birbilis
+ Robotics
http://www.mech.upatras.gr/~robgroup
........................................................................
Damian said:
Kevin, we're having the same problem here. The ASP.NET application,
currently installed on Windows 2003 Server, used to work fine on
Windows 2000.

We've set the Impersonate parameter to TRUE.

"Kevin Spencer" <[email protected]> wrote in message
What account is your app running under? What are the permissions for this
account?

--
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I am able to create new sources using CreateEventSource.
I can call GetEventLogs, I can delete sources, I can see
if sources exist BUT, as soon as I try a "WriteEntry", I
get an exception:

{System.InvalidOperationException}
[System.InvalidOperationException]:
{System.InvalidOperationException}
HelpLink: Nothing
InnerException: {System.ComponentModel.Win32Exception}
Message: "Cannot open log for source {0}. You may not
have write access."
Source: "System"
StackTrace: " at
System.Diagnostics.EventLog.OpenForWrite()
at System.Diagnostics.EventLog.WriteEvent(Int32
eventID, Int16 category, EventLogEntryType type, String[]
strings, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID, Int16
category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID, Int16
category)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID)
at FormRouter.Global.LogError(String sError) in
c:\inetpub\wwwroot\FormRouter\Global.asax.vb:line 79"
TargetSite: {System.Reflection.RuntimeMethodInfo}

The inner exception is:
{System.ComponentModel.Win32Exception}
[System.ComponentModel.Win32Exception]:
{System.ComponentModel.Win32Exception}
HelpLink: Nothing
InnerException: Nothing
Message: "Access is denied"
Source: Nothing
StackTrace: Nothing
TargetSite: Nothing




I don't quite understand. I am running .NET v.1.1.4322.
I am developing using VS .NET 2003. I am running Windows
2003 Server Enterprise.
 
D

David Conorozzo

It is running impersonation with Admin priviledges. The
problem I am having here is that I can actually create
Event SOURCES but then can't actually create entries.
Don't these 2 things involve similar permissions?
-----Original Message-----
What account is your app running under? What are the permissions for this
account?

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I am able to create new sources using CreateEventSource.
I can call GetEventLogs, I can delete sources, I can see
if sources exist BUT, as soon as I try a "WriteEntry", I
get an exception:

{System.InvalidOperationException}
[System.InvalidOperationException]:
{System.InvalidOperationException}
HelpLink: Nothing
InnerException: {System.ComponentModel.Win32Exception}
Message: "Cannot open log for source {0}. You may not
have write access."
Source: "System"
StackTrace: " at
System.Diagnostics.EventLog.OpenForWrite()
at System.Diagnostics.EventLog.WriteEvent(Int32
eventID, Int16 category, EventLogEntryType type, String []
strings, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID, Int16
category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID, Int16
category)
at System.Diagnostics.EventLog.WriteEntry(String
message, EventLogEntryType type, Int32 eventID)
at FormRouter.Global.LogError(String sError) in
c:\inetpub\wwwroot\FormRouter\Global.asax.vb:line 79"
TargetSite: {System.Reflection.RuntimeMethodInfo}

The inner exception is:
{System.ComponentModel.Win32Exception}
[System.ComponentModel.Win32Exception]:
{System.ComponentModel.Win32Exception}
HelpLink: Nothing
InnerException: Nothing
Message: "Access is denied"
Source: Nothing
StackTrace: Nothing
TargetSite: Nothing




I don't quite understand. I am running .NET v.1.1.4322.
I am developing using VS .NET 2003. I am running Windows
2003 Server Enterprise.


.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top