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?

Published Tuesday, August 24, 2004 12:01 AM by AvnerK

Filed under: , ,

Comments

# re: PortalRight - all wrong.@ Monday, August 23, 2004 7:48 PM


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

Rob

# VB.NET and Enums@ Tuesday, July 11, 2006 4:58 AM

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

Miscellaneous Debris

Leave a Comment

(required) 
(required) 
(optional)
(required)