> If I want to reference to some .dll in a .fs file, it is impossible to do so?

In Visual Studio referencing a DLL from F# is the same as with C# or VB. Your F# project will have an item called "References". Right-click on that, and then add a reference to a System DLL, or browse to a DLL in the file system.

After you've added it, you can use it in your F# project as if it were an F# item. Intellisense works with it.

Caveat: In previous versions of F# I've found that intellisense and the compiler either didn't detect the reference, or didn't keep up with the latest version of it, and had to be fixed by reloadin the solution, or even restarting Visual Studio. A quick test on the 1.9.6.16 release (May 2009 CTP) shows it working as it should.

A worthwhile exercise is to add a C# project to your solution, with a simple class, then add a reference to it from F#, by browsing to the C# DLL, in its ..\Bin\Debug directory.

eg.

C# project "ClassLibrary1" and file "Class1.cs"

using System;

namespace ClassLibrary1
{
public class Class1
{
public string AboutMe() {
return this.ToString() + ": at " + DateTime.Now;
}
}
}

In F# Program.fs:

let str1 = (new ClassLibrary1.Class1()).AboutMe()
printfn "str1 = %A" str1

If you've added the ClassLibrary1 DLL correctly then the F# should have intellisense on the DLL, and, of course, compile and run correctly. It will also keep up with any changes to the C# DLL.

By on 5/30/2009 6:27 PM ()

thank you very much!

but I am wondering since .fs can also be executed interactively, why .fsx is necessary?

By on 5/30/2009 11:22 PM ()

.fs files are regular files that contain code that will be compiled in your dll or exe..fsx fils contain code that is only meant to be run in F# interactive (select, press alt-enter). These files will not be compiled and run with the dll or exe.

By on 5/30/2009 2:30 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper