0

Using a project that targets .Net 4.5, I have a section of code that does this

public static IObservable<string> Receive(SubscriberSocket subp)
{
    return Observable
        .Create<string>(o =>
            Observable.Using<string, SubscriberSocket>(() =>
            {
                subp.Connect("inproc://test");
                subp.Subscribe("");
                return subp;
            }, sub =>
                Observable.FromEventPattern<EventHandler<NetMQSocketEventArgs>, NetMQSocketEventArgs>(
                    h => sub.ReceiveReady += h,
                    h => sub.ReceiveReady -= h)
                .Select(x => sub.ReceiveString()))
        .Subscribe(o));
}

However, it complains that I need System.Reactive.Interfaces, Version=3.0.0.0 even though that assembly has been added into the project?

/home/idf/Documents/csharp/NetMQObs/TestNetMQ/TestNetMQ/Program.cs(25,25): Error CS0012: The type 'IQbservable<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Reactive.Interfaces, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263'. (CS0012) (TestNetMQ)

After adding the 2.2.5 versions as suggested below, now I get this error. Changing the call to ReceiveFrameString compiles, but YMMV.

/home/idf/Documents/csharp/NetMQObs/TestNetMQ/TestNetMQ/Program.cs(42,42): Error CS1061: 'SubscriberSocket' does not contain a definition for 'ReceiveString' and no extension method 'ReceiveString' accepting a first argument of type 'SubscriberSocket' could be found (are you missing a using directive or an assembly reference?) (CS1061) (TestNetMQ)
Enigmativity
  • 113,464
  • 11
  • 89
  • 172
Ivan
  • 7,448
  • 14
  • 69
  • 134
  • 1
    Just a side note - this implementation is bad - you'll end up disposing your `SubscriberSocket` when the first subscription terminates. Why are you passing in `SubscriberSocket subp`? – Enigmativity Oct 14 '17 at 04:59
  • 1
    It also looks like NetMQ uses Rx-Core 2.2.5 and Rx-Interfaces 2.2.5. Perhaps that's causing you grief? Can you try those versions? – Enigmativity Oct 14 '17 at 05:01
  • @Richard.Schneider - `IQbservable` is the correct type here for this error. I've rolled back your edit. – Enigmativity Oct 14 '17 at 06:31
  • @Enigmativity the 2.2.5 suggestion helps. However now I get a new error. See the edit in the end of the post. Since this is bad design on my part, how do you suggest I modify it? I will open a new question. – Ivan Oct 14 '17 at 19:12
  • @Enigmativity see this new post: https://stackoverflow.com/questions/46748396/how-to-avoid-disposing-socket – Ivan Oct 14 '17 at 19:16
  • To everyone - please don't edit the title - `IQservable` is the correct type, not `IObservable`. This is the same distinction as `IQueryable` versus `IEnumerable`. – Enigmativity Oct 14 '17 at 22:43

1 Answers1

0

It also looks like NetMQ uses Rx-Core 2.2.5 and Rx-Interfaces 2.2.5.

By putting in the wrong library (Version=3.0.0.0) you are causing this error.

Enigmativity
  • 113,464
  • 11
  • 89
  • 172