从命令行运行F#脚本时缺少名称空间 [英] Missing namespace while running F# script from command line

查看:71
本文介绍了从命令行运行F#脚本时缺少名称空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循此链接 http://msdn.microsoft.com /en-us/library/hh361033.aspx 来通过SqlDataConnection运行F#脚本中的SqlDataConnection数据库查询,该脚本通过命令行fsx.exe触发。

I am trying to follow this linke http://msdn.microsoft.com/en-us/library/hh361033.aspx to run the a database query via SqlDataConnection from a F# script which is triggered via a command line fsx.exe.

虽然我从VS2012交互式窗口运行以下脚本行,但打开所有命名空间都没有问题。

While I run the following script lines from VS2012 interactive window there was no problem to open all the namespaces.

#r "FSharp.Core.dll"
#r "System.Data.dll"
#r "FSharp.Data.TypeProviders.dll"
#r "System.Data.Linq.dll"


open Microsoft.FSharp.Linq
open System
open System.Data
open System.Data.Linq
open Microsoft.FSharp.Data.TypeProviders

--> Referenced 'C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\3.0\Runtime\v4.0\FSharp.Core.dll'


--> Referenced 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Data.dll'


--> Referenced 'C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\3.0\Runtime\v4.0\Type Providers\FSharp.Data.TypeProviders.dll'


--> Referenced 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Data.Linq.dll'

但是,如果我使用FSI.exe从命令行窗口运行相同的脚本文件,则会出现错误

however if I run the same script file from the command line window using FSI.exe I got an error

Script4.fsx(9,23): error FS0039: The namespace 'Linq' is not defined.  

第9行指的是Microsoft.FSharp.Linq命名空间。

Line 9 is referring to the Microsoft.FSharp.Linq namespace.

Q1:我在这里想念什么?

Q1: what am I missing here?

当我在VS2012交互式窗口中运行脚本时,我可以看到所有的
参考信息/添加了路径/绑定信息和Val信息。但是,如果我从命令行运行脚本,则不会打印出任何内容来帮助我进行调试。

Also when I ran the script in VS2012 interactive window I can see all Reference information/added pathes/binding information and Val information. However if I ran the script from the command line there is nothing being printed out to help me debug.

第二季度:是否可以在VS2012交互式窗口上打印相同的信息以在命令行窗口上打印?

Q2: is it possible to have the same information printed on the VS2012 interactive window to be printed on command line window?

考虑
棺材

推荐答案

Linq 名称空间主要在System.Core.dll中定义。我猜想在VS交互式窗口中这是隐式导入的,因此您的脚本有效,并且在FSI中没有隐式导出。无论哪种方式,您都应该可以通过将以下内容添加到脚本中来解决此问题

The Linq namespace is primarily defined in System.Core.dll. I'm guessing that in the VS interactive window this implicitly imported and hence your script works and that it's not implicitly exported in FSI. Either way you should be able to fix this by adding the following to the script

#r "System.Core.dll"

这篇关于从命令行运行F#脚本时缺少名称空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆