繁体   English   中英

F#:未定义名称空间

[英]F#: the namespace is not defined

我有这个F#项目Rm.Accounting.Domain其中包含以下文件(并Rm.Accounting.Domain顺序):

  • Model.fsmodule Rm.Accounting.Domain.Model
  • Commands.fsmodule Rm.Accounting.Domain.Commands
  • Events.fsmodule Rm.Accounting.Domain.Events

最后一个引起问题的Behaviour.fs

module Rm.Accounting.Domain.Behaviour

open Rm.Accounting.Domain.Commands
open Rm.Accounting.Domain.Events
open Rm.Accounting.Infrastructure

let a = 42

这导致两个错误:

  • Behaviour.fs(3, 20): [FS0039] The namespace 'Domain' is not defined. -> open Rm.Accounting.Domain.Commands
  • Behaviour.fs(4, 20): [FS0039] The namespace 'Domain' is not defined. -> open Rm.Accounting.Domain.Events

没有该项目的Behaviour.fs文件,该项目就可以编译,我不确定为什么这两次导入会引起一些麻烦。

由于这些评论,似乎由于某些原因,尽管在Rider中对文件进行了重新排序,但fsproj并未真正得到正确的更新。

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
    </PropertyGroup>

    <ItemGroup>
        <Compile Include="Behaviour.fs" />
        <Compile Include="Model.fs" />
        <Compile Include="Commands.fs" />
        <Compile Include="Events.fs" />
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\Rm.Accounting.Infrastructure\Rm.Accounting.Infrastructure.fsproj" />
    </ItemGroup>

</Project>

在此处输入图片说明

重新组织fsproj,做到了这一点:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
    </PropertyGroup>

    <ItemGroup>
        <Compile Include="Model.fs" />
        <Compile Include="Commands.fs" />
        <Compile Include="Events.fs" />
        <Compile Include="Behaviour.fs" />
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\Rm.Accounting.Infrastructure\Rm.Accounting.Infrastructure.fsproj" />
    </ItemGroup>

</Project>

暂无
暂无

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

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