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

StackOverflow https://stackoverflow.com/questions/16943006

  •  31-05-2022
  •  | 
  •  

문제

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)
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top