1

Fixed

crash when used on OSX

description

comments

olsonjeffery wrote Mar 28, 2011 at 12:11 AM

I went and created a new c# console project and added the same code, pasted above, into the body of the Main() method.. running it with mono provided the following output:

before creating pub/sub

Unhandled Exception: System.InvalidOperationException: Operation is not valid due to the current state of the object
at System.Collections.Generic.LinkedList`1+Enumerator[ZeroMQ.ZmqSocket].get_Current () [0x00000] in :0
at ZeroMQ.ZmqSocket.Schedule () [0x00000] in :0
at System.Threading.Thread.StartUnsafe () [0x00000] in :0
bash-3.2$

AlexForster wrote May 22, 2011 at 5:44 PM

I think this had to do with an Assert() in the polling code that didn't need to be there. Try with the latest release.

pboles wrote Aug 9, 2011 at 11:26 PM

Compiling libzmq on mac for use with mono. I just downloaded the beta version of Monodevelop 2.6.3 and it only compiles my project in x86 despite me being on a x86_64 machine. To fix you need to make sure you have a 32 bit version of your lib.
./configure CFLAGS="-O -arch i386" CXXFLAGS="-O -arch i386" LDFLAGS="-arch i386" --disable-dependency-tracking --prefix=/usr/local/lib/

You need to make sure the --prefix=/usr/local/lib is in your DYLD_LIBRARY_PATH
MAC: export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH



using System;
using ZeroMQ;

namespace testZMQ
{
class MainClass
{
    public static void Main (string[] args)
    {

            Console.WriteLine("before creating pub/sub");
            // define connection address
            String address = "tcp://127.0.0.1:9292";

            // set up publisher
            var publisher = new ZeroMQ.ZmqPublishSocket {
                Identity = Guid.NewGuid().ToByteArray(),
                RecoverySeconds = 10
            };
            Console.WriteLine("after instantiating publisher");

            // bind to address
            publisher.Bind(address);

            // publisher is now read to publish
            Console.WriteLine("after publisher.Bind()");

            // set up subscriber
            var subscriber = new ZmqSubscribeSocket();
            Console.WriteLine("after instantiating subscriber");

            // connect to publisher
            subscriber.Connect(address);

            // do not filter anything send it all
                subscriber.Subscribe("");
            Console.WriteLine("after creating pub/sub");

            // publisher message
            publisher.Send("pow");

            // receive message
            string data;
            subscriber.Receive(out data);

            // do work on data
            Console.WriteLine(data);
    }
}
}