Search Issue Tracker
Fixed in 5.0.X
Votes
6
Found in
4.3.1f1
Issue ID
585558
Regression
No
Project can not be built if it uses System.Enum.ToObject(System.Type,System.Int32)
Project can not be built if it uses System.Enum.ToObject(System.Type,System.Int32) even though is available in .NET for windows Phone 8 - http://msdn.microsoft.com/en-us/library/windowsphone/develop/k6x6b517(v=vs.105).aspx
Steps to reproduce:
1. Create a project which uses System.Enum.ToObject(System.Type,System.Int32)
2. Build an run it on Windows Phone 8
3. Error will be reported indicating that method is not available in target framework.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- “[Worker0] Could not generate preview image“ error when opening macOS native plugin in the Inspector with Architecture to build for set to ARM 64-bit
- [iOS] Application.absoluteURL is empty on Awake/Start when opening via deep link with Splash Screen disabled
- Crash on MemoryManager::Deallocate when rapidly calling Addressables.LoadAssetAsync
- Crash on physx::shdfnd::atomicIncrement when adjusting values on a character controller component after entering Play mode in Prefab edit mode
- [Rendering Debugger] [NewInputSystem] Debug Overlays in Play mode throws InvalidOperationException when using New Input System
sient
Jun 27, 2014 05:53
It looks like Enum.ToObject(System.Type, System.Object) is available *but* Enum.ToObject(System.Type, System.Int32) is not.
So changing the example from
Behavior GetTypeUsingObject(int typeValue)
{
//This won't compile
Behavior type = (Behavior)Enum.ToObject(typeof(Behavior), typeValue);
return type;
}
to
Behavior GetTypeUsingObject(int typeValue)
{
//This *will* compile
Behavior type = (Behavior)Enum.ToObject(typeof(Behavior), (object)typeValue);
return type;
}
should make it compile.
Kyle.A
May 03, 2014 22:28
Casting is an option for some uses to work around this issue.
Behavior GetTypeUsingObject(int typeValue)
{
//This won't compile
Behavior type = (Behavior)Enum.ToObject(typeof(Behavior), typeValue);
return type;
}
Behavior GetTypeCasted(int typeVale)
{
//This will
Behavior type = (Behavior)typeValue;
return type;
}
Whether this fits everybody's needs is another question.