简体   繁体   English

F#:未定义名称空间

[英]F#: the namespace is not defined

I have this F# project Rm.Accounting.Domain with the following files (and in that order): 我有这个F#项目Rm.Accounting.Domain其中包含以下文件(并Rm.Accounting.Domain顺序):

  • Model.fs : module Rm.Accounting.Domain.Model Model.fsmodule Rm.Accounting.Domain.Model
  • Commands.fs : module Rm.Accounting.Domain.Commands Commands.fsmodule Rm.Accounting.Domain.Commands
  • Events.fs : module Rm.Accounting.Domain.Events Events.fsmodule Rm.Accounting.Domain.Events

and the last one causing problems Behaviour.fs : 最后一个引起问题的Behaviour.fs

module Rm.Accounting.Domain.Behaviour

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

let a = 42

Which leads to two errors: 这导致两个错误:

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

Without that file Behaviour.fs the project can compile, I am not sure to understand why those two imports cause some troubles. 没有该项目的Behaviour.fs文件,该项目就可以编译,我不确定为什么这两次导入会引起一些麻烦。

Thanks to the comments, it seems that for some reasons despite reordering files in Rider, the fsproj didn't really get updated right. 由于这些评论,似乎由于某些原因,尽管在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>

在此处输入图片说明

Re-organising the fsproj, did the trick: 重新组织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