Peter's Gekko

Sponsors

The Lounge

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
CoCreateGuid .net style

For an app I needed some GUID's at runtime. In the COM days I  used the CoCreateGuid for that. In .NET it is much simpler, it is even so simple  I overlooked it and spent far to long looking for a way to import the COM stuff in my code. So let me share what I found in the help file.

The Guid class has a static meber which will get me my guid:

aanmelding.ReplyGuid = System.Guid.NewGuid().ToString();

This one-liner generates a new guid and puts it in string format into my field. That's all.

Peter


Posted 04-07-2004 9:32 AM by pvanooijen

[Advertisement]

Comments

Scott Galloway wrote re: CoCreateGuid .net style
on 04-07-2004 5:46 AM
I recently published a little code snippet which helps you do it the other way (with format validation...). You can find it here:
http://www.mostlylucid.co.uk/posts/946.aspx
Peter wrote re: CoCreateGuid .net style
on 04-07-2004 10:10 AM
Cool, I could use that to see if the guid the FCL has generated for me is valid. :>
In my case everything is valid as long as it has a high propabillity of being unique.
Jeff wrote re: CoCreateGuid .net style
on 06-09-2004 10:52 AM
What type of class do you need to declare aanmaelding as?
Peter van Ooijen wrote re: CoCreateGuid .net style
on 06-09-2004 2:57 PM
Aanmelding is a class describing a subscription appliance. I needed a unique ID for the confirmation e-mail. As subject for the mail, so its just a string.

The point was you can do with the guid whatever you like.
rohan wrote re: CoCreateGuid .net style
on 03-19-2008 6:24 AM

thanks dude. I also started to import files, but it occured to me to just first google it, and I got your post!

you did save my time

Add a Comment

(required)  
(optional)
(required)  
Remember Me?