<div dir="ltr"><div>It sounds like you were already doing what I was suggesting trying. The "full framework" version is what you get when you install using the MSI. The zip file in releases link contains the .NET Core version of the interpreter but like I said it doesn't support CompileModule.<br><br></div><div>
I think you may be out of luck on this since there's currently no way to compile the code for .NET Core and the assembly generated using full .NET doesn't work...<br></div><div><br></div><div>Stéphane<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 4, 2018 at 1:38 PM, Josiah Kiehl <span dir="ltr"><<a href="mailto:jkiehl@riotgames.com" target="_blank">jkiehl@riotgames.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Oh! I understand now, thanks for clarifying. Yes, that's the problem. You mentioned that there is a "full framework" version I could compile my dlls with? I poked around the releases and I wasn't sure what you were referencing, specifically.<div><br></div><div>I installed via the 2.7.8 msi from here: <a href="https://github.com/IronLanguages/ironpython2/releases" target="_blank">https://github.com/<wbr>IronLanguages/ironpython2/<wbr>releases</a>. Is there a release with dotnet core or can I build one?<br><div><br></div><div>I did notice that I can't compile via running the compile script in the embedded IronPython in dotnet core, as CompileModule is not supported.</div><div><br></div><div>Thanks so much for answering my questions, this is extremely helpful.</div><div>Josiah<br><br><div class="gmail_quote"><div dir="ltr">On Wed, Apr 4, 2018, 6:16 AM 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="ltr"><div>I assumed you were using .NET Core when you said you were using dotnet 2.0.3. So you are compiling using ipy.exe (which is a .NET 4.5 app) and then using the assembly from a .NET Core 2.0 application?
The .NET Core API doesn't expose System.Runtime.<wbr>CompilerServices.Closure so that might be the reason things are failing...<br><br></div></div><div dir="ltr">Stéphane<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 3, 2018 at 5:53 PM, Josiah Kiehl <span dir="ltr"><<a href="mailto:jkiehl@riotgames.com" target="_blank">jkiehl@riotgames.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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.<wbr>dll", "test.py")</font></div><div><br></div><div>This works just fine.</div><div><br class="m_-2364573188181677361m_-7365801118264451593m_-3385468049869424747m_3608916085308959151m_-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(<wbr>Assembly.LoadFile(@"C:\some\<wbr>path\compiled.dll"));</font></div><div><span style="font-family:monospace">var scope = engine.Runtime.ImportModule("<wbr>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/<wbr>questions/32639893/call-dll-<wbr>function-from-c-sharp-<wbr>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.<wbr>CompilerServices.Closure' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=<wbr>b77a5c561934e089'.</div><div>  at DLRCachedCode.test$1(<wbr>CodeContext $globalContext, FunctionCode $functionCode)</div><div>  at IronPython.Compiler.<wbr>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.<wbr>com/capoferro/<wbr>5a730088582b8cd36591be510d6ca2<wbr>fc</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">
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/ironpython-<wbr>users</a><br>
</blockquote></div></div></div>
</blockquote></div></div></div>
</blockquote></div><br></div>
</blockquote></div></div></div></div>
</blockquote></div><br></div>