2012-01-05 53 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. 
} 
修復