none
C# interpreter wihout dynamics or generation of new assemblies RRS feed

  • Question

  • Hi all,

    I need to implement an interpreter that should be added to a framework able to support the execution of scripting language. Most of components of framework must be injected in the scripting context allowing to manipulate the application using scripting.

    The invokes comes from multiple concurrent clients and potentially the scripting may be updated without the need to restart the server. The preferred scripting language is C#.

    Roslyn is not a good solution as it creates a real assemblies (byte code) for each compile or at least I was not able to force Roslyn as interpreter and not as compiler. After 2000/3000 calls, the application throws an "out of memory" exception and the service crashes. I have tried to reuse the generated assemblies until a new script version is available, but in a real production environment many new script could be added.

    I have seen Jint intepreter that seems matching my request but it is Javascript language and it does not support the out parameters of existing framework methods that should used inside the scripting code.

    Any suggestions is appreciated to address the right interpreter.

    Maurizio Romano

    Saturday, February 17, 2018 10:00 AM

All replies

  • Take a look at CSX. Never used it myself but that is what is designed for.

    Also, you can work around the memory issue by having the scripts run in a separate appdomain. For sandboxing purposes it is probably a better option anyway. Of course then you have to get into marshalling objects but that is how most scripting libraries work.


    Michael Taylor http://www.michaeltaylorp3.net

    Monday, February 19, 2018 5:20 PM
    Moderator
  • Thanks. I'll give a look to the suggested library.

    Maurizio.

    Tuesday, February 20, 2018 8:45 AM
  • Unfortunately there is no source code in the suggested article, so I'm yet searching for a library to interpreter C# code able to execute thousands of scripting without finishing the available memory.

    Maurizio

    Monday, February 26, 2018 12:13 AM
  • Hi Maurizio,

    What source code do you want? Please provide more details about it. If you want to the source code of .net framework(the C# library), you could refer to the Reference Source.

    The article provided by CoolDadTx is very nice about script. Please have a look.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 2, 2018 6:04 AM
    Moderator