Types 错误FS0193:内部错误:无法加载类型';位置';来自组件';FSI-ASSEMBLY,版本=0.0.0.0,区域性=中性,PublicKeyToken=null';
当我构建解决方案时,一切都很顺利。 但是,当我尝试在FSI中运行脚本时,会得到以下结果:Types 错误FS0193:内部错误:无法加载类型';位置';来自组件';FSI-ASSEMBLY,版本=0.0.0.0,区域性=中性,PublicKeyToken=null';,types,compiler-errors,f#,fsi,Types,Compiler Errors,F#,Fsi,当我构建解决方案时,一切都很顺利。 但是,当我尝试在FSI中运行脚本时,会得到以下结果: error FS0193: internal error: Could not load type 'Position' from assembly 'FSI-ASSEMBLY, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' 我试着四处转转,但我仍然不明白是什么导致了错误。 从MS connect来看,似乎存在一个问题 定义了位置的代码片段如
error FS0193: internal error: Could not load type 'Position' from assembly 'FSI-ASSEMBLY, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
我试着四处转转,但我仍然不明白是什么导致了错误。
从MS connect来看,似乎存在一个问题
定义了位置
的代码片段如下所示:
type Position =
struct
val Shares: NrShares
val BuyPrice: Price
new (nrShares: NrShares, buyPrice: float) = { Shares = nrShares; BuyPrice = buyPrice}
/// Merge two positions.
static member inline (+!) (one: Position, other: Position) =
let addToPosition (one: Position) (other: Position) =
let nrShares = one.Shares + other.Shares
let avgprice = (one.Shares * one.BuyPrice + other.Shares * other.BuyPrice) / nrShares
Position (nrShares, avgprice)
// Sell out or partially an existing position. Buy price is not updated
let sellFromPosition (one: Position) (other: Position) =
let newShares = one.Shares - other.Shares
Position (newShares, one.BuyPrice)
if (sign(one.Shares) = sign(other.Shares))
then addToPosition one other
else sellFromPosition one other
end
这里的问题是什么?
谢谢
编辑一个
在我当前的设置中,我有一个fsx脚本LoadScript.fsx
,其中我使用\r
指令加载所需的dll文件,然后使用\open
指令打开所需的模块
LoadScript.fsx
由主脚本调用,我在主脚本中对实际计算进行编码。
fsx脚本链允许我隐藏样板代码。我只是向客户展示带有计算的主脚本,一切看起来都很整洁
fsx
脚本的“链”一直在工作。直到昨天,我从一个新的.fs
文件中添加了新模块
我试图隔离产生问题的代码部分。
这相当困难,因为错误
消息没有指向特定的代码段
奇怪的是,当我直接运行LoadScript.fsx
时,一切都顺利进行。
当我从另一个脚本调用LoadScript.fsx
时,Fsi编译失败:
#if INTERACTIVE
#load "LoadScript.fsx"
#endif
这种奇怪行为的原因是什么?
有什么提示吗?显而易见的问题是:您的编译器版本是否比错误报告中的修复日期更现代?错误是针对VS12更新2报告的,修复计划针对更新3,我正在运行VS12更新4,您提到的问题是另一个问题。对于这个问题,如果你能得到一个小的修改并提交给fsbugs@microsoft.com@desco嗨,谢谢你调查这件事。我正试图准备一个小的复制,但我正在努力隔离产生问题的特定代码段。不幸的是,类型
位置
是在第一个加载的模块中定义的,而可能触发错误的模块是最后一个加载的模块。在这些模块中,我们定义了依赖于一长串依赖项之后的位置的类型。我添加了一个编辑。也许能给我们一些关于这个问题的提示。谢谢