Answered by:
When is a GUID not a GUID?

Question
-
User68971474 posted
[edited]
I want a GUID, and can't seem to make one!
My code should convert a string to a GUID; but the resulting GUID is always empty.
Here's my code with an actual GUID string that fails:
Private _userGuid As String = "d5774e1e-b3c4-4f2f-9d1e-c2d9e03df61d"
Private _gGuid As Guid
_gGuid = New Guid(_userGuid)
...
Stopping on the next line, I examine _gGuid, and it's Empty.
Saturday, August 30, 2008 1:56 PM
Answers
-
User1564875471 posted
Yes , The new Guid will looks empty in debug , but its not !
You can get its value by calling its .ToString() method ,
dim GuidValue as string= YourGuidInstance.ToString()
You can also use the GuidGen tool which generate a guids string for you ,
to add the tool to vs , go to Tools->Eternal Tools -> Add ,
for the command value use : C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\guidgen.exe
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, August 30, 2008 2:39 PM
All replies
-
User1564875471 posted
_gGuid = New Guid(_userGuidStr)i think you have o change that line to :
_gGuid = New Guid(_strGuidStr)
Saturday, August 30, 2008 2:16 PM -
User68971474 posted
Thank you, Anas. I fixed my post above; my editing was bad.
Anyway, I thought maybe the Guid string was case-sensitive. So I forced it to uppcase with .ToUpper.
Still not working. What's the mystery here?
Saturday, August 30, 2008 2:28 PM -
User68971474 posted
I don't get any exceptions either. Just an empty Guid.
Saturday, August 30, 2008 2:33 PM -
User1564875471 posted
Yes , The new Guid will looks empty in debug , but its not !
You can get its value by calling its .ToString() method ,
dim GuidValue as string= YourGuidInstance.ToString()
You can also use the GuidGen tool which generate a guids string for you ,
to add the tool to vs , go to Tools->Eternal Tools -> Add ,
for the command value use : C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\guidgen.exe
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, August 30, 2008 2:39 PM -
User68971474 posted
The new Guid looks empty in Debug?!
Ok, I can accept that.
My Guid comes from column userId in table aspnet_Users, so generating them will not help in this case.
Thank you
Saturday, August 30, 2008 2:58 PM