When trying to access an enum
, called Monsters, from another class, Visual Studio gives me the error "The type or namespace name 'Monsters' could not be found (are you missing a using directive or an assembly reference?)", despite having an associated using
in my class.
Here is my enum code:
namespace Zadify.Enums
{
public enum Monsters
{
Zombie,
Skeleton,
Mummy,
Robot,
Demon
}
}
And here is my class I need to access it from:
using System;
using System.Xml.Serialization;
using Zadify.Enums;
namespace Zadify
{
[Serializable]
public abstract class Goal
{
//Properties, Other methods
public void AssignMonsterData(int rank)
{
var random = new Random();
var monsterTypeValues = Enum.GetValues(typeof (Monsters)); //Gives the error on "Monsters" here
var monster = (Monsters) monsterTypeValues.GetValue(random.Next(rank - 1)); //Also gives the error on this "Monsters"
//Do other stuff
}
I later do a switch
on monster
, and it seems to be fine with every time I use Monsters.Zombie
, Monsters.Skeleton
, etc. I also have several other enums
in Zadify.Enums
that all work fine, and, in fact, I use the exact same code on them in this class.
So far I have tried changing the enum's namespace
and adding a using
to that new namespace
, copying Monsters
into another file, cleaning the project, and rebuilding a hundred times. I'm using Visual Studio 2010 and writing a Mono for Android app, though there is no Android code in these classes.
Visual Studio doesn't seem to have a problem until I build. Beforehand, intellisense works fine, if I take out the using Zadify.Enums;
line, it asks if that's what I want to reference, and ctrl+clicking it brings me to the proper file.
If there is any other code I should provide, let me know.