I'm trying to build a COM DLL that will be consumed by several clients.
for that purpose, I have 2 clients.
the WPF app will call the Publish method of the COM DLL, which in turn will raise an event, and the Console App which is subscribed to this event will respond.
the event is static.
COM DLL
[Guid("EAA4976A-45C3-4BC5-BC0B-E474F4C3C83F"), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IComListen
{
[DispId(2)]
string Publish();
[DispId(1)]
string Version();
}
[Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71"), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IListenerEvents
{
void Ack();
}
public delegate void AckDelegate();
[Guid("0D53A3E8-E51A-49C7-944E-E72A2064F938"), ClassInterface(ClassInterfaceType.None), ComSourceInterfaces(typeof(IListenerEvents))]
public class Listen : IComListen
{
public static event AckDelegate Ack;
public string Publish()
{
Ack();
return "This message should be published";
}
public string Version()
{
return "0.050";
}
}
the WPF App:
private void Button_Click(object sender, RoutedEventArgs e)
{
var listener = new Listen();
listener.Publish();
}
the Console App:
private static void Main(string[] args)
{
Listen.Ack += Listen_Ack;
while (true)
{
}
}
private static void Listen_Ack()
{
throw new NotImplementedException();
}
the current state is that Ack() inside the Publish() method in the COM DLL is null...
You are trying to handle an event which was triggered from another application. I think you have to use one of these protocols:
AMQP
STOMP
MQTT
AMQP 1.0
HTTP
See Handle events from another application
and https://www.codeproject.com/Articles/5830/Using-MSMQ-from-C
and my recommendation is: https://www.rabbitmq.com/tutorials/tutorial-one-dotnet.html
RabbitMQ can be and is used in Enterprise Applications to handle Events between Microservices. Alternative to this would be Apache Kafka.