0

I'm new to IronPython but have been using Python for many years. I inherited some C# applications and would like to access some of their classes via Python. Given the following C#:

namespace Updater {
    static class Program {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() {
            //Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault( false );
            Application.Run( new Form1() );
        }
    }
}

When I import in Python:

>>> clr.AddReferenceToFile('Updater.exe')
>>> import Updater
>>> dir(Updater)
['Form1']

Why isn't Program visible?

Kenny
  • 675
  • 10
  • 24

1 Answers1

2

The default visibility to classes in C# is internal, so IronPython won't show the Program class. See https://stackoverflow.com/a/3763638/129592 for more info.

You can fix it by changing the class declaration to

public static class Program {
    // etc.
}
Community
  • 1
  • 1
Jeff Hardy
  • 7,632
  • 24
  • 24