带有 IObservable 的 MethodCallExpression 向 System.CoreEx 抛出访问被拒绝异常
我有一个 MethodCallExpression
对象,我尝试使用 Reactive Extensions
框架从该对象返回一个 IObservable
实例。
private IObservable<Thing> GetThing(Expression<Func<Thing>> expression)
{
Func<Thing> method = expression.Compile()
var observable = Observable.FromAsyncPattern<Thing>(method.BeginInvoke, method.EndInvoke);
IObservable<Thing> observable = observable();
return observable;
}
问题是,当执行此命令时,我在 observable() 上收到以下运行时异常:
无法加载文件或程序集“System.CoreEx,Version=1.0.2617.104,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。访问被拒绝。
如果我在没有反应性框架的情况下运行该方法,一切都很好。
Thing item = method();
有什么想法造成这种情况吗?所有程序集引用均已添加。
编辑 我应该补充一点,所讨论的表达式包含一个在使用 Moq 创建的模拟对象上执行的方法。
I have a MethodCallExpression
object from which I'm trying to return a IObservable<Thing>
instance using the Reactive Extensions
framework.
private IObservable<Thing> GetThing(Expression<Func<Thing>> expression)
{
Func<Thing> method = expression.Compile()
var observable = Observable.FromAsyncPattern<Thing>(method.BeginInvoke, method.EndInvoke);
IObservable<Thing> observable = observable();
return observable;
}
The issue is that when this executes I get the following runtime exception on observable()
:
Could not load file or assembly 'System.CoreEx, Version=1.0.2617.104, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Access is denied.
If I run the method without the Reactive framework everything is fine.
Thing item = method();
Any ideas what's causing this? All assembly references are added.
Edit I should add that the expression in question contains a method which executes on a Mocked object created using Moq.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是否为当前用户安装了反应式框架?您对此文件有读取/可执行权限吗?
Is reactive framework installed for the current user? do you have read/executable access to this file?
好吧,我设法让它工作,尽管我从未真正了解访问被拒绝问题的根源。可能是重启后解决了这个问题。在剥离我的代码并重建它之后,我开始遇到不同的错误:
然后我将代码更改为在应用 Rx 之前将方法调用包装到
Action
中,并且这有效:据记录我能够进一步减少这种情况:
Well I managed to get it working, although I never really got to the bottom of the Access Denied issue. It may have been a reboot that resolved it. After stripping my code right back and rebuilding it I starting getting a different error:
I then changed the code to wrap to method invoke into an
Action
before applying Rx, and this worked:For the record I was able to reduce this further: