Unique EventID

  • Thread starter Thread starter walterd
  • Start date Start date
W

walterd

Hi

Has anyone implemented a unique number generator for the EventLog EventID?
I need to populate the EventID since I have an application that reads the
EventLog.

Any help is highly appreciated.
 
Hi

I get the following error when I use
BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0);

An unhandled exception of type 'System.ArgumentException' occurred in
system.dll

Additional information: Invalid eventID value '1296869646'. It must be
in the range between '0' and '65535'.

Are there any companies out there that actually write to the EventLog
using unique EventID's?
 
walterd said:
Hi

I get the following error when I use
BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0);

An unhandled exception of type 'System.ArgumentException' occurred in
system.dll

Additional information: Invalid eventID value '1296869646'. It must be
in the range between '0' and '65535'.

I think Alphamacaroon meant to say
BitConverter.ToInt16(Guid.NewGuid().ToByteArray(), 0)

But:
Are there any companies out there that actually write to the EventLog
using unique EventID's?

I don't know. Bear in mind that there's a limit to how unique a value
in 0..65535 can be. Not that the above technique of taking the first
two bytes of a new GUID might not work, depending on the GUID
generation mechanism.
 
Alphamacaroon said:
Why didn't ToInt32 work? Is EventID a short? Looks like it might be.

Actually, given that the error was
Additional information: Invalid eventID value '1296869646'. It must be
in the range between '0' and '65535'.

it looks like it wants a UInt16, not just an Int16 as my correction
suggested.
 
I agree. If this is true, then yes I would also agree that the
uniqueness of a UInt16 is pretty spotty.
 
Back
Top