Monday, October 20, 2008

Using ActiveScript in Managed Code

I recently was involved in porting a legacy COM application to a .NET version of the application. The application made heavy use of VBScript through the ActiveScript interfaces for customization. The customers current user base was large enough that one of the requirements was to continue to support existing scripts in the field. So interfacing with ActiveScript via .NET was a must. I set out to find a library that already did this, but all I really found were pieces here and there on how to kind of implement it. I played around for a while and finally came up with a good implementation. It even supports adding your own .NET objects to the script. I was able to get rid of all the COM objects and port the entire object model to .NET. The only COM in the new application is the ActiveScript stuff. There are some advantages to using ActiveScript still. For one it doesn’t compile an in memory assembly that you can’t get rid of. If you want to get rid of your compiled in memory assemblies in .NET you have to put them in a separate application domain and unload it, which can be tricky depending on the complexity of your application.

I’m posting the entire ActiveScript libaray including source code on CodePlex for anyone to use free of charge. There is a basic sample included with it that demonstrates how to use the library. It’s actually pretty simple. In future blog entries I will write more on how to use it. For now I wanted to get it out there for others to use. Hopefully it will save some of you some time and hassle. If you find the code useful and decide to use it drop me a line.

The source code (written in C#) can be found here on CodePlex.