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

Dino Viehland dinov at microsoft.com
Thu Feb 19 09:38:07 PST 2009

Generally what you'd do is:

import clr
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.

> -----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.
> Ernesto Cullen
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

More information about the Users mailing list