2012-01-05 54 views
0

我是IronPython的新手,但已经使用Python很多年了。我继承了一些C#应用程序,并希望通过Python访问他们的一些类。下面的C#:IronPython静态程序类可见性

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()); 
     } 
    } 
} 

当我导入的Python:

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

为什么没有程序的可视性?

回答

2

C#中类的默认可见性为internal,所以IronPython不会显示Program类。有关更多信息,请参阅https://stackoverflow.com/a/3763638/129592

您可以通过更改类声明

public static class Program { 
    // etc. 
} 
修复