2

I can use ironpython 2.6 (not for .net 4) load numpy, running ipy with -X:Frames or -X:FullFrames on the command line.

But, if I want to use Ironpython/DLR in C# 2.0 to load the py file, how can I use -X:Frames or -X:FullFrames?

I tried it like this:

        var lang = Python.CreateLanguageSetup(null);
        lang.Options["Frames"] = ScriptingRuntimeHelpers.True;
        var setup = new ScriptRuntimeSetup();
        setup.LanguageSetups.Add(lang);
        var runtime = new ScriptRuntime(setup); 
        var engine = runtime.GetEngine("py");

        engine.ExecuteFile("test.py");  

But, it didn't work! So, is there anyone can give me a hand?

Begtostudy
  • 1,374
  • 4
  • 13
  • 28

2 Answers2

1

I don't think frames working or not working is your problem. If I take your code and put:

import sys
sys._getframe()

into test.py it works if I have the 'lang.Options["Frames"] = ScriptingRuntimeHelpers.True;' line and fails if I don't. That indicates the option is working fine.

So what is the error you're getting? It might be that you need to set something which the command line normally does - such as sys.path which maybe needs the current directory and/or ".". Or maybe site.py needs to be imported. Or maybe IronClad is installed in the DLLs directory and auto-loaded so you need to do runtime.LoadAssembly(...) on it's DLL.

Dino Viehland
  • 6,478
  • 20
  • 25
  • I tred sys._getframe() and it's OK, and running ipy console with -X:Frames is also ok. Only load py by ironpython in C# 2.0. I uploaded my code (Visual studio 2010 solution, but .net 2.0 project):http://1oz7ga.blu.livefilestore.com/y1pbhO4fRA4M7KUlnk0Oi19-dTmSUhRdj2rQ6tguLebK829d9WykIUoc3vQEvuhlkhFU6xIT_cCOXjGB9TOMo064a-Qzcb4gbea/ex_vs10_cs%20load%20ipy%20ironclad.rar?download&psid=1 – Begtostudy Jul 01 '10 at 06:16
  • You should change "*.rar_" to "*.rar" of the file name. – Begtostudy Jul 01 '10 at 06:20
0

Your question looks similar to this one: Can't import numpy into embedded ironpython engine

But, maybe you should give more info about what errors you got...

Community
  • 1
  • 1
digEmAll
  • 56,430
  • 9
  • 115
  • 140