When you are assigning a mutable value, the operator is <-
, not =
. In F# =
is only used for initial bindings, otherwise it's used as the Boolean equality operator (like C-family ==
). Some docs here.
You want
let mList = messageQueue.GetAllMessages()
let xt = [| "System.String,mscorlib" |]
for m in mList do
m.Formatter <- XmlMessageFormatter(xt)
No casting is needed in this case.
The error comes up because the compiler thinks you are trying to compare a IMessageFormatter
to a XmlMessageFormatter
.