在Visual Studio 2010中定位x64平台时,F#项目引用不起作用 [英] F# project references not working when targeting x64 platform in Visual Studio 2010
问题描述
在同一个解决方案中,我有一个依赖于C#类库项目的F#库项目.本质上,在F#代码中,我执行open MyLib
(其中MyLib是C#项目的名称),并访问在C#项目中定义的一些代码.
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.
我进行编译,并且两个项目的构建都没有错误或警告.然后,如果我在两个项目上都将目标从Any CPU更改为x64,则C#项目仍然可以正常运行,但是F#项目无法构建,并显示错误消息,提示我找不到模块MyLib.重建解决方案无济于事.删除所有bin og obj文件夹也无济于事.如果我将平台目标改回Any CPU或x86,一切都会再次编译.
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?
保持健康 -h-
更新:根据要求,以下是我的确切复制步骤.
Update: On request, here are my exact reproduction steps.
- 在Visual Studio 2010中创建一个新的空解决方案
- 在解决方案中添加一个新的C#类库项目,称为MyLib
- 向Class1类添加静态方法
int GetAnswer() { return 42; }
- 将新的F#库项目添加到解决方案中,称为MyOtherLib
- 将F#库项目中的引用添加到C#类库项目中
-
将此代码添加到
module Module1
行下面的Module1.fs中:
- 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:
打开MyLib
让答案= Class1.GetAnswer()
let answer = Class1.GetAnswer()
编译.一切都应该整洁.
Compile. Everything should build cleanly.
更新2:刚刚使用Visual Studio 2010 Beta 1对其进行了测试,其行为是相同的.
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.
事实证明,这是一个错误,显然已在下一版F#中修复.
It turns out to be a bug that's apparently been fixed in the next version of F#.
这篇关于在Visual Studio 2010中定位x64平台时,F#项目引用不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!