Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Issue with DataDictionary and using enums as keys, "Cannot retrieve heap variable of type 'Int32' as type 'DataToken" #137

Open
MyroG opened this issue Jun 29, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@MyroG
Copy link

MyroG commented Jun 29, 2023

The piece of code bellow generates the error "Cannot retrieve heap variable of type 'Int32' as type 'DataToken'"

DataDictionary _dict;

// more code here that initializes the dictionary

void SomeFunction(EEnum enumVal)
{
    DataToken key = (int) enumVal;
    if (!_dict.ContainsKey(key)) //crash here
    {
    }
}

To fix it, I need to use Convert.ToInt32() instead of using a regular (int) cast, like this :

DataToken key = Convert.ToInt32(enumVal);
if (!_dict.ContainsKey(key))
@MyroG MyroG added the bug Something isn't working label Jun 29, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant