error FS0193: internal error: Could not load type 'anyType' from assembly 'FSI-ASSEMBLY, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'

回眸只為那壹抹淺笑 提交于 2019-12-12 00:24:17

问题


When Using Resizable array with any types i can't loop through that array , f# seems not to understand my preDefined Type . here is a sample code :

type someData = { 
     Entry:string ; id:int } 
let datas = new ResizeArray<someData>()
let record1 = {someData.Entry = "hiLo" ;someData.id =1234 }
datas.Add(record1)
let record2 = {someData.Entry = "Lolo" ;someData.id =1224 }
datas.Add(record2)
let record3 = {someData.Entry = "Hihi" ;someData.id =1231 }
datas.Add(record3)
let nameOnly = new ResizeArray<string>()
for entries in datas do
    nameOnly.Add(entries.Entry)

回答1:


If you run your sample code in

type someData = 
    { Entry:string ; id:int } 

let datas = new ResizeArray<someData>()
let record1 = {someData.Entry = "hiLo" ;someData.id =1234 }
datas.Add(record1)
let record2 = {someData.Entry = "Lolo" ;someData.id =1224 }
datas.Add(record2)
let record3 = {someData.Entry = "Hihi" ;someData.id =1231 }
datas.Add(record3)
let nameOnly = new ResizeArray<string>()

let createEntries () =
    for entries in datas do
        nameOnly.Add(entries.Entry)
createEntries()

there is no problem. If you first enter the part of your code up to the for loop, and then the for loop, the code also runs. I think it has something to do with the type being put into a temp module of the interactive.



来源:https://stackoverflow.com/questions/16943006/error-fs0193-internal-error-could-not-load-type-anytype-from-assembly-fsi-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!