Forum Discussion

Inotdead's avatar
Inotdead
New Contributor
13 years ago

.NET Assembly events

Hello,

I have a simple .NET assembly which contains an event which looks like this:



public delegate void myEventHandler(string s);


public static event myEventHandler myEvent;




Is it possible to script a listener to this or any event?

If yes, where can I find a tutorial?
  • Anton,


    TestComplete can handle events of external ActiveX objects (COM servers). As for managed events, you cannot create script handlers for them, unless the tested application is a COM server.


    A possible workaround is to create a C# handler for the event in your assembly and then, from within this handler, call the needed TestComplete script or test. If you are using a Connected Application, you can run a TestComplete test by using the Connect.RunTest method. If you don't use a Connected Application, you can connect to and work with TestComplete via COM.

  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Anton,


    TestComplete can handle events of external ActiveX objects (COM servers). As for managed events, you cannot create script handlers for them, unless the tested application is a COM server.


    A possible workaround is to create a C# handler for the event in your assembly and then, from within this handler, call the needed TestComplete script or test. If you are using a Connected Application, you can run a TestComplete test by using the Connect.RunTest method. If you don't use a Connected Application, you can connect to and work with TestComplete via COM.

  • Inotdead's avatar
    Inotdead
    New Contributor
    A bit of additional info:



    I'm using C# (Visual Studio 2008) and TC 8.60.665.7 (JScript as script language)

    CLR Bridge settings are 32-Bit and Multi-threaded apartment.



    Another error I'm getting is that sometimes tcHostingProcess stops working after a couple of events were raised even if there were no listeners at all. TC doesn't log this error and I only notice it when I try to call another assembly function.