2

I'm trying to rewrite this matlab .Net example in F# interactive. In the example a COM-interface reference is used. How do I reference a COM-interface from within the fsi?

EDIT

I refence the as described

From the Project menu, select Add Reference. Select the COM tab in the Add Reference dialog box. Select the MATLAB application.

This reference I can not send with right click to the interactive. There is no path in the properties and the dll cited in the description MLApp.dll I can not find in my matlab directory. This F# programm works:

[<EntryPoint>]
let main argv = 
    let matlab = new MLApp.MLAppClass()
    matlab.Execute "x=1+1"          |> printfn "%A"
    matlab.GetVariable("x","base")  |> printfn "%A"
    0 

But I want to use it from FSI.

Peter Siebke
  • 196
  • 1
  • 8
  • 2
    Don't post direct links to other resources. If you want to refer to information from other resource, better to copy it in the questions, so other developers can read a question without navigating to other links. Thanks. – Eugene Obrezkov Sep 29 '16 at 09:13
  • If you referenced it in VS you can right click and select send reference to FSI. Or specify with #r the dll path. – s952163 Sep 29 '16 at 09:41
  • 1
    The same way you reference any other dll in fsi – John Palmer Sep 29 '16 at 10:11
  • I there any problem with doing [this](http://www.mathworks.com/help/matlab/matlab_external/call-matlab-function-from-c-client.html)? – s952163 Sep 29 '16 at 11:21
  • @ ghaiklor I hope with the edit it is bettern now. – Peter Siebke Sep 29 '16 at 12:34
  • @ s952163 this works for dll but I do not refrence a dll, I can compile and run code referencing the running application. I want to reference it from the FSI. – Peter Siebke Sep 29 '16 at 12:34
  • @John-Palmer if I knew a dll I would, but in VS Studio it works fine to reference a running apllication, and I want to do it in the FSI. – Peter Siebke Sep 29 '16 at 12:37
  • The build output should give you the actual path to the referenced dll – John Palmer Sep 29 '16 at 12:42
  • @PeterSiebke In case you don't get a workable solution I'll take a look tomorrow (as I'd need access to matlab). – s952163 Sep 29 '16 at 13:12
  • 2
    Look in the bin\Debug directory of that little test project you used. There should be an interop library for matlab, auto-generated when you built the program. You might want to copy it into a better directory. Use #r in the fsi console to reference it. – Hans Passant Sep 29 '16 at 13:52
  • @HansPassant Thank you for your solution, it solves my needs, but I' still curios if there could be a solution without the auto generated dll of a (different) project. – Peter Siebke Sep 29 '16 at 14:22
  • 2
    You can also run Tlbimp.exe to generate the interop library. Having the IDE do it for you helps you avoid learning how to use it, rather the point of using an IDE. There is no fundamental difference. – Hans Passant Sep 29 '16 at 14:37

0 Answers0