Help me get started with hosting

May 12, 2011 at 8:13 PM

I would like to add DLR scripting to an application but I'm a little lost as to where to start.

1. dlr.codeplex.com does not include binaries and is version 2.6.1 of IronPython. 

2. ironpython.codepex.com is more recent but does not provide examples of how to implement hosing.

There is no documentation of how to configure ScriptRuntime other than to read from a .config file.  I modified the sample app.config to reference the new version of IronPython (type="IronPython.Runtime.PythonContext, IronPython, Version=2.7.0.40, Culture=neutral, PublicKeyToken=null").  The hosting sample "ShapeScript" throws an exception when it tries to get the engine:

            _runtime = new ScriptRuntimeScriptRuntimeSetup.ReadConfiguration(configFile));
            _engine = _runtime.GetEngine("py");

Exception: Could not load file or assembly 'IronPython, Version=2.7.0.40, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Sadly, to my eye the specification does appear to match the 2.7 IronPython.dll but I admit that I'm not very familiar with .net assemblies.  I do have dynamic loading of assemblies working in another part of my application.  So I'm stuck here.

What should I do?  Persist in getting this working?  What is wrong with my reference to the IronPython DLL?  Should I back up and complie DLR 1.0 and use that?  I don't want to compile year old sources.  I want to use a recent binary distribution. 

Thanks,

Tom

May 12, 2011 at 8:44 PM

Looks like that config is for a non-signed version of IronPython, so it definitely wouldn't work if you installed an IronPython release. Look at ipy.exe.config from your IronPython installation and make sure it matches what is in the config you're trying to load. 

You can also try "_engine = IronPython.Hosting.Python.CreateEngine();" instead to avoid loading from a config.

But what exact sample are you trying to run? We can fix it if the checked in version is broken.

Note that http://github.com/IronLanguages/main is where the latest IronPython/IronRuby sources are.

~Jimmy

May 13, 2011 at 1:05 AM

Thanks for the quick response.  I've downloaded sources from github.  I didn't want to install git just to get the sources so I used the "download" feature and I got IronLanguages-main-ipy-2.7-40-gece5b9e.zip.  But then I looked at other download options and saw a version 1.1.3 and got:  IronLanguages-main-v1.1.3-0-g93ce72d.zip.  These actually look like different versions of the same source. The 1.1.3 version is not too old so I don't think it is the same version scheme that 2.7 comes from.  DLR versioning?  Anyway, that's what I've downloaded.  But both are still the source and I hope to not have to build from source.  I just want to use this.  I don't know how either one relates to the binary distribution of IronPython 2.7.

Looking at the app.config files that came with each version I see:

ipy-2.7 -> IronPython 3.0, version=3.0.0.0

1.1.3 -> IronPython 2.7 RC 2, version=2.7.0.40

Yep, ipy-2.7 is more recent.  In fact, it looks like it is the beginning of the next version?  Well, anyway, I appear to have version 2.7 installed.  In fact, Info on my installed IronPython.dll says it is version 2.7.0.40.

I know that for people involved in the project all these version numbers make sense but to an outsider to me it is not clear and there is very little information on either codeplex or github to direct me. 

So I copied the config XML from signed/app.config to my application's config.

      <language names="IronPython;Python;py" extensions=".py" displayName="IronPython 2.7 RC 2" type="IronPython.Runtime.PythonContext, IronPython, Version=2.7.0.40, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

But my application still will not run.  Same exception as before. 

 

> Look at ipy.exe.config from your IronPython installation and make sure it matches what is in the config you're trying to load.

There is no file named ipy.exe.config in my IronPythong installation :(

> You can also try "_engine = IronPython.Hosting.Python.CreateEngine();" instead to avoid loading from a config.

I don't want to explicitly instantiate an IronPython engine because I do want the option to support other languages.

>But what exact sample are you trying to run? We can fix it if the checked in version is broken.

I'm working with the "ShapeScript" Example from DLR 1.0 from here. I know it is old it compiles and the code that is throwing the exception looks correct.

Is there a more modern example?

Thanks,

Tom

 

 

May 16, 2011 at 1:21 PM

Hey Tom, I did a talk on IronPython hosting at CodeMash in January 2011.

The slides and code are at http://devjourney.com/blog/embedding-ironpython-talk-at-codemash-2011/.

Try loading up that project and running it. Be sure to drop the IPy and MS scripting refs and re-add them.

Perhaps that example will help you get going.

Kevin Hazzard
http://devjourney.com