Guid not working?

  • Thread starter Thread starter Razzie
  • Start date Start date
R

Razzie

Hey all,

I need to add a Guid to my class. In a tutorial I saw this was easy:

[Guid("16369924-5F32-4E26-AE89-8308B5C162E2")]
class someClass
{ ... }

However, I get the error "The type or namespace name 'Guid' could not be
found (are you missing a using directive or an assembly reference?)"
I'm doing it exactly the same way as in the tutorial but apparantly I'm the
only one having troubles with it. I'm using the System namespace in which
the Guid class is, but even if I use [System.Guid("xxx-etc")] it's not
working. Am I doing something wrong? And I don't have the 'Create Guid' in
the Tools menu either every website is talking about.

I hope someone can clear this up for me.

Thanks,

Razzie
 
Hi Razzie,

You are actually applying an atttribute to someClass. When you do so, the
attribute name you use actually refers to an Attribute type. In your case,
you are really referring to the GuidAttribute attribute type which exists in
the System.Runtime.InteropServices namespace. Add a using statement for this
namespace in your source file.

HTH,
Rakesh
 
GuidAttribute is in System.Runtime.InteropServices namespace. So, have
'using System.Runtime.InteropServices;' in your code.

Hey all,

I need to add a Guid to my class. In a tutorial I saw this was easy:

[Guid("16369924-5F32-4E26-AE89-8308B5C162E2")]
class someClass
{ ... }

However, I get the error "The type or namespace name 'Guid' could not be
found (are you missing a using directive or an assembly reference?)"
I'm doing it exactly the same way as in the tutorial but apparantly I'm the
only one having troubles with it. I'm using the System namespace in which
the Guid class is, but even if I use [System.Guid("xxx-etc")] it's not
working. Am I doing something wrong? And I don't have the 'Create Guid' in
the Tools menu either every website is talking about.

I hope someone can clear this up for me.

Thanks,

Razzie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top