【发布时间】:2017-06-06 06:58:55
【问题描述】:
抱歉所有长的错误信息!我想知道我的 Xamarin 或 Mono 安装是否有问题会破坏 Xamarin 上的 FSI?默认 .Net 运行时是 Mono 4.6.2 虽然我已经安装了 Mono 4.8.0,但 Xamarin 是在 4.6.2 上运行的
我想知道这些错误消息是否意味着 FSI 没有加载 System.Drawing 模块?为什么 SOURCE_DIRECTORY 似乎不起作用? .fsx 文件中没有显示错误,但加载到 FSI 时它不起作用。
我还安装了 Visual Studio for Mac。我刚开始使用 F#(第 3 天),这是我第一次尝试打开系统模块,所以我不知道它是否有效。我自己编写的基本函数将在 FSI 中进行评估。我正在考虑安装在某个地方被搞砸的可能性,我想知道我是否应该删除 .Net、Xamarin 和 Mono 并从头开始重新安装? Visual Studio 会不会干扰 Xamarin?
通过 FSharp TV 介绍课程,我遇到了以下错误
.fsx 文件中的 F#:
open System.Drawing
let bitmap = new Bitmap(32,32)
let path = __SOURCE_DIRECTORY__ + "/"
bitmap.Save (path + "large.png")
在 FSI 中加载整个代码块会抛出:
System.Exception: Generic Error [GDI+ status: GenericError]
at System.Drawing.GDIPlus.CheckStatus (System.Drawing.Status status) [0x0007a] in <1917aa1c39d94b1a91807b8cd9f03350>:0
at System.Drawing.Image.Save (System.String filename, System.Drawing.Imaging.ImageCodecInfo encoder, System.Drawing.Imaging.EncoderParameters encoderParams) [0x00043] in <1917aa1c39d94b1a91807b8cd9f03350>:0
at System.Drawing.Image.Save (System.String filename, System.Drawing.Imaging.ImageFormat format) [0x0004c] in <1917aa1c39d94b1a91807b8cd9f03350>:0
at System.Drawing.Image.Save (System.String filename) [0x00008] in <1917aa1c39d94b1a91807b8cd9f03350>:0
at (wrapper remoting-invoke-with-check) System.Drawing.Image:Save (string)
at <StartupCode$FSI_0004>.$FSI_0004.main@ () [0x0003d] in <2545683d6122431b9ff3a69ce9ec460c>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <8f2c484307284b51944a1a13a14c0266>:0
在 FSI 返回中仅加载 SOURCE_DIRECTORY:
val it : string = "/"
这很奇怪,因为那不是正确的路径
加载行:let bitmap = new Bitmap(32,32)
抛出:
Stopped due to error
System.Exception: Operation could not be completed due to earlier error
The type 'Bitmap' is not defined at 2,4
将 System.Drawing 发送给 FSI
抛出:
Stopped due to error
System.Exception: Operation could not be completed due to earlier error
The value, constructor, namespace or type 'Drawing' is not defined at 2,7
【问题讨论】:
-
你能试试 Xamarin Studio 中的 F# Interactive pad 吗?它位于 View -> Pads -> F# Interactive 下。
-
嘿,Ashley,我实际上已经删除了 Xamarin,看看是不是那个单声道安装导致了这个错误。在我将其全部删除之前,F# Interactive 运行良好。我现在正在使用 VSCode。同样的错误。不过我可以加载其他系统模块
-
有趣! FWIW,Xamarin 团队成员能够毫无问题地运行相同的代码。看到它在 VSCode 中也失败了,我想知道你的机器上是否有什么不正确的地方?除了Mono 4.8 requirement 之外,还没有看到任何关于 VS Mac/Xamarin Studio 干扰的报告,但会留意以防万一。
-
我在 Visual Studio for Mac 上也有
__SOURCE_DIRECTORY__return "/"
标签: xamarin f# mono xamarin-studio