简体   繁体   English

如何在Visual Studio 2010的C#(和XNA)类中使用F#库

[英]how using a F# library inside C# (and XNA) classes with visual studio 2010

I have developed a little game using XNA 4.0 and C# (new Project->Windows Game 4.0 ). 我使用XNA 4.0和C#开发了一个小游戏(新的Project-> Windows Game 4.0)。 Now I have to refactor all the game logic and write it in F#. 现在,我必须重构所有游戏逻辑并用F#编写。

I created a new project for my F# library(new Project->F# Library), and added the XNA library to the project's references. 我为F#库创建了一个新项目(新Project-> F#库),并将XNA库添加到了该项目的引用中。

Now, how can I include the F# library inside my C# project? 现在,如何在C#项目中包含F#库?

I assume the problem is referencing your F# library project from your C# one, rather than using the XNA library from in your F# project. 我认为问题是从C#引用您的F#库项目,而不是从F#项目中使用XNA库。


In the same way you'd reference a C# project: 用相同的方式引用C#项目:

Add the F# project to your solution and add a reference to the F# project in your other one 将F#项目添加到您的解决方案中,并在另一个项目中添加对该F#项目的引用

Compile the F# library and include it into your solution. 编译F#库并将其包含在您的解决方案中。 I had to do this a while back to get the Financial Functions library: http://blogs.msdn.com/b/lucabol/archive/2008/12/04/financial-functions-for-net-released.aspx 我必须做一阵子才能获得Financial Functions库: http : //blogs.msdn.com/b/lucabol/archive/2008/12/04/financial-functions-for-net-released.aspx

I don't have my own experience with writing XNA libraries in F#, but I suppose that you may need to change some project properties to be able to reference the F# library from C# XNA application. 我没有用F#编写XNA库的经验,但是我想您可能需要更改一些项目属性才能从C#XNA应用程序引用F#库。 I don't know exactly which project settings need to be changed, but there are two online templates that you can download and use as a starting point: 我不知道到底需要更改哪些项目设置,但是有两个在线模板可以下载并用作起点:

Aside, you can also find them if you click on "Online Templates" in the "New Project" dialog in Visual Studio and search for "F# XNA". 另外,如果您在Visual Studio的“新建项目”对话框中单击“在线模板”并搜索“ F#XNA”,也可以找到它们。 There is quite a few, very useful, templates contributed by the F# community! F#社区提供了很多非常有用的模板!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM