Groups | Blog | Home
all groups > dotnet vsa > july 2004 >

dotnet vsa : Direct Access to VSA project Assembly


joerg NO[at]SPAM krause.net
7/1/2004 5:50:54 AM
Hi,

I've a VSA implementation and I'm able to invoke any method in
my script.

Now I want to hook up event handler in the code from an external
event source.

Normally I use this:

EventInfo eInfo = this.MyForm.GetType().GetEvent("EventName");
Delegate d = Delegate.CreateDelegate(eInfo, this, "Button_Click");
eInfo.AddEventHandler(this, d);

"this" points to the class where "Button_Click" is available.
This works very well.

No I want the event handler, defined in my VSA script.

EventInfo eInfo = this.MyForm.GetType().GetEvent("EventName");
Delegate d = Delegate.CreateDelegate(eInfo, MyVSA, "Button_Click");
eInfo.AddEventHandler(MyVSA, d);

Question: How to get MyVSA?

object MyVSA = vsaEngine.Assembly.INeedAMethodLike_GetRunningInstance();

Any ideas? Or is there any other way to hook up script methods
as event handlers for the host application?

Thank you,

bruce barker
7/1/2004 11:05:57 AM
you have only loaded code in the vsa engine. there are no class instances
until you code creates one. if you used vb script, and a module, you have
created static methods for which there is no instance. you can create a
class in script instead and create an instance of this class.

if you want to stick with static metods the common approach is you create
your own delegate for the event, and it uses reflection to find a method to
call in vsa.

-- bruce (sqlwork.com)



[quoted text, click to view]

AddThis Social Bookmark Button