IObservable含糊不清的参考错误 [英] IObservable ambiguous reference error

查看:110
本文介绍了IObservable含糊不清的参考错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WPF应用程序中使用了Reactive扩展.而且在使用它时,我遇到了模棱两可的参考错误.

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

我也尝试使用完全限定的名称,并尝试了解决方案

引用IObservable时,要么使用

System.Reactive.IObservable<T>

System.IObservable<T>

更新>>>

嗯,既然您已经添加了图片,我就看到了您的问题.您有两个System.IObservable类...那些反应性家伙是什么白痴!

无论如何,看看这些帖子:

如何可以在2个不同的DLL中访问具有完全限定名称的类型

外部别名演练

这不是很漂亮,但它可以为您提供帮助.

I'm using Reactive extensions in my WPF application. And while using it I'm getting below ambiguous reference error.

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

I tried with fully qualified name also and tried this url as well, but didn't get any luck. I'm using .NET 4.0 version of Reactive Extensions.

My Code:

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

Any idea how can i resolve this?

Thanks

解决方案

When you reference IObservable, either use

System.Reactive.IObservable<T>

or

System.IObservable<T>

UPDATE>>>

Ahhhh, now that you've added the image, I see your problem. You have two System.IObservable classes... what idiots those Reactive guys are!

Anyway, take a look at these posts:

How to access a type with same fully qualified name in 2 different DLLs

Extern alias walkthrough

It's not pretty, but it should help you.

这篇关于IObservable含糊不清的参考错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆