GUID isn't unique?

  • Thread starter Thread starter Brett
  • Start date Start date
B

Brett

The following is called each time an event is triggered. The generated GUID
is the same for 3 of 4 calls. Is there a way to ensure it is different for
each call?

this.PrintMessage(System.Guid.NewGuid().ToString() +
this.MessageImageFileExtension, RootImageFileDirectory + "\\" +
DateTime.Today.Month.ToString() + DateTime.Today.Year.ToString() + "\\");

Thanks,
Brett
 
for(int i=0;i<10;i++)

{

Console.WriteLine(System.Guid.NewGuid().ToString());

}

No dups. If you are somehow consistently finding dups, that would be very
interesting to many folks. Need to show more code to find this issue with
the output.
 
Hi,
Are your sure that GUID are the same Atleast 1 char should differ!!!!!!.
If whatever ur saying is true then it would be the issue of the century for
developers!!!!!
 
Here's what happens with the dups:

04dc3412-6150-43ce-80a5-a11093e6e2ec(1)
04dc3412-6150-43ce-80a5-a11093e6e2ec(2)

Isn't it Windows that's actually appending the trailing numeric in
parentheses rather than GUID?

Now that I think about it, I see what is probably happening. The above
files are JPGs. They are generated from a printer driver that prints an
image of a webpage for example The printing of a unique page occurs each
time the event is fires. If the webpage goes beyond my predefined length,
page 2 is generated as a seperate image file. It could be the printer
driver appending the numeric rather than windows. It knows which page is
being printed for the current image. To differentiate pages, it is probably
appending the numeric. I noticed this behavior when doing a stand alone
(non code) print.

In summary, I'm sure now GUID is fine. Each time the event is triggered,
which occurs after a print is complete, I get a new GUID. However, if the
printed image is larger than one page, The same GUID is used because another
is not created (no event fired). Once that currrent print completes, a new
page loads, fires the event and a new GUID is cretaed. Does that make
sense?

Thanks,
Brett
 
Back
Top