如果服務器上沒有安裝f#代碼(共享服務器),是否可以在服務器上運行f#代碼?我的意思是也許我可以上傳和參考所有必要的程序集? f# download place包含「其他cli實現」的zip - 也許有人有simillar問題?在服務器上運行f#代碼,即使沒有安裝f#
編輯更多的上下文:其實我使用c#編譯和運行f#程序。所以我打電話
using (CodeDomProvider provider = new Microsoft.FSharp.Compiler.CodeDom.FSharpCodeProvider())
{
cr = provider.CompileAssemblyFromSource(cp, new string[] { data.Program });
}
現在在我的機器上一切都很好。我已經包含了FSharp.Core.dll(版本4)以及FSharp.Compiler.CodeDom(版本2)。一切都在本地複製。在服務器我得到這個錯誤:
Could not load file or assembly 'FSharp.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Microsoft.FSharp.Compiler.CodeDom.FSharpCodeProvider.CreateCompiler()
at System.CodeDom.Compiler.CodeDomProvider.CreateCompilerHelper()
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters options, String[] sources)...
EDIT2: 所以其實我想未安裝F#的服務器上編譯 F#代碼。這是我必須做的:
1. put FSharp.Compiler.CodeDom.dll (version 2 as there is now newer now) and FSharp.Core.dll version 2 in bin directory.
2. create new directory in bin directory and put there this:
-FSharp.Compiler.dll (version 4)
-FSharp.Core (.dll, .xml, .sigdata, .optdata) (version 4)
-Fsc.exe - f# compiler
3. From code set process' FSHARP_BIN environment variable to point to above directory:
System.Environment.SetEnvironmentVariable("FSHARP_BIN", Utils.RootFolder + @"bin\comilersstuff");
這樣編譯成功,如果你想運行它,你就不得不把Fsharp.Core.dll在同一目錄(4節)。作爲編譯的F#程序。
'FSharp.Core.dll'是可重新發布的,因此您可以將它部署在您的應用程序旁邊,這通常是最容易做的事情。 (您也可以將安裝程序鏈接到應用程序的安裝程序,另請參閱http://msdn.microsoft.com/en-us/library/ee241127.aspx)。 – Brian
標記爲最初問題的答案 – ren