event from c# dll not fired from excel VBA call -
i have dll written in c# , code work on dev pc.
[guid("a125ae08-682e-46cb-9a9e-52dd70021d80")] [comvisible(true), interfacetype(cominterfacetype.interfaceisidispatch)] public interface imyevents { [dispid(1)] void onevent(); } [guid("fb9be25d-5012-44d7-8d66-221c3343e19e")] [comvisible(true), interfacetype(cominterfacetype.interfaceisidispatch)] public interface imyclass { [dispid(2)] int sum(int x, int y); [dispid(3)] void starttimer(); } [guid("bd40af0a-ac44-4ffe-88a7-9bd4f77a9790")] [comvisible(true)] [classinterface(classinterfacetype.none)] [comsourceinterfaces(typeof(imyevents), typeof(imyclass))] public sealed class testforvba:imyclass, imyevents { public delegate void timerevent(); public event timerevent onevent; public int sum(int x, int y) { return x + y; } void imyevents.onevent() { } public void starttimer() { timer t = new timer(); t.interval = 5000; t.elapsed += (s, a) => { onevent?.invoke(); }; t.start(); } }
dll , com registered use regasm.exe , call excel vba
public withevents b testforvba private sub b_onevent() msgbox "event left fired" end sub private sub commandbutton1_click() set b = createobject("testforvba") msgbox b.sum(5, 10) msgbox "timers event fire starting..." call b.starttimer end sub
all code (c# , vba) work on dev pc when copy excel file , dll user pc , run vba code see message b.sum(5, 10) message fired event didn't display.
Comments
Post a Comment