F#和C#Web服务无法打开名称空间 [英] F# and C# Web Service cannot open namespace
问题描述
我想使用Daniel Mohl撰写的VS2012 F#和C#Web服务模板.但是,我遇到了一个令人沮丧的问题,就是无法在脚本文件中使用生成的代码:
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
我得到:
Service1.svc.fs(4,6):错误FS0039:名称空间或模块 未定义"FSharpWcfServiceApplicationTemplate"
Service1.svc.fs(4,6): error FS0039: The namespace or module 'FSharpWcfServiceApplicationTemplate' is not defined
当我尝试加载dll时:
When I try and load the dll's like:
#I "bin/Debug"
#r "Services.dll"
在交互式环境中正确引用了dll,但是我无法打开命名空间FSharpWcfServiceApplicationTemplate.我还尝试将fsi文件添加到Service1.svc.fs文件.哪个可以编译,并且可以由C#项目使用,但不能在脚本文件中使用.
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?
我必须承认这是一个重复的问题 a>:但是我仍然对解决此问题的替代方法感兴趣.
I have to admit this is sort of a duplicate question: but I am still interested in alternative approaches to this problem.
推荐答案
我创建了一个基于上面模板的示例项目,该模板解决了在脚本文件中引用的问题.基本上,您可以为每个加载本地fs文件和依赖项的项目创建一个fsx文件.然后您可以将此fsx文件加载到另一个从属项目的fsx文件中,依此类推.
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.
可以在此处找到示例代码.
这篇关于F#和C#Web服务无法打开名称空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!