4

我仍在尝试了解引用项目中的命名空间。

我有一个定义命名空间(“A”)的 ac# 项目。我创建了一个 F# 应用程序,我在其中引用了 c# 项目。

open A

导致以下结果:

错误 FS0039:未定义命名空间或模块“A”

这是我检查过的:

MSDN 帮助不大(http://msdn.microsoft.com/en-us/library/vstudio/dd393787.aspx)。

谢谢。

[编辑]

我从头开始,因此示例简洁明了。

C# 项目“ClassLibrary1”包含:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class Class1
    {
    }
}

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

错误:

未定义命名空间或模块“ClassLibrary1”

4

2 回答 2

0

确保您的引用是真实的项目引用,而不仅仅是引用 bin\Debug 文件夹中的 DLL。

如果您无法获得真正的项目引用来工作,请确保将 F# 项目设置为依赖于 C# 项目,以便它首先由 Visual Studio 构建(右键单击项目并转到项目依赖项,然后使用复选框)。

于 2013-11-02T12:46:04.827 回答
0

我有同样的问题。我所要做的就是确保我的 C# 项目依赖项都已解决,构建我的 C# 项目,然后 F# 项目能够引用正确的 dll。

在 Visual Studio 中,您可以右键单击每个 C# 项目并按构建。在 VSCode 中,您必须使用终端导航到每个项目并运行dotnet build.

于 2020-11-10T16:49:34.977 回答