locked
NewComb uniqueness violation RRS feed

  • Question

  • User-150770710 posted

    Hi

    I am using NewComb to generate GUID in my web application. The key is used for activity log, which any action taken by user would be recorded.

    I just hit error of uniqueness violation when deploy to customer. The # of access is high but should be extremely high. Any ideas how could it happen? 

    Thank you

    Monday, May 9, 2011 5:31 AM

Answers

  • User-578657687 posted

    Hi,

    To reproduce this issue is difficult, I suggest you to use “GUID.NewGuid”, like the code snippet below:

    // This code example demonstrates the Guid.NewGuid() method.
    
    using System;
    
    class Sample 
    {
        public static void Main() 
        {
        Guid g;
    // Create and display the value of two GUIDs.
        g = Guid.NewGuid();
        Console.WriteLine(g);
        Console.WriteLine(Guid.NewGuid());
        }
    }
    
    /*
    This code example produces the following results:
    
    0f8fad5b-d9cb-469f-a165-70867728950e
    7c9e6679-7425-40de-944b-e07fc1f90ae7
    
    */
    

    Also, you can use GUID Generation to create GUID, this tutorial demonstrates how to use it.<o:p></o:p>

    <o:p> </o:p>

    For more information about GUID Structure please look at the following link:<o:p></o:p>

    http://msdn.microsoft.com/en-us/library/cey1zx63(v=VS.80).aspx<o:p></o:p>

    http://msdn.microsoft.com/en-US/library/system.guid_members(v=VS.80).aspx <o:p></o:p>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 13, 2011 5:28 AM

All replies

  • User-2131369213 posted

     

    The odds for that are astronomical. Either there is a bug or you just won the jackpot of the galaxy. :-)

     

    just use    Guid test = Guid.NewGuid();

     

    Tuesday, May 10, 2011 8:54 AM
  • User-150770710 posted

    Hi

    I use NewComb is to have sequential GUID.

    I don't think I won jackpot, because it hit so frequent especially in peak hours.

    Wednesday, May 11, 2011 9:00 PM
  • User-578657687 posted

    Hi,

    To reproduce this issue is difficult, I suggest you to use “GUID.NewGuid”, like the code snippet below:

    // This code example demonstrates the Guid.NewGuid() method.
    
    using System;
    
    class Sample 
    {
        public static void Main() 
        {
        Guid g;
    // Create and display the value of two GUIDs.
        g = Guid.NewGuid();
        Console.WriteLine(g);
        Console.WriteLine(Guid.NewGuid());
        }
    }
    
    /*
    This code example produces the following results:
    
    0f8fad5b-d9cb-469f-a165-70867728950e
    7c9e6679-7425-40de-944b-e07fc1f90ae7
    
    */
    

    Also, you can use GUID Generation to create GUID, this tutorial demonstrates how to use it.<o:p></o:p>

    <o:p> </o:p>

    For more information about GUID Structure please look at the following link:<o:p></o:p>

    http://msdn.microsoft.com/en-us/library/cey1zx63(v=VS.80).aspx<o:p></o:p>

    http://msdn.microsoft.com/en-US/library/system.guid_members(v=VS.80).aspx <o:p></o:p>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 13, 2011 5:28 AM