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
  •  | 
  •  

Question

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)
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top