IObservable ambiguous reference error

I am using Reactive extensions in my WPF application. And when using it, I get below an ambiguous reference error.

The type 'System.IObservable<T>' exists in both 'mscorlib.dll' and 'System.Reactive.dll' 

I also tried with the full name and tried this url but got no luck. I am using the version of the tested .NET 4.0 extensions.

My code is:

 using System; // mscorlib.dll using Rx = System.Reactive; public Rx.IObservable<int> BytesReceived { get { return _bytesReceivedSubj; } } // Not valid as IObservable is in System namespace of System.Reactive. public IObservable<int> BytesReceived { get { return _bytesReceivedSubj; } } // With this I'm getting ambiguous reference error 

enter image description here

Any idea how I can solve this?

thanks

+6
source share
2 answers

When you reference IObservable , use

 System.Reactive.IObservable<T> 

or

 System.IObservable<T> 

UPDATE →>

Ahhhh, now that you have added the image, I see your problem. You have two System.IObservable classes ... what idiots for these jet guys!

Anyway, check out these posts:

How to access a type with the same full name in two different DLL files

Passing an External Alias

This is not very, but it should help you.

+5
source

When you say you are using the .Net 4 Rx version, which version of Rx are you using? 1.1 or 2.x? If you are using 2.x, you should not refer to System.Reactive, but rather to System.Reactive.Core. I suspect that you updated this project with .Net 3.5, but did not update all the necessary links. Make sure that the Rx version you are using is not for Silverlight 4 or .Net 3.5 (which did not have IObservable / IObserver in the kernel).

This might be easiest if you just delete the reactive links and bundle them nuget for you using the version of Reactive Extensions - WPF Helpers. Note. You may need to change the import for classes using Rx to import System.Reactive.Linq if you are using an older version that had extension methods in the old System.Linq namespace.

+7
source

Source: https://habr.com/ru/post/950553/


All Articles