[IronPython] Type.GetType returns None
J. Merrill
jvm_cop at spamcop.net
Sat Mar 10 17:13:25 CET 2007
Those aren't comparable statements. If you had passed "String" (in quotes) in your C# I think that would have worked, but "string" should not -- the Type.GetType(string) overload is defined as a case-sensitive search, and in general wants an "assembly qualified name".
http://msdn2.microsoft.com/en-us/library/system.type.assemblyqualifiedname.aspx
Perhaps all would be fine in pure IP if you had just used Type.GetType(String) or String.GetType(); I'm away and not easily able to try it myself.
I would guess that the cause is that Python's "string" type (lowercase without the quotes) is not the same as .Net's "String" type (mixed case without quotes).
At 09:48 AM 3/10/2007, Michael Foord wrote
>Michael Foord wrote:
>> Hello all,
>>
>> Why does "Type.GetType(string)" return None from IronPython ?
>>
>> I need to use it with names like "Console", "int" and "string" -
>> fetching the .NET type objects. I guess this is because of the reflected
>> types ? Do I have an alternative that will work ? (other than stub C#).
>>
>Interesting - even with the following C# called from IronPython it
>returns None. The code I am translating is from the MSDN docs. Any clues ?
>
>namespace SimpleTest
>{
> public class SimpleTest
> {
> public static Type getType(string typename){
> return Type.GetType(typename);
> }
>}
>
>Michael Foord
>http://www.voidspace.org.uk/ironpython/
J. Merrill / Analytical Software Corp
More information about the Ironpython-users
mailing list