Miscellaneous Debris

Avner Kashtan's Frustrations and Exultations

PortalRight - all wrong.

A followup to this post:

The PortalRight enumeration defined in Microsoft.Sharepoint.Portal.Security is, for some reason, derived from UInt32 rather than Int32. You can see this in the Object Browser when in a VB.NET project.
This anomaly - nothing more than a raised eyebrow in a C# project - seems to be crippling in a VB.NET project.
Whenever I try to use this enum in code, the compiler claims that it can't cast from Integer to PortalRight - even I always use the enum:

Dim acc as AreaAccessControl = new AreaAccessControl(ctx, PortalRight.ViewArea, myArea.ID)

Gives a compiler error in VB.NET, but works fine in C# - even though the second parameter is defined as PortalRight.
Casting it to UInt32 simply gives a "Can't convert UInt32 to PortalRight".
The only way I could get it to compile (didn't check if it worked) is by doing Enum.Parse on PortalRight.ViewArea.ToString(), which is just SO wrong.

Anyone know why this is so?

Posted: Aug 24 2004, 12:01 AM by AvnerK | with 3 comment(s)
Filed under: , ,

Comments

Rob said:


I am not a VB guy so this may be totally off base but I thought that the unsigned stuff wasn't supported in VB until Whidbey.

A quick google revealed a bunch of links and this one seems to confirm it.

http://www.error-bank.com/microsoft.public.dotnet.languages.vb.1/210218_Thread.aspx

Hope this helps.

rob
# August 23, 2004 7:48 PM

Miscellaneous Debris said:

I've run into several problems with the way the VB.NET compiler handles enums. I've described one here,

# July 11, 2006 4:58 AM

Quintero said:

It is appropriate time to make some plans for the future and it is time to be happy.

I've read this post and if I could I desire to suggest you some interesting things or advice. Maybe you can write next articles referring to this article. I desire to read even more things about it!

# June 14, 2012 11:10 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)