[IronPython] Question about using IronPython in C#

葉信源 iapyeh at gmail.com
Fri Apr 6 11:47:40 CEST 2007


As a C+ newbie.
I am tring to write the MSN add-in in C# and use IronPython (Python, my
favorite) actually.
The following code can be compiled successfully (in VC# Studio).
But it fails to be imported to be Messenger Add-in.
The problem happens to create PythonEngine in Initialize().
Any Hints?
Thanks in advance.

iap

=================================================================================
using System;
using Microsoft.Messenger;
using IronPython.Hosting;
namespace MyAddIn
{
    public class AddIn: IMessengerAddIn
    {
        MessengerClient _mclient = null;
        public void Initialize(MessengerClient mclient){
            PythonEngine engine = new PythonEngine(); // If this line
disabled, to be imported in Messenger will be fine.
            _mclient = mclient;
            _mclient.AddInProperties.FriendlyName = "My Bot 2";
            _mclient.AddInProperties.Creator = "My Name";
            _mclient.AddInProperties.Description = "Bot for testing";
            _mclient.AddInProperties.Url = new Uri(http://www.google.com);
            _mclient.IncomingTextMessage += new
EventHandler<IncomingTextMessageEventArgs>(IncomingTextMessageHandler);
        }
        void IncomingTextMessageHandler(object
sender,IncomingTextMessageEventArgs args){
            _mclient.SendTextMessage("What you said:"+args.TextMessage,
args.UserFrom);
        }
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070406/fda2cc39/attachment.html>


More information about the Ironpython-users mailing list