parse enum trouble

  • Thread starter Thread starter Chance Hopkins
  • Start date Start date
C

Chance Hopkins

//1-Problem

I am trying to do the following in the compactframework:

public enum MyEnum : int{ONE = 1}

MyEnum myName =
(MyEnum)System.ComponentModel.TypeDescriptor.GetConverter(typeof(MyEnum)).ConvertFromString("ONE");

//2-Solution one
I was given this link as a solution:

Take a look at the EnumEx.Parse method within the SDF
(www.opennetcf.org/sdf/)
It's described here:
http://www.opennetcf.org/library/OpenNETCF.EnumEx.Parse_overloads.html

//3-New Problem

The problem is, this code generates an error when I try to parse:

MyEnum e = (MyEnum )OpenNETCF.Parse(typeof(MyEnum ),"ONE",true);

----------------------------
Application.exe
MissingMethodException
Method not found: ToObject
System.Enum, mscorlib,
Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=969DB8053D3322AC

Application::Run+0xf
Form1::Main+0xa

----------------------------

"ToObject" is called inside the OpenNetCF.Parse method and works on the
desktop framework.

//4-Question
Does my enum require some type of interface or override that I am not aware
of?

Thanks, if you took the time to make it this far.
 
Ensure that you have the latest OpenNETCF.dll, this code works fine:

public enum MyEnum : int {ONE = 1}
....
MyEnum e = (MyEnum)OpenNETCF.EnumEx.Parse(typeof(MyEnum), "ONE", true);


Best regards,
Sergey Bogdanov
 
You where right, the problem was something else.

Sergey Bogdanov said:
Ensure that you have the latest OpenNETCF.dll, this code works fine:

public enum MyEnum : int {ONE = 1}
...
MyEnum e = (MyEnum)OpenNETCF.EnumEx.Parse(typeof(MyEnum), "ONE", true);


Best regards,
Sergey Bogdanov
 
Back
Top