How do I get started designing and implementing a script interface for my .NET application?

后端 未结 8 768
礼貌的吻别
礼貌的吻别 2021-01-30 13:47

How do I get started designing and implementing a script interface for my .NET application?

There is VSTA (the .NET equivalent of VBA for COM), but as far as I understan

相关标签:
8条回答
  • 2021-01-30 14:22

    The Lua scripting language is free, used in a large number of commercial applications, and is easily embeddable into a .NET application using the freely-available LuaInterface library, which permits you to expose types and methods from your application that scripts in your embedded interpreter can leverage.

    A tutorial on how to embed Lua into a C# application can be found here.

    Edit: It's probably also worth noting that Lua was designed from the ground up to be an embedded scripting language, and as a result, the interpreter is highly customizable. The host application can restrict almost any aspect of the interpretation capabilities as part of the security model; e.g. allowing or preventing scripts from making network connections or writing to files, etc.

    Also, you asked about external scripts. Making your program available to out-of-process scripts is done in the same way you make it available to out-of-process applications: by exposing a standardized automation interface through some sort of communication protocol. On Windows, for same-machine cross-process communication, that will most commonly be COM, but it could also be WCF, TCP remoting, RPC or any number of other communications standards. What you choose to do depends heavily on how your application is built and what kind of external automation you intend for it to do.

    0 讨论(0)
  • 2021-01-30 14:28

    I would suggest you consider the Dynamic Language Runtime as a strategy for implementing a scripting interface. Details:

    • CodePlex DLR site
    • MSDN .NET 4 DLR Overview

    The DLR currently supports IronPython and IronRuby, plus a number of other language implementations can be found on CodePlex. If you are interested in creating a language specific to your application Bitwise Magazine has a good primer article.

    Dino Viehland's PDC09 session Using Dynamic Languages to Build Scriptable Applications is worth watching. You can find the demo code here.

    0 讨论(0)
提交回复
热议问题