elmish / Elmish.WPF

Static WPF views for elmish programs
Other
429 stars 71 forks source link

ApplicationAlreadyRunning Exception #595

Closed bainewedlock closed 6 months ago

bainewedlock commented 7 months ago

I tried to make the counter app from the tutorial, but when I start it there is an exception:

System.InvalidOperationException: 'Die Anwendung führt den Verteiler bereits aus.'

I guess this is the untranslated error: ApplicationAlreadyRunning | Application is already running the Dispatcher.

Note: I wasn't able to follow the tutorial exactly, because some functions did not exist with the suggested name.

    let main window =
        Program.mkSimpleWpf init update bindings
        |> Program.runWindow window
TysonMN commented 7 months ago

Can you share a GitHib repo with code that reproduces your problem?

bainewedlock commented 7 months ago

Sure: https://github.com/bainewedlock/elmish-wpf-demo

let me know if you need more details to reproduce the behavior

marner2 commented 6 months ago

@bainewedlock sorry about the delayed response.

This error happens when you use Program.mkWindow in a context where you already "made" the window with XAML.

Instead use Program.mkSimpleWpf init update bindings |> Program.startElmishLoop ElmConfig.Default window if you are using the Activated event on an already-existing App and Window.

bainewedlock commented 6 months ago

@marner2 great it works, thanks for taking a look at my code!