Question

I want to use the VS2012 F# and C# Web Service template by Daniel Mohl. However, I run into a frustrating issue of not being able to use the generated code in a script file:

namespace FSharpWcfServiceApplicationTemplate

open System
open FSharpWcfServiceApplicationTemplate.Contracts

type Service1() =
    interface IService1 with
        member x.GetData value =
            sprintf "%A" value
        member x.GetDataUsingDataContract composite =
            match composite.BoolValue with
            | true -> composite.StringValue <- 
                            sprintf "%A%A" composite.StringValue "Suffix"
            | _ -> "do nothing" |> ignore
            composite

I tried the following scenarios without any luck:

#load Service1.svc.fs

I get:

Service1.svc.fs(4,6): error FS0039: The namespace or module 'FSharpWcfServiceApplicationTemplate' is not defined

When I try and load the dll's like:

#I "bin/Debug"
#r "Services.dll"

The dll is referenced in the interactive correctly, but I cannot open the namespace FSharpWcfServiceApplicationTemplate. I also tried with adding an fsi file to the Service1.svc.fs file. Which compiles and can be used by the C# project, but not in the script file.

How can I change this setup so I can use the service code interactively?

Edit: I have to admit this is sort of a duplicate question: but I am still interested in alternative approaches to this problem.

Was it helpful?

Solution

I have created a sample project that is based on the template above that resolves the issue with referencing in a script file. Basically you can create a fsx file for every project that loads the local fs files and dependencies. Than you can in turn load this fsx file in an fsx file in another dependant project, and so on.

The sample code can be found here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top