This is killing me.
I've read what SO posts I could find on the subject: here was the most relevant, but it didn't cover passing the delegate to an Event (though I'd have expected it would be straightforward).
Specifically, the error in VS is:
This function value is being used to construct a delegate type whose signature includes a byref argument. You must use an explicit lambda expression taking 2 arguments.
The best reasoning for the error I could find is the aside in Eric Lippert's blog, but I thought I had it handled below.
// Documentation: http://msdn.microsoft.com/en-us/library/aa752084(v=vs.85).aspx
// Don't forget to unwrap the instance before using it.
let mutable ieInstance : option<InternetExplorer> = None
let onDocumentComplete (pDisp : Object) (url : byref<Object>) =
let doc = ieInstance.Value.Document :?> IHTMLDocument2
let window = doc.parentWindow
window.execScript(@"alert('Message added by addon.');") |> ignore
// All of the following underline "DocumentComplete" as the source of the error.
do ieInstance.Value.DocumentComplete.AddHandler(new Handler<byref<Object>>(fun pDisp url -> onDocumentComplete pDisp &url))
do ieInstance.Value.DocumentComplete.AddHandler(fun pDisp url -> onDocumentComplete pDisp &url)
do ieInstance.Value.DocumentComplete.Add(fun pDisp url -> onDocumentComplete pDisp &url)
do ieInstance.Value.DocumentComplete.Add(fun _ _ -> ())
do ieInstance.Value.DocumentComplete.Add(fun (_, _) -> ())
I appreciate any suggestions!
Update 1
The library I'm referencing is Interop.SHDocVw, in 'Microsoft Internet Controls'. I also tried using SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler
as the delegate type, still failing.