[英]open c# namespace from same solution, referenced project in f#
I am still trying to get my head around namespaces in referenced projects.我仍在尝试了解引用项目中的命名空间。
I have ac# project where a namespace ("A") is defined.我有一个 ac# 项目,其中定义了一个命名空间(“A”)。 I create a F# application, where I reference the c# project.
我创建了一个 F# 应用程序,我在其中引用了 c# 项目。
open A
leads to the following:导致以下情况:
error FS0039: The namespace or module 'A' is not defined
错误 FS0039:未定义命名空间或模块“A”
This is what I have checked:这是我检查过的:
MSDN is not much of a help ( http://msdn.microsoft.com/en-us/library/vstudio/dd393787.aspx ). MSDN 没有多大帮助( http://msdn.microsoft.com/en-us/library/vstudio/dd393787.aspx )。
Thanks.谢谢。
[EDIT] [编辑]
I have started from scratch, so that the example is lean and clean.我是从头开始的,所以这个例子既简洁又干净。
The C# project "ClassLibrary1" contains: C# 项目“ClassLibrary1”包含:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1
{
public class Class1
{
}
}
The F# Application is: F# 应用程序是:
// Learn more about F# at http://fsharp.net
// See the 'F# Tutorial' project for more help.
open ClassLibrary1
[<EntryPoint>]
let main argv =
printfn "%A" argv
0 // return an integer exit code
The error:错误:
The namespace or module 'ClassLibrary1' is not defined
未定义命名空间或模块“ClassLibrary1”
Make sure your reference is a real project references and not just referencing the DLL in the bin\\Debug folder.确保您的引用是真实的项目引用,而不仅仅是引用 bin\\Debug 文件夹中的 DLL。
If you can't get a real project reference to work, make sure the F# project is set to depend on the C# project so that it gets built first by Visual Studio (right-click on the project and go to Project Dependencies then use the tickboxes).如果您无法获得真正的项目引用,请确保将 F# 项目设置为依赖于 C# 项目,以便它首先由 Visual Studio 构建(右键单击项目并转到项目依赖项,然后使用复选框)。
I had this same issue.我有同样的问题。 All I had to do was make sure my C# project dependencies were all settled, build my C# projects, then the F# project was able to reference the correct dll's.
我所要做的就是确保我的 C# 项目依赖项全部解决,构建我的 C# 项目,然后 F# 项目能够引用正确的 dll。
In Visual Studio, you can right click on each C# project and press build.在 Visual Studio 中,您可以右键单击每个 C# 项目并按构建。 In VSCode, you have to use the terminal to navigate to each project and run
dotnet build
.在 VSCode 中,您必须使用终端导航到每个项目并运行
dotnet build
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.