F# does not allow for you to silently ignore return values. The type unit is F#'s version of void. So the error is saying essentially
I expected the statement to have no return but instead it returns an int value
Or the opposite. I tend to incorrectly read this error message.
What's likely happening is one of the following
- The method in question is expecting an
int return value but the method Add returns void hence F# is just asking for a return value
- The method in question is typed as
unit but Add is returning an int and F# needs you to ignore the value.
- The
GetCapture or ToWpfImage return values that need to be explicitly handled.
For the last 2 cases you can fix this by passing the value to the ignore function
mtvCap.GetCapture() |> ignore
mtvCap.ToWpfImage() |> ignore
grid.Children.Add(mtvCap.ImageElement) |> ignore
After digging around a bit I believe #2 is the issue because UIElementCollection.Add returns an int value. Try modifying the final line to look like this
grid.Children.Add(mtvCap.ImageElement) |> ignore