请在F#交互环境中运行以下代码:
#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>)
运行程序时,我遇到了以下错误:
构成服务合同的操作中使用的所有参数名称都不能为null。 参数名:name
出了什么问题?
PS:我使用的是Visual Studio 2010 Ultimate SP1
编辑:只是为了确保,C#等效代码可以正常工作。