您需要使用
#I
指令,则可以加载程序集并使用它。我写了一个简单的C#控制台应用程序,试试这个,让它工作。
using System;
namespace ConsoleApplication1
{
public class Program
{
static void Main(string[] args)
{
PrintMessage();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
Console.WriteLine();
}
public static void PrintMessage()
{
Console.WriteLine("MESSAGE!");
}
}
}
然后在F#交互中:
> #I "full path to debug directory";;
--> Added 'full path to debug directory' to library include path
> #r "ConsoleApplication1.exe";;
--> Referenced 'full path to debug directory\ConsoleApplication1.exe'
> open ConsoleApplication1;;
> Program.PrintMessage();;
MESSAGE!
val it : unit = ()
所以它肯定有效,你只需要先编译你的项目。请记住重新设置会话以提前释放程序集。