http://osherove.com/blog/2004/2/17/make-your-net-application-support-scripting-a-practical-appr.html
I studied up and created a sample application, but the VBScript code was not able to see my object. I kept getting InvalidCastException whenever I tried to add my custom object using ScriptControl.AddObject. Using information from the above articles, and some trial and error, I was able to figure out the following requirements:
- Your object (and its methods/properties) needs to be public
- Your process must be an x86 process (COM Interop doesn't work well in x64)
- The assembly containing your class must be registered for COM interop (which means it must be a class library ... you cannot define the class within an executable and have it work)
With these requirements correctly implemented, the ScriptControl works well and can interact with my .NET object.
No comments:
Post a Comment