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 ever开发者_如何学Cything 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.
- Create a new empty solution in Visual Studio 2010
- Add a new C# class library project to the solution, call it MyLib
- Add a static method
int GetAnswer() { return 42; }
to the Class1 class - Add a new F# library project to the solution, call it MyOtherLib
- Add a reference from the F# library project to the C# class library project
Add this code to Module1.fs, below the
module Module1
line:open MyLib
let answer = Class1.GetAnswer()
Compile. Everything should build cleanly.
- Go to the build tab in the project properties for MyLib. Change the platform target to x64.
- Do the same for MyOtherLib.
- 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.
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#.
精彩评论