I am using ZeroMQ with combination of clrzmq and libzmq dll files.
I have included these files in my windows service project and it was working fine in simple windows PC. Now I moved service to Windows Server 2012 machine where I installed service with administrator rights and trying to start ZMQ server. All attempts to start server are getting failed with below error.
My Code
public void InitializeServer()
{
using (var context = ZmqContext.Create())
{
using (var socket = context.CreateSocket(SocketType.REP))
{
HelperMethods.WriteLog(string.Format("server started at: {0}", serverAddress));
socket.Bind(serverAddress);
while (true)
{
lock (_lock)
{
try
{
var rcvdMsg = socket.Receive(Encoding.UTF8);
HelperMethods.WriteLog("New event received. ");
var replyMsg = "Acknowledged event.";
HelperMethods.WriteLog(replyMsg);
socket.Send(replyMsg, Encoding.UTF8);
HelperMethods.WriteLog("=====================================================");
}
catch (Exception ex)
{
HelperMethods.WriteLog("InitializeServer(): " + ex.Message + " | Stack Trace: " + ex.StackTrace);
}
}
}
}
}
ERROR:
The type initializer for 'ZeroMQ.Interop.LibZmq' threw an exception. | at ZeroMQ.Interop.ContextProxy.Initialize() in C:\clrzmq\zeromq-clrzmq-v3.0.0-beta1-52-g0d83a1e\zeromq-clrzmq-0d83a1e\src\ZeroMQ\Interop\ContextProxy.cs:line 28 at ZeroMQ.ZmqContext.Create() in C:\clrzmq\zeromq-clrzmq-v3.0.0-beta1-52-g0d83a1e\zeromq-clrzmq-0d83a1e\src\ZeroMQ\ZmqContext.cs:line 78
What I have tried so far
- I have installed C++ redistributable package.
- I have disabled firewall and added service exe inbound and outbound rules
- I have installed .NET Framework 4.6.2