Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin Studio for Mac在FSI中抛出异常-`似乎'没有加载核心F#libs_Xamarin_F#_Mono_Xamarin Studio - Fatal编程技术网

Xamarin Studio for Mac在FSI中抛出异常-`似乎'没有加载核心F#libs

Xamarin Studio for Mac在FSI中抛出异常-`似乎'没有加载核心F#libs,xamarin,f#,mono,xamarin-studio,Xamarin,F#,Mono,Xamarin Studio,抱歉,有这么长的错误消息!我想知道我的Xamarin是否有问题,或者Mono安装是否破坏了Xamarin上的FSI?默认的.Net运行时是Mono4.6.2,虽然我已经安装了Mono4.8.0,但Xamarin是在4.6.2上运行的 我想知道这些错误消息是否意味着FSI没有加载System.Drawing模块?为什么源目录似乎不起作用?.fsx文件中没有显示错误,但加载到FSI时,该文件不起作用 我还安装了Visual Studio for Mac。我只是从F#(第3天)开始,这是我第一次尝试打

抱歉,有这么长的错误消息!我想知道我的Xamarin是否有问题,或者Mono安装是否破坏了Xamarin上的FSI?默认的.Net运行时是Mono4.6.2,虽然我已经安装了Mono4.8.0,但Xamarin是在4.6.2上运行的

我想知道这些错误消息是否意味着FSI没有加载System.Drawing模块?为什么源目录似乎不起作用?.fsx文件中没有显示错误,但加载到FSI时,该文件不起作用

我还安装了Visual Studio for Mac。我只是从F#(第3天)开始,这是我第一次尝试打开系统模块,所以我不知道它是否有效。我自己编写的基本函数将在FSI中进行评估。我正在考虑安装可能在某个地方出错,我想知道我是否应该删除.Net、Xamarin和Mono,然后从头开始重新安装?Visual Studio是否可能干扰Xamarin

通过FSharp TV简介课程,我运行了以下错误

F#在.fsx文件中:

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
这很奇怪,因为这不是正确的路径

加载行:
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
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
发送系统。图纸至FSI

抛出:

Stopped due to error
 System.Exception: Operation could not be completed due to earlier error
 The type 'Bitmap' is not defined at 2,4
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

看起来你可能遇到了单声道错误。我已经发现了一些类似于同一个bug的报告(尽管可能是几个不同的bug)。最有用的一个问题似乎是Github问题:

我不知道这是否对你有帮助;这个问题似乎已经通过从Mono 3.2.8升级到当时最新版本的Mono解决了。但是您已经运行了最新版本的Mono,因此“升级到最新Mono”可能不是解决问题的建议。但这是我能给出的最好的建议

另外,在搜索过程中,我发现一些人抱怨
libgdiplus
(Mono的gdiplusapi实现)在各种方面存在缺陷。因此,如果你不能让
libgdiplus
正常工作,我可能会跳过
System.Drawing
示例,转到教程的另一部分

另外,下面是我第一次回答你的问题时写的,但后来我试验并发现,
系统.Drawing
名称空间会自动加载到F#scripts中,而无需显式打开它。不过,作为一名F#初学者,您可能会发现以下信息在其他环境中很有用,因此我将其保留在这里。请注意,我在下面所说的关于
系统的内容。未自动打开的绘图是错误的

----下面是不太正确的答案---

.fsx
文件中编写F#脚本时,不能只执行
打开(名称空间)
。您还必须告诉F#在哪里可以找到具有该名称空间的.DLL。在编译的项目(使用
.fs
文件)中,可以在
.fsproj
文件中找到该信息。但是对于F#脚本(
.fsx
格式),没有项目文件,因此脚本本身需要指定要加载的DLL。您可以通过
#r
指令执行此操作:

#r "/path/to/library.dll"
或者,如果正在加载的DLL安装在标准系统位置,如GAC(全局程序集缓存),则可以不使用路径,只需执行以下操作:

#r "library.dll"
每当运行F#脚本时,都会自动加载一些dll,例如
mscorlib.dll
,其中包含
系统
名称空间之类的内容。但是
System.Drawing
名称空间不是自动加载的DLL之一。因此,在打开
System.Drawing
名称空间之前,必须输入相应的
#r
引用,如下所示:

#r "System.Drawing.dll"
open System.Drawing

你能试试Xamarin工作室的F#互动板吗?它在视图->Pads->F#Interactive下。嘿,阿什利,我实际上删除了Xamarin,看看是不是mono安装导致了这个bug。F#Interactive在我将其全部删除之前运行良好。我现在正在使用VSCode。同样的错误。我可以加载其他系统模块,虽然很有趣!Xamarin团队成员FWIW能够毫无问题地运行相同的代码。鉴于它在VSCode中也失败了,我想知道您的机器上是否有不太正确的地方?除了,我还没有看到任何关于VS Mac/Xamarin Studio干扰的报告,但我会密切关注以防万一。我还有Visual Studio for Mac上的
\uu源代码\uu目录\uu
return”/“谢谢您的帮助!我还是不太清楚是什么原因造成的。我试过去除xamarin。尽管我可以加载其他系统模块,但VSCode中的错误仍然存在。我也想删除.Net安装,但这似乎真的很痛苦..>