What is the necessity for the GUID attribute? why don’t just let the compiler handle this automatically?!
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the compiler handled this automatically, you’d end up with one of two situations.
A new GUID every time you compiled – since GUIDs are supposed to be published, this would fail.
Collisions – if the GUID was the same every time, based on (say) a Hash of the name, multiple projects would end up using the same GUID for different purposes.
The existing approach – an explicit GUID gives developers the power to control these as required.
You only actually need to add a GUID attribute in limited cases – the primary one being for COM interop, if you’re using .NET to write a COM object for use by another system. Depending on what kind of project you have, this might be an everyday event – or an annual one.