Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

Unique EventID

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
walterd - 01 Aug 2005 19:33 GMT
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.
Alphamacaroon - 01 Aug 2005 19:47 GMT
Try:

BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0);
walterd - 02 Aug 2005 11:20 GMT
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?

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
larrylard@hotmail.com - 02 Aug 2005 12:12 GMT
> Hi
>
[quoted text clipped - 6 lines]
> 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.

Signature

Larry Lard
Replies to group please

Alphamacaroon - 03 Aug 2005 23:50 GMT
Why didn't ToInt32 work? Is EventID a short? Looks like it might be.
larrylard@hotmail.com - 04 Aug 2005 14:00 GMT
> 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.

Signature

Larry Lard
Replies to group please

Alphamacaroon - 04 Aug 2005 21:42 GMT
I agree. If this is true, then yes I would also agree that the
uniqueness of a UInt16 is pretty spotty.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.