Cố gắng chạy này trong F # tương tác:F # tương tác vs F # giải pháp và 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>)
Bạn có thể sẽ thành công. Hãy thử tạo một giải pháp mới.
tham khảo:
- System.Runtime.Serialization
- System.ServiceModel
Dán đoạn mã sau vào 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>)
Và chạy nó. Tôi nhận được lỗi sau:
All parameter names used in operations that make up a service contract must not be null. Parameter name: name
Điều gì là sai?
PS: Tôi sử dụng Visual Studio 2010 Ultimate SP1
EDIT: chỉ để chắc chắn, C# tương đương hoạt động tốt
Bạn đã kiểm tra kỹ để đảm bảo rằng bạn đang nhắm mục tiêu đúng phiên bản của thời gian chạy .NET? Khi tôi nhớ lại, mặc định cho các ứng dụng giao diện điều khiển F #, trong VS 2010, là .NET 4 Client Profile, là * không * toàn bộ lược tả .NET, đôi khi gây ra các loại "nó hoạt động ở đây nhưng không có" vấn đề. – pblasucci