EntryPointNotFound при подписке на событие через IObservable - PullRequest
0 голосов
/ 09 декабря 2011

Я пытался выполнить перетаскивание в приложении WPF с помощью Rx, и когда я пытался подписаться, было выдано исключение EntryPointNotFindException .... кто-нибудь может мне помочь с этим?

Код приложения WPF

<Window x:Class="RxDragDropPOC.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="300" Width="300">
<Canvas Name="canvas">
    <TextBlock Name="textBlock" Text="Test" />
    <Image Canvas.Left="0" Canvas.Top="25" Height="100" Name="image" Width="100" Source="C:/Users/guilherme.dias/Desktop/images.jpg" />
</Canvas>

код C #

public partial class MainWindow : Window
{

    public MainWindow()
    {
        InitializeComponent();

        var mouseDown = from evt in Observable.FromEvent<MouseButtonEventArgs>(image, "MouseLeftButtonDown")
                        select evt.EventArgs.GetPosition(this);
        var mouseUp = from evt in Observable.FromEvent<MouseButtonEventArgs>(image, "MouseLeftButtonUp")
                      select evt.EventArgs.GetPosition(this);
        var mouseMove = from evt in Observable.FromEvent<MouseEventArgs>(image, "MouseMove")
                        select evt.EventArgs.GetPosition(this);

        var q = from start in mouseDown
                from pos in mouseMove.StartWith(start).TakeUntil(mouseUp).
                            Let(mm => mm.Zip(mm.Skip(1), (prev, cur) =>
                                new { X = cur.X - prev.X, Y = cur.Y - prev.Y }))
                select pos;

        //THIS IS THE LINE THAT THROWS EntryPointNotFound
        q.ObserveOnDispatcher().Subscribe(value =>
        {
            Canvas.SetLeft(image, Canvas.GetLeft(image) + value.X);
            Canvas.SetTop(image, Canvas.GetTop(image) + value.Y);
        });
    }
}

РЕДАКТИРОВАТЬ 1

Сведения об исключении

System.EntryPointNotFoundException was caught
Message=Entry point was not found.
Source=mscorlib
TypeName=""
StackTrace:
   at System.IObservable`1.Subscribe(IObserver`1 observer)
   at System.ObservableExtensions.Subscribe[TSource](IObservable`1 source, Action`1 onNext, Action`1 onError, Action onCompleted)
   at System.Linq.Observable.<>c__DisplayClass3dd`2.<Select>b__3db(IObserver`1 observer)
   at System.Collections.Generic.AnonymousObservable`1.<>c__DisplayClass1.<Subscribe>b__0()
   at System.Concurrency.CurrentThreadScheduler.EnsureTrampoline(Action action)
   at System.Collections.Generic.AnonymousObservable`1.Subscribe(IObserver`1 observer)
   at System.ObservableExtensions.Subscribe[TSource](IObservable`1 source, Action`1 onNext, Action`1 onError, Action onCompleted)
   at System.Linq.Observable.<>c__DisplayClass3dd`2.<Select>b__3db(IObserver`1 observer)
   at System.Collections.Generic.AnonymousObservable`1.<>c__DisplayClass1.<Subscribe>b__0()
   at System.Concurrency.CurrentThreadScheduler.EnsureTrampoline(Action action)
   at System.Collections.Generic.AnonymousObservable`1.Subscribe(IObserver`1 observer)
   at System.ObservableExtensions.Subscribe[TSource](IObservable`1 source, Action`1 onNext, Action`1 onError, Action onCompleted)
   at System.Linq.Observable.<>c__DisplayClass2e5`1.<Merge>b__2de(IObserver`1 observer)
   at System.Collections.Generic.AnonymousObservable`1.<>c__DisplayClass1.<Subscribe>b__0()
   at System.Concurrency.CurrentThreadScheduler.EnsureTrampoline(Action action)
   at System.Collections.Generic.AnonymousObservable`1.Subscribe(IObserver`1 observer)
   at System.ObservableExtensions.Subscribe[TSource](IObservable`1 source, Action`1 onNext, Action`1 onError, Action onCompleted)
   at System.Linq.Observable.<>c__DisplayClass27b`1.<ObserveOn>b__274(IObserver`1 observer)
   at System.Collections.Generic.AnonymousObservable`1.<>c__DisplayClass1.<Subscribe>b__0()
   at System.Concurrency.CurrentThreadScheduler.EnsureTrampoline(Action action)
   at System.Collections.Generic.AnonymousObservable`1.Subscribe(IObserver`1 observer)
   at System.ObservableExtensions.Subscribe[TSource](IObservable`1 source, Action`1 onNext, Action`1 onError, Action onCompleted)
   at System.ObservableExtensions.Subscribe[TSource](IObservable`1 source, Action`1 onNext)
   at RxDragDropPOC.MainWindow..ctor() in C:\Semantic Framework\POC\RxDragDropPOC\RxDragDropPOC\MainWindow.xaml.cs:line 46

1 Ответ

0 голосов
/ 11 декабря 2011

Убедитесь, что у вас есть ссылка на PresentationFoundation, WindowsBase, PresentationCore и System.Xaml, возможно, вам не хватает одного из них. Убедитесь, что у вас также есть ссылка на System.Reactive.Windows.Threading.dll

...