[IronPython] how to use an enum from a hosted script

Michael Foord fuzzyman at voidspace.org.uk
Thu Feb 19 18:54:31 CET 2009


Dino Viehland wrote:
> Generally what you'd do is:
>
> import clr
> clr.AddReference('yourdll')
> from MyNamespace import NotificationTypeEnum
>
> I have no idea where the 'Imports are disabled' exception would come from though.  If you could include the actual text of the exception that might be helpful.  Also running w/ the -X:ExceptionDetail command line and sending back that stack trace might be useful as well.
>   

With IronPython hosted inside a C# application the -X:ExceptionDetail 
command line switch is likely to not be particularly useful... :-)

Michael



>   
>> -----Original Message-----
>> From: users-bounces at lists.ironpython.com [mailto:users-
>> bounces at lists.ironpython.com] On Behalf Of Ernesto Cullen
>> Sent: Thursday, February 19, 2009 9:26 AM
>> To: users at lists.ironpython.com
>> Subject: [IronPython] how to use an enum from a hosted script
>>
>> hi all,
>>     I have IronPython hosted inside a c# project, and all goes well...
>> until now when i want to use an enum c# type inside a script. For
>> instance, I have in C# this declaration:
>>
>> public enum NotificationTypeEnum {Main,Detail}
>>
>> Then in a script I want to use this enum in an assignment:
>>
>> NotifMessage('some message', NotificationTypeEnum.Main)
>>
>> Where NotifMessage is a delegate expecting a string and a
>> NotificationTypeEnum. When I try to run this script, IPy says that it
>> does not know NotificationTypeEnum. I tried to add an Import but i get
>> 'Imports are disabled'.
>> Any ideas on how to pass this enumeration to a script? I am using IPy
>> 1.1.
>>
>> TIA
>>
>> Ernesto Cullen
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>     
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   




More information about the Ironpython-users mailing list