开发者

Trouble referencing an F# dll in a C# project

Forgive me if the answer seems obvious.

I created a Visual Studio solution and added two projects to it, one an F# Library (called MathLibrary) and the second, a C# frontend (called frontend, I'm aware of my creativity).

So I add a reference to the MathLibrary DLL in my frontend project, compiled the MathLibrary DLL (to make sure) and attempted to use it in my frontend project开发者_如何学运维. At which point my compiler complained that it was an undefined reference. It was my understanding that adding the appropriate reference would allow me access to my DLL, but clearly I'm missing an important step.

Any help?


There is no realtionship between a .fs file's name, and the namespaces/modules therein contained... except in the case where you completely omit any namespace or module declarations; in this case, the compile assumes a module with the same name as the file. While I am glad you were able to compile, I don't think you've hit upon the actual problem/solution.


Does it perhaps show up as Module1.SomeClass. The default file in an F# library project is called Module1, and if you don't start the source code file with either a namespace or module declaration, you generate code in a module with the same name as the filename.

You might try adding namespace FsLib to the top of your F# library code that defines some class, and then see if FsLib.SomeClass works in C#.


Did the F# library build successfuly? Can you see the DLL file and does it contain any classes and namespaces if you open it using Reflector?

In any case, you'll also need to add reference to FSharp.Core.dll (which is a library containing core F# types such as lists, etc. and is referenced by any dll that the F# compiler produces). However, I suppose the error message you'd get if you just needed to add this reference would be different.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜