尝试在F#交互运行此:F#互动对F#的解决方案和WCF
#r "System.ServiceModel"
#r "System.Runtime.Serialization"
open System.ServiceModel
[<ServiceContract>]
type IWCF =
[<OperationContract>]
abstract Ping: float -> unit
type WCF() =
interface IWCF with
member o.Ping a = printfn "Hello, %g" a
let svh = new ServiceHost (typeof<WCF>)
你可能会成功。尝试制定新的解决方案。
参考:
- System.Runtime.Serialization
- System.ServiceModel
下面的代码粘贴到Program.fs
:
open System.ServiceModel
[<ServiceContract>]
type IWCF =
[<OperationContract>]
abstract Ping: float -> unit
type WCF() =
interface IWCF with
member o.Ping a = printfn "Hello, %g" a
let svh = new ServiceHost (typeof<WCF>)
并运行它。我收到以下错误:
All parameter names used in operations that make up a service contract must not be null. Parameter name: name
出了什么问题?
PS:我使用Visual Studio 2010旗舰版SP1
编辑:只是为了确保,在C#相当于正常工作
你有没有加倍检查以确定你的目标是.NET运行时的正确版本?我记得,在VS 2010中,F#控制台应用程序的默认值是.NET 4客户端配置文件,它不是*完整的.NET配置文件,有时会导致这种“它在此工作但不存在”类型的的问题。 – pblasucci