Thursday, September 13, 2012 6:37 AM
I'm trying the following code:
let orig = ref <| Vector(X = 1, Y = 1) native.DynamicInvoke[| box orig |] |> ignore
But it results in ArgumentException (FSharpRef[Vector] cannot be converted to Vector&)
Thursday, September 13, 2012 7:12 AM
You should have a look this: Parameters and Arguments
Just make sure it's mutable - so this should work:
let mutable orig = Vector(X = 1, Y = 1) native.DynamicInvoke[| &(box orig) |] |> ignoreWhat I don't get is why you need a byref at all - AFAIK the DynamicInvoke needs just a param-array - can you give a working snippet so I can try?
Thursday, September 13, 2012 7:16 AM
I don't think your code works.
Also, nevermind, I found solution.
let args = [| box valueTypeValue |] native.DynamicInvoke args |> ignore assert(not <| valueTypeValue.Equals(args.))
So if native is of C# type
delegate void NativeDelegate(ref SomeValueType v)
and is changing v, then after calling DynamicInvoke corresponding arg in arguments array (this time - args) will be overwritten.
- Marked As Answer by lostmsu Thursday, September 13, 2012 7:16 AM