EventLog.DeleteEventSource Fails on Partial Match

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating custom event logs using VS.Net 2002 on DNR 1.0.
I created an event log named "RDBMS". I create event sources for that log
named "R", "RD", "RDB", "RDBM", and "RDBMS" (the last gets created by
default.)
When I try to remove ANY of these event sources I get an error like the
following:

"System.InvalidOperationException: The event log source 'RD' can not be
deleted, because it's equal to the log name.
at System.Diagnostics.EventLog.DeleteEventSource(String source, String
machineName)
at EVS.frmEVSMain.DeleteSource(String SourceName, String Machine,
EventSourceList& Sources) in C:\...\Form1.vb:line 1111"

HResult = -2146233079

Does anyone know a workaround for this bug or do I have to hack the registry?
 
From: "=?Utf-8?B?RG9uYWxkIFdlbGtlcg==?="
<Donald.WelkerN0$SPAM@N0$SPAM.navy.mil>
|
| I am creating custom event logs using VS.Net 2002 on DNR 1.0.
| I created an event log named "RDBMS". I create event sources for that
log
| named "R", "RD", "RDB", "RDBM", and "RDBMS" (the last gets created by
| default.)
| When I try to remove ANY of these event sources I get an error like the
| following:
|
| "System.InvalidOperationException: The event log source 'RD' can not be
| deleted, because it's equal to the log name.
| at System.Diagnostics.EventLog.DeleteEventSource(String source, String
| machineName)
| at EVS.frmEVSMain.DeleteSource(String SourceName, String Machine,
| EventSourceList& Sources) in C:\...\Form1.vb:line 1111"
|
| HResult = -2146233079
|
| Does anyone know a workaround for this bug or do I have to hack the
registry?

The exception is thrown correctly for the final, default, source. You
can't delete a source that's equal to the log name. You can delete the
event log with EventLog.Delete.

The fact that you get this exception for the other sources is a bug in v1.0
of the Framework that was fixed in v1.1. DeleteEventSource was checking
for a substring of the log name rather than the entire log name.

The only workaround I can think of is "don't create (or at least don't try
to delete) event sources that are substrings of an event log name." If
that doesn't work for you, then, yeah, I think you'll have to delete the
sources manually from the registry.

Katy
CLR Test
 
Thanks Katy. I confirmed last night that the problem doesn't happen with
1.1. Are you aware of any utilities for moving event sources between custom
logs (or to/from a custom log and the Application log?)
 
From: "=?Utf-8?B?RG9uYWxkIFdlbGtlcg==?="
<Donald.WelkerN0$SPAM@N0$SPAM.navy.mil>

No, I'm afraid I don't know of any.

Katy

| Thanks Katy. I confirmed last night that the problem doesn't happen with
| 1.1. Are you aware of any utilities for moving event sources between
custom
| logs (or to/from a custom log and the Application log?)
|
| "Katy King" wrote:
|
| > From: "=?Utf-8?B?RG9uYWxkIFdlbGtlcg==?="
| > <Donald.WelkerN0$SPAM@N0$SPAM.navy.mil>
| > |
| > | I am creating custom event logs using VS.Net 2002 on DNR 1.0.
| > | I created an event log named "RDBMS". I create event sources for
that
| > log
| > | named "R", "RD", "RDB", "RDBM", and "RDBMS" (the last gets created by
| > | default.)
| > | When I try to remove ANY of these event sources I get an error like
the
| > | following:
| > |
| > | "System.InvalidOperationException: The event log source 'RD' can not
be
| > | deleted, because it's equal to the log name.
| > | at System.Diagnostics.EventLog.DeleteEventSource(String source,
String
| > | machineName)
| > | at EVS.frmEVSMain.DeleteSource(String SourceName, String Machine,
| > | EventSourceList& Sources) in C:\...\Form1.vb:line 1111"
| > |
| > | HResult = -2146233079
| > |
| > | Does anyone know a workaround for this bug or do I have to hack the
| > registry?
| >
| > The exception is thrown correctly for the final, default, source. You
| > can't delete a source that's equal to the log name. You can delete the
| > event log with EventLog.Delete.
| >
| > The fact that you get this exception for the other sources is a bug in
v1.0
| > of the Framework that was fixed in v1.1. DeleteEventSource was
checking
| > for a substring of the log name rather than the entire log name.
| >
| > The only workaround I can think of is "don't create (or at least don't
try
| > to delete) event sources that are substrings of an event log name." If
| > that doesn't work for you, then, yeah, I think you'll have to delete
the
| > sources manually from the registry.
| >
| > Katy
| > CLR Test
| >
| >
|
 
Back
Top