Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6977673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:39:21+00:00 2026-05-27T17:39:21+00:00

Public Enum ERight ECanInvite = 0 ECanCreate = 1 ECanDelete = 2 etc… End

  • 0
  Public Enum ERight
    ECanInvite = 0
    ECanCreate = 1
    ECanDelete = 2
    etc...
  End Enum


  Public Enum EUserType
    EAdministrator = 0
    EPartner_level1 = 1
    EPartner_level2 = 2
    ENormalUser = 3
    ...etc
  End Enum

This below sub, on rights.add, sometimes throws this error: An item with the same key has already been added.

How is this even possible?

Private Shared rights As Dictionary(Of ws_garuda.EUserType, List(Of ERight)) = Nothing

Private Sub initRoles()
    rights = New Dictionary(Of EUserType, List(Of ERight))
    rights.Clear()
    ' Set all rights to false for all roles
    For Each usertype As EUserType In DirectCast([Enum].GetValues(GetType(EUserType)), EUserType())
      rights.Add(usertype, New List(Of ERight))
    Next
End sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:39:22+00:00Added an answer on May 27, 2026 at 5:39 pm

    The error is happening because you’re writing a Shared object in a multithreaded environment.

    The fix is to add a lock (in which case the call to Clear() becomes redundant):

    Private Shared rights As Dictionary(Of ws_garuda.EUserType, List(Of ERight)) = Nothing
    Private Shared rightsLock As Object = New Object()
    
    Private Sub initRoles()
      SyncLock rightsLock
        rights = New Dictionary(Of EUserType, List(Of ERight))
        ' Set all rights to false for all roles
        For Each usertype As EUserType In DirectCast([Enum].GetValues(GetType(EUserType)), EUserType())
          rights.Add(usertype, New List(Of ERight))
        Next
      End SyncLock
    End sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public enum myEnum { VAL1(10), VAL2(20), VAL3(hai) { public Object getValue() { return this.strVal;
Public Enum Fruit Red_Apple = 1 Oranges Ripe_Banana End Enum Private Sub InitCombosRegular() Dim
I have enum like this [Flags] public enum Key { None = 0, A
For example: public enum Unit{ KW, kV, V, Hz, %V } In this case
I have this enumeration public enum LightFiles { PNG, JPG, GIF, FLV, TIF, BMP,
I have this : [Flags] public enum InfoAbonne{civilite,name,firstname,email,adress,country } public class Formulaire { private
Given this code: public enum Enum1 { ONE, TWO } public enum Enum2 {
This is my enum: public enum DocumentTypes { [EnumMember] TYPE_1 = 1, [EnumMember] TYPE_2
I have enum like this public enum PetType { Dog = 1, Cat =
Given this enum public enum UserStatus : byte { Approved = 1, Locked =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.