[Python.NET] Question about RunString

Nader Akhnoukh iamnader at gmail.com
Sat Oct 28 00:26:55 CEST 2006


I have a very simple script, message.py:

from CLR.System.Windows.Forms import MessageBox
MessageBox.Show("hello");

If I run this from the console it works fine and I see the MessageBox.

However, if I embed PythonNet in my .Net 1.1 C# app, Python loads correctly,
no exceptions are thrown, but I don't see the MessageBox.

This is the C# code:

        PythonEngine.Initialize();

        IntPtr state = PythonEngine.AcquireLock();

        StreamReader sr = File.OpenText("C:/message.py");
        string pythoncode = sr.ReadToEnd();
        sr.Close();

        PythonEngine.RunString(pythoncode);

        PythonEngine.ReleaseLock(state);


Any idea what's going on?

Thanks,
n
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythondotnet/attachments/20061027/b5de689f/attachment.htm 


More information about the PythonDotNet mailing list