I'm trying to learn Python.NET module, but at the very beginning I face some problems.
I'm trying to execute this simple code:
import clr
clr.AddReference("System")
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
import System
import System.Drawing
import System.Windows.Forms
class FormLogin(System.Windows.Forms.Form):
def __init__(self):
pass
def main():
System.Windows.Forms.Application.Run(FormLogin())
if __name__ == "__main__":
main()
Unfortunately, this exception is raised:
Traceback (most recent call last):
File "C:\Users\MyUser\Desktop\Test\APP.py", line 21, in <module>
main()
File "C:\Users\MyUser\Desktop\Test\APP.py", line 18, in main
System.Windows.Forms.Application.Run(FormLogin())
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.Form.get_IsMdiChild()
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
Does anyone know how to fix this?