Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > step through .py file in a .NET application written in C# in Visual Studio

Reply
Thread Tools

step through .py file in a .NET application written in C# in Visual Studio

 
 
Bo
Guest
Posts: n/a
 
      08-06-2007
Hello All,

I am experimenting IronPython in Visual Studio. Here is what I have,
what I did and what I want

1. I have installed Visual Studio SDK 4.0 according to this blog
http://blogs.msdn.com/aaronmar/archi...ronpython.aspx

If I run Visual Studio under Experimental Hive, a Python file opened
is color coded.

2. Also, my computer has apparently installed some IronPython DLL
because my Visual Studio can recoginize the following class:
IronPython.Hosting.PythonEngine.

If I declare something like the following in Visual Studio:

public static class MyPythonClass {
private static IronPython.Hosting.PythonEngine MY_ENGINE;
//suppose I have created an instance of PhythonEngine and assigned
to MY_ENGINE
............
}

If I do "Go to Definition" of PythonEngine, I can navigate to the
Definition of PythonEngine, but it is from MetaData.

3. In my .NET application (written in C#) , I can invoke the
execution of an external python file using something like:
MyPythonClass.MY_ENGINE.ExecuteFile("myPythonFileW ithAbsolutePath.py")

The python file (myPythonFileWithAbsolutePath.py) can be executed all
right, but I want to step through it to debug it. Any suggestions on
how to do it?

Thanks a bunch.

Bo

 
Reply With Quote
 
 
 
 
Paul McGuire
Guest
Posts: n/a
 
      08-07-2007
On Aug 6, 5:22 pm, Bo <(E-Mail Removed)> wrote:
> Hello All,
>
> I am experimenting IronPython in Visual Studio. Here is what I have,
> what I did and what I want
>
> 1. I have installed Visual Studio SDK 4.0 according to this bloghttp://blogs.msdn.com/aaronmar/archive/2006/02/16/a-bit-more-on-ironp...
>
> If I run Visual Studio under Experimental Hive, a Python file opened
> is color coded.
>
> 2. Also, my computer has apparently installed some IronPython DLL
> because my Visual Studio can recoginize the following class:
> IronPython.Hosting.PythonEngine.
>
> If I declare something like the following in Visual Studio:
>
> public static class MyPythonClass {
> private static IronPython.Hosting.PythonEngine MY_ENGINE;
> //suppose I have created an instance of PhythonEngine and assigned
> to MY_ENGINE
> ............
>
> }
>
> If I do "Go to Definition" of PythonEngine, I can navigate to the
> Definition of PythonEngine, but it is from MetaData.
>
> 3. In my .NET application (written in C#) , I can invoke the
> execution of an external python file using something like:
> MyPythonClass.MY_ENGINE.ExecuteFile("myPythonFileW ithAbsolutePath.py")
>
> The python file (myPythonFileWithAbsolutePath.py) can be executed all
> right, but I want to step through it to debug it. Any suggestions on
> how to do it?
>
> Thanks a bunch.
>
> Bo


Um, make sure you compile with debug?

I have coded in Boo, which is very Python-like, and it will step
through the debugger just fine, so IP should do the same in theory.
But I've not used IP, so all I can give are generic "are you sure it's
plugged in?" type of suggestions.

Hmm, upon rereading your post, I see that you want the debugger to
step through a separate file that was executed using ExecuteFile.
Unless there are some debug options on ExecuteFile, I'd say your
chances are slim, since the file being executed is not really part of
the image being debugged. You could also try explicitly invoking the
debugger from within the file that you are loading, using (this works
from Boo):

System.Diagnostics.Debugger.Launch()
System.Diagnostics.Debugger.Break()


-- Paul

 
Reply With Quote
 
 
 
 
jingwu.mail@gmail.com
Guest
Posts: n/a
 
      08-08-2007
On Aug 7, 9:24 am, Paul McGuire <(E-Mail Removed)> wrote:
> On Aug 6, 5:22 pm, Bo <(E-Mail Removed)> wrote:
>
>
>
> > Hello All,

>
> > I am experimenting IronPython in Visual Studio. Here is what I have,
> > what I did and what I want

>
> > 1. I have installed Visual Studio SDK 4.0 according to thisbloghttp://blogs.msdn.com/aaronmar/archive/2006/02/16/a-bit-more-on-ironp...

>
> > If I run Visual Studio under Experimental Hive, aPythonfile opened
> > is color coded.

>
> > 2. Also, my computer has apparently installed some IronPython DLL
> > because my Visual Studio can recoginize the following class:
> > IronPython.Hosting.PythonEngine.

>
> > If I declare something like the following in Visual Studio:

>
> > public static class MyPythonClass {
> > private static IronPython.Hosting.PythonEngine MY_ENGINE;
> > //suppose I have created an instance of PhythonEngine and assigned
> > to MY_ENGINE
> > ............

>
> > }

>
> > If I do "Go to Definition" of PythonEngine, I can navigate to the
> > Definition of PythonEngine, but it is from MetaData.

>
> > 3. In my .NET application (written in C#) , I can invoke the
> > execution of an externalpythonfile using something like:
> > MyPythonClass.MY_ENGINE.ExecuteFile("myPythonFileW ithAbsolutePath.py")

>
> > Thepythonfile (myPythonFileWithAbsolutePath.py) can be executed all
> > right, but I want to step through it to debug it. Any suggestions on
> > how to do it?

>
> > Thanks abunch.

>
> > Bo

>
> Um, make sure you compile with debug?
>
> I have coded in Boo, which is veryPython-like, and it will step
> through the debugger just fine, so IP should do the same in theory.
> But I've not used IP, so all I can give are generic "are you sure it's
> plugged in?" type of suggestions.
>
> Hmm, upon rereading your post, I see that you want the debugger to
> step through a separate file that was executed using ExecuteFile.
> Unless there are some debug options on ExecuteFile, I'd say your
> chances are slim, since the file being executed is not really part of
> the image being debugged. You could also try explicitly invoking the
> debugger from within the file that you are loading, using (this works
> from Boo):
>
> System.Diagnostics.Debugger.Launch()
> System.Diagnostics.Debugger.Break()
>
> -- Paul



Thanks Paul, for giving me the suggestions. I will try your
suggestion.

I have been struggling with the most of today. Here is a summary of
what I have found. May be useful to other

1. My IronPython DLL is version 1.1. It is download here
http://www.codeplex.com/Wiki/View.as...ame=IronPython

2. Apparently, there is a problem with either the ipy.exe or
IronPython.DLL that one cannot step into a function (F11 in visual
studio). Here is the discussion
http://lists.ironpython.com/pipermai...ay/004957.html

I am not sure if this is related to my case.

3. Here is Jim Hugunin's presentation
http://msdn.microsoft.com/msdntv/epi...H/manifest.xml

Apparently, he can step through the external ironpython file in an C#
application. He probably used an old version of Iron Python. The
method he used to execute the external iron python file is
Engine.Runfile()


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic tutorial for beginners explained step by step ali Computer Support 0 05-10-2007 06:23 AM
Visual Step by Step guide for setting up Wi Fi connection =?Utf-8?B?RXNraW1vc291bmQ=?= Wireless Networking 5 11-26-2006 07:57 PM
Step by step: Compiling extensions with MS Visual C++ Toolkit 2003 - msvccompiler-patch.txt (0/1) Martin Bless Python 8 03-18-2005 10:11 PM
Need sample files from MS Access/Visual Basic Step by Step krfb Microsoft Certification 1 10-17-2003 11:31 PM
Replacing CMOS battery - need visual Step-By-Step Ed Computer Support 17 09-25-2003 07:47 PM



Advertisments