Code
-------------------
using System;
using System.Runtime. InteropServices ;
using System.Runtime. CompilerService s;
namespace DEMONS
{
[ComVisible(fals e)]
public delegate void TestEventHandle r();
[InterfaceType(C omInterfaceType .InterfaceIsIDi spatch)]
public interface ControlEvents
{
//[DispIdAttribute (0x60020000)]
void OnBeforeStartTe st();
}
[
ClassInterface( ClassInterfaceT ype.AutoDispatc h),
ComSourceInterf aces(typeof(Con trolEvents))
]
public class Demo
{
public event TestEventHandle r OnBeforeStartTe st;
public void TEST()
{
Console.WriteLi ne("TEST()");
if (OnBeforeStartT est != null)
OnBeforeStartTe st();
}
}
}
-------------------
VBS:
sub OnTest2()
msgbox "VBSCRIPT OnTest"
end sub
sub obj_OnBeforeSta rtMigration()
msgbox "VBSCRIPT OnTest"
end sub
set obj = createobject("D EMONS.Demo")
set obj.OnBeforeSta rtTest = GetRef("OnTest2 ")
obj.TEST
--------------------------------
obj.TEST works fine (if to comment upper string). But when I leave i
uncommented i receive
Microsoft VBScript runtime error: Object doesn't support this propert
or method: 'obj.OnBeforeSt artTest'
Whats wrong to my code - VBS and .NET
+----------------------------------------------------------------
| Attachment filename: eventsforcom.zi p
|Download attachment:
http://www.codecomments.com/attachme...postid=1081328
+----------------------------------------------------------------
-
senglor
-----------------------------------------------------------------------
Posted via
http://www.codecomments.co
-----------------------------------------------------------------------