<div dir="ltr"><div>Sorry if I'm not understanding... when you say "full framework version", do you mean the stand alone executable, ipy.exe?</div><div><br></div>I compiled the dll with ipy.exe running a simple script:<div><br></div><div><font face="monospace">> ipy compile.py</font><br><div><div><br></div><div><font face="monospace"># compile.py</font></div><div><font face="monospace">import clr</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">clr.CompileModules("compiled.dll", "test.py")</font></div><div><br></div><div>This works just fine.</div><div><br class="m_-3826548449641085982inbox-inbox-Apple-interchange-newline">Then I tried to load "compiled.dll" via the embedded IronPython in a simple dotnet CLI app and it produces the above error:</div><div><div><font face="monospace"><br></font></div><div><font face="monospace">ScriptEngine engine = Python.CreateEngine();</font></div><div><font face="monospace">engine.Runtime.LoadAssembly(Assembly.LoadFile(@"C:\some\path\compiled.dll"));</font></div><div><span style="font-family:monospace">var scope = engine.Runtime.ImportModule("test");</span><br></div></div><div><br></div></div><div>Is that what's not supported? Loading the dll in the embedded IronPython?</div><div><br></div><div>Thanks for your help, I am super hopeful I can get this working.</div><div>Josiah</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Apr 3, 2018 at 2:39 PM Stéphane Lozier <<a href="mailto:stephane.lozier@gmail.com" target="_blank">stephane.lozier@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>The .NET Core version of IronPython does not support assembly generation. I haven't tried it myself, but you could probably compile the assembly using the full framework version and then run it with .NET Core 2.0 (assuming you're not using unsupported APIs).</div><div dir="auto"><div dir="auto"><br></div><div dir="auto">Stéphane</div><br><br><div class="gmail_quote" dir="auto"></div></div></div><div dir="auto"><div dir="auto"><div class="gmail_quote" dir="auto"><div dir="ltr">On Tue, Apr 3, 2018, 5:16 PM Josiah Kiehl, <<a href="mailto:jkiehl@riotgames.com" target="_blank">jkiehl@riotgames.com</a>> wrote:<br></div></div></div></div><div dir="auto"><div dir="auto"><div class="gmail_quote" dir="auto"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Oh, I'm on dotnet 2.0.3, if that's relevant information.</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Apr 3, 2018 at 2:15 PM Josiah Kiehl <<a href="mailto:jkiehl@riotgames.com" rel="noreferrer" target="_blank">jkiehl@riotgames.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I'm trying to execute this example code:<div><a href="https://stackoverflow.com/questions/32639893/call-dll-function-from-c-sharp-ironpython" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/32639893/call-dll-function-from-c-sharp-ironpython</a><br></div><div><br></div><div>I realize the posted question is a few years old at this point... has something changed in how python, compiled to a DLL via clr.CompileModule, is loaded?</div><div><br></div><div>I'm getting this error when I run the code in the example at the above link:</div><div><div>Unhandled Exception: System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.Closure' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.</div><div>   at DLRCachedCode.test$1(CodeContext $globalContext, FunctionCode $functionCode)</div><div>   at IronPython.Compiler.OnDiskScriptCode.Run()</div></div><div><br></div><div>(full stack: <a href="https://gist.github.com/capoferro/5a730088582b8cd36591be510d6ca2fc" rel="noreferrer" target="_blank">https://gist.github.com/capoferro/5a730088582b8cd36591be510d6ca2fc</a>)</div><div><br></div><div>My ipy.exe, which did the compilation, is 2.7.8.0 and my embedded IronPython is 2.7.8.1, though I get the same error on 2.7.8.0.</div><div><br></div><div>Am I missing something obvious or is there a better example to use?</div><div><br></div><div>My end goal is to be able to take a python module defined in a file (foo.py) with some functions defined, compile it into a dll via CompileModule, then load it directly from the dll via ImportModule to skip the performance hit of interpreting the Python at runtime.</div><div><br></div><div>Thanks!</div></div><div dir="ltr"><div>Josiah</div><div><br></div><div><br></div></div></blockquote></div></blockquote></div></div></div><div dir="auto"><div dir="auto"><div class="gmail_quote" dir="auto"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
_______________________________________________<br>
Ironpython-users mailing list<br>
<a href="mailto:Ironpython-users@python.org" rel="noreferrer" target="_blank">Ironpython-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/ironpython-users" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/ironpython-users</a><br>
</blockquote></div></div></div>
</blockquote></div></div></div>