using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
namespace DEMONS
{
[ComVisible(false)]
public delegate void TestEventHandler();
[InterfaceType(ComInterfaceType.InterfaceIsIDispatc h)]
public interface ControlEvents
{
//[DispIdAttribute(0x60020000)]
void OnBeforeStartTest();
}
[
ClassInterface(ClassInterfaceType.AutoDispatch),
ComSourceInterfaces(typeof(ControlEvents))
]
public class Demo
{
public event TestEventHandler OnBeforeStartTest;
public void TEST()
{
Console.WriteLine("TEST()");
if (OnBeforeStartTest != null)
OnBeforeStartTest();
}
}
}
VBS:
[code:1:d720d2858a]
sub OnTest2()
msgbox "VBSCRIPT OnTest"
end sub
sub obj_OnBeforeStartMigration()
msgbox "VBSCRIPT OnTest"
end sub
set obj = createobject("DEMONS.Demo")
set obj.OnBeforeStartTest = GetRef("OnTest2")
obj.TEST
[/code:1:d720d2858a]
obj.TEST works fine (if to comment upper string). But when I leave it
uncommented i receive
Microsoft VBScript runtime error: Object doesn't support this property
or method: 'obj.OnBeforeStartTest'
Whats wrong to my code - VBS and .NET?
*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*