Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# project references not working when targeting x64 platform in Visual Studio 2010

I have an F# library project that depends on a C# class library project, both in the same solution. Essentially in the F# code, I do open MyLib (where MyLib is the name of the C# project), and access some code defined in the C# project.

I compile and both projects build without errors or warnings. If I then change the target from Any CPU to x64 on both projects, the C# project still builds fine, but the F# project fails to build with error messages that tell me that it can't find the module MyLib. A rebuild of the solution doesn't help. Removing all bin og obj folders also doesn't help. If I change the platform target back to Any CPU or to x86 everything compiles again.

I have reproduced this in a toy solution with two small projects containing only trivial code, so I know it's not related to my specific code.

Anyone else experienced this? Any known workarounds?

be well -h-

Update: On request, here are my exact reproduction steps.

  1. Create a new empty solution in Visual Studio 2010
  2. Add a new C# class library project to the solution, call it MyLib
  3. Add a static method int GetAnswer() { return 42; } to the Class1 class
  4. Add a new F# library project to the solution, call it MyOtherLib
  5. Add a reference from the F# library project to the C# class library project
  6. Add this code to Module1.fs, below the module Module1 line:

    open MyLib

    let answer = Class1.GetAnswer()

  7. Compile. Everything should build cleanly.

  8. Go to the build tab in the project properties for MyLib. Change the platform target to x64.
  9. Do the same for MyOtherLib.
  10. Build again. You will now get two errors in the F# project, both complaining about namespace or modules not being defined.

UPDATE 2: Just tested it with Visual Studio 2010 Beta 1 and the behavior is the same.

like image 433
corvuscorax Avatar asked Oct 25 '22 08:10

corvuscorax


1 Answers

OK, so I finally got some response from Microsoft.

It turns out to be a bug that's apparently been fixed in the next version of F#.

like image 173
corvuscorax Avatar answered Oct 31 '22 00:10

corvuscorax