Script
Using a scripting engine in your application can greatly enhance the flexibility and scalability of your program, similar to MS Office and VS. NET's macro function. Microsoft. NET Framework, the script engine framework is defined in Microsoft.vsa.dll, while Microsoft.Visualbase.vsa.dll defines the scripting engine that implements VBA. Using these two DLLs, you can define your own vba.net scripting engine.
Some framework interfaces are defined in Microsoft.vsa.dll, where the more important interfaces include
IVsaEngine for scripting engine interfaces, all scripting engines use this interface
Ivsasite script engine Communication interface, script engine accepts this interface to post some information
Ivsaitem Project for scripting engine-related resources
Ivsacodeitem for scripting code modules
Ivsarefrenceitem external Reference object used for the scripting engine
Ivsaglobalitem the Global object module used for the scripting engine
Use procedures typically instantiate a script engine, pass the Ivsasite object to the script engine object, and then add references, code text, and global objects using the CreateItem method of the engine's items. Then call the compile method to compile the script engine and use Run to start the engine.
After the script engine is started, a assembly assembly is dynamically generated and loaded according to the script code in the current application domain, using ivsaengine.assembly to access dynamically generated assemblies.
Microsoft.VisualBase.vsa.dll implements these interfaces and implements a scripting engine based on the vba.net syntax.
The main object is Vsaengine
This program provides a C # written demo program, using Microsoft. NET Framework 1.1, the demo program provides a general-purpose module that uses the scripting engine, which makes it easy to use the VBA scripting engine to extend your application.