I have a file called BasicFunctions.fs which is used by Program.fs. BasicFunctions.fs is definitely above Program.fs in the project so the order is correct. But I keep on getting this error:
Error 1 Files in libraries or multiple-file applications must begin with a namespace or module declaration, eg 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'. Only the last source file of an application may omit such a declaration.
I am using VS 2013, with F# 3.1. Here is the example code, nothing special:
BasicFunctions.fs
module BasicFunctions
let runAll =
let result = 4
result
Program.fs
[<EntryPoint>]
let main argv =
printfn "%A" argv
BasicFunctions.runAll
0 // return an integer exit code
Here is the screenshot of the solution:
I found the problem. There seems to be an issue when you copy and paste .fs files instead of creating a new file from scratch. Found this link using google: https://github.com/Microsoft/visualfsharp/issues/104
To resolve the issue I just deleted the two files BasicFunctions.fs and BasicFunctions2.fs and created them using the "New Item.." menu item in VS, also ensuring that they are before the main file Program.fs.
If you don't want the hassle of re-creating files, it would be better to actually modify the .fsproj file to ensure that Program.fs is the last file. Credit goes to rmunn in the comments section.
It's building successfully now, thanks for everyone's help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.