Creating a Unique ID

Posted on 2007-10-10
Medium Priority
Last Modified: 2010-04-15
I am looking for advice or solution for creating a Unique ID. Basically I need to record a transaction id whenever my SOAP applications shake hands and I was unsure as to the best solution.

Previously I had just used an int, and bumped it up every time the handshake was made, but perhaps there is a better method like GUID?

Anyone got any ideas, or examples
Question by:directxBOB
  • 3
  • 2
LVL 16

Accepted Solution

McExp earned 1000 total points
ID: 20048920
You got it in one a GUID is waht you want!


Assisted Solution

Dorfer32 earned 1000 total points
ID: 20048971
GUIDs are wonderful, and C# makes generating new ones easy:

Guid id = Guid.NewGuid();

With things like ints you may run into issues where multiple clients counters are not synchronized or restarting the client restarts the counter which causes values to reuse.  Using GUIDs avoids these issues as the generation routine is random not sequential, so it is extremely unlikely you would ever get a duplicate id.

Author Comment

ID: 20049346
So there is no requirement to track what ID was last used because they are random?
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 16

Expert Comment

ID: 20049391
Yes, that is correct

Author Comment

ID: 20049399
Also given that a GUID is a 128bit integer I assume I can cast it to an int for general usage?
LVL 16

Expert Comment

ID: 20049447
Guess so, It's not something I've ever had cause to do.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question