Exposing C# COM server events to delphi client
-
Hi everyone, I have a C# COM dll which I've add to my delphi application . I can access to its methods and properties successfully .but I cannot access to its events . this is the sample C# code that I found and used: [ComVisible(false)] public delegate void CallArrived(object sender, string callData); /// <summary> /// Interface to expose SimpleAgent events to COM /// </summary> [ComVisible(true)] [GuidAttribute("1FFBFF09-3AF0-4F06-998D-7F4B6CB978DD")] [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface IAgentEvents { ///<summary> /// Handles incoming calls from the predictive manager. ///</summary> ///<param name="sender">The class that initiated this event</param> ///<param name="callData">The data associated with the incoming call.</param> [DispId(1)] void OnCallArrived(object sender, string callData); } /// <summary> /// Represents the agent side of the system. This is usually related to UI interactions. /// </summary> [ComVisible(true)] [GuidAttribute("EF00685F-1C14-4D05-9EFA-538B3137D86C")] [ClassInterface(ClassInterfaceType.None)] [ComSourceInterfaces(typeof(IAgentEvents))] public class SimpleAgent { /// <summary> /// Occurs when a call arrives. /// </summary> public event CallArrived OnCallArrived; public SimpleAgent() {} public string AgentName { get; set; } public string CurrentPhoneNumber { get; set; } public void FireOffCall() { if (OnCallArrived != null) { OnCallArrived(this, "555-123-4567"); } } } and this is the Delphi Sample code which I used : procedure TForm1.Button1Click(Sender: TObject); var intrf : SimpleAgent; begin intrf.AgentName ('Name'); end; I'll appreciate it if anyone could show me the way to access the Event . Best Regards, Shialn
-
Hi everyone, I have a C# COM dll which I've add to my delphi application . I can access to its methods and properties successfully .but I cannot access to its events . this is the sample C# code that I found and used: [ComVisible(false)] public delegate void CallArrived(object sender, string callData); /// <summary> /// Interface to expose SimpleAgent events to COM /// </summary> [ComVisible(true)] [GuidAttribute("1FFBFF09-3AF0-4F06-998D-7F4B6CB978DD")] [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface IAgentEvents { ///<summary> /// Handles incoming calls from the predictive manager. ///</summary> ///<param name="sender">The class that initiated this event</param> ///<param name="callData">The data associated with the incoming call.</param> [DispId(1)] void OnCallArrived(object sender, string callData); } /// <summary> /// Represents the agent side of the system. This is usually related to UI interactions. /// </summary> [ComVisible(true)] [GuidAttribute("EF00685F-1C14-4D05-9EFA-538B3137D86C")] [ClassInterface(ClassInterfaceType.None)] [ComSourceInterfaces(typeof(IAgentEvents))] public class SimpleAgent { /// <summary> /// Occurs when a call arrives. /// </summary> public event CallArrived OnCallArrived; public SimpleAgent() {} public string AgentName { get; set; } public string CurrentPhoneNumber { get; set; } public void FireOffCall() { if (OnCallArrived != null) { OnCallArrived(this, "555-123-4567"); } } } and this is the Delphi Sample code which I used : procedure TForm1.Button1Click(Sender: TObject); var intrf : SimpleAgent; begin intrf.AgentName ('Name'); end; I'll appreciate it if anyone could show me the way to access the Event . Best Regards, Shialn
I'll give you a word or two of advice - you've posted this in the Delphi forum and again here - you'll get better help/assistance if you dont cross-post - pick a forum, stick with it - people will get narky if you post in more than one forum - if you get the forum wrong, people will guide you to the correct one 'g'
-
I'll give you a word or two of advice - you've posted this in the Delphi forum and again here - you'll get better help/assistance if you dont cross-post - pick a forum, stick with it - people will get narky if you post in more than one forum - if you get the forum wrong, people will guide you to the correct one 'g'
To some extent I can understand in this case. Help may come from either forum but most people who visit one probably won't visit the other.
Steve