F# and C# Web Service cannot open namespace

梦想与她 提交于 2019-12-13 06:03:06

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/16937387/f-and-c-sharp-web-service-cannot-open-namespace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!