【问题标题】:Metadata file .dll could not be found找不到元数据文件 .dll
【发布时间】:2018-10-05 20:44:28
【问题描述】:

我的项目找不到命名空间。有人知道问题出在哪里吗?

我已经尝试了很多方法来解决这个问题。但没有一个有效。

我尝试过:清理解决方案、构建解决方案、重构和

右键单击解决方案,然后单击属性。

点击左侧的配置。

确保选中为找不到的项目构建下的复选框。

如果已经勾选,取消勾选,点击应用并再次勾选。

这是我的代码的屏幕截图。 screenshot of code

    <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

      <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

      <PropertyGroup>

        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProjectGuid>{DD7D144A-06C0-482A-9142-3CD989CCC7A4}</ProjectGuid>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>NTier.BLL</RootNamespace>
        <AssemblyName>NTier.BLL</AssemblyName>
        <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>bin\Debug\</OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>bin\Release\</OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <ItemGroup>
        <Reference Include="System" />
        <Reference Include="System.Core" />
        <Reference Include="System.Xml.Linq" />
        <Reference Include="System.Data.DataSetExtensions" />
        <Reference Include="Microsoft.CSharp" />
        <Reference Include="System.Data" />
        <Reference Include="System.Net.Http" />
        <Reference Include="System.Xml" />
      </ItemGroup>
      <ItemGroup>
        <Compile Include="Admin\AdminLogic.cs" />
        <Compile Include="Customer\CustomerLogic.cs" />
        <Compile Include="Admin\IAdminLogic.cs" />
        <Compile Include="Customer\ICustomerLogic.cs" />
        <Compile Include="Customer\INotRegularCustomerLogic.cs" />
        <Compile Include="Customer\IRegularCustomerLogic.cs" />
        <Compile Include="Customer\NotRegularCustomerLogic.cs" />
        <Compile Include="Customer\RegularCustomerLogic.cs" />
        <Compile Include="Order\IOrderLogic.cs" />
        <Compile Include="Order\OrderLogic.cs" />
        <Compile Include="Product\IProductLogic.cs" />
        <Compile Include="Review\IReviewLogic.cs" />
        <Compile Include="Product\ProductLogic.cs" />
        <Compile Include="Properties\AssemblyInfo.cs" />
        <Compile Include="Review\ReviewLogic.cs" />
      </ItemGroup>
      <ItemGroup>
        <ProjectReference Include="..\NTier.DAL\NTier.DAL.csproj">

          <Project>{a42bdcd5-0ec1-4d2a-b96a-92e39138e9cb}</Project>
          <Name>NTier.DAL</Name>
        </ProjectReference>
        <ProjectReference Include="..\NTier.Domain\NTier.Domain.csproj">
          <Project>{70a4d682-67bb-456b-a21d-f343b43fe1b6}</Project>
          <Name>NTier.Domain</Name>
        </ProjectReference>
      </ItemGroup>
      <ItemGroup>
        <WCFMetadata Include="Connected Services\" />
      </ItemGroup>
      <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    </Project>

这是您要求的代码。希望你能帮助解决我的问题。

【问题讨论】:

  • 您在哪里定义了“Product”类,可能是在引用的项目中?能否请您分享 .csproj 文件?
  • 看新帖。我无法在此评论中分享代码。
  • 请编辑您的问题并添加 .csproj 文件内容
  • 我需要查看项目 .csproj 文件,而不是 Product 类
  • 我什至无法进入我的 .csproj 文件 ....

标签: c# asp.net class namespaces n-tier-architecture


【解决方案1】:

原因是 ProductLogic 类中的命名空间与 NTier.Domain 命名空间中的 Product 类名称冲突。它与项目参考没有太大关系。在这种情况下,VS 优先于当前命名空间,而不是来自其他命名空间的类。 在这种情况下,您需要为每个 Product 类用法每次使用 NTier.Domain.Product 或将您的 NTier.BLL.Product 命名空间更改为其他名称;例如NTier.BLL.ProductLogic

你“不能”使用Ntier.Domain命名空间似乎也不是真的(参考附上的截图和评论):它是灰色的,因为它根本没有被使用(因为VS没有连接代码中使用的任何 Product 字符串到您希望它执行的类,但到当前命名空间,因此不使用来自 Ntier.Domain 的任何类,并且 VS 说您“您可以删除该引用,它没有被使用”),检查: 如果您将鼠标放在产品参考上,您应该会看到类似的内容:

这会告诉你 VS 没有看到一个类,而是你当前的命名空间

【讨论】:

    猜你喜欢
    • 2010-11-28
    • 2015-05-13
    • 1970-01-01
    • 1970-01-01
    • 2017-10-30
    • 2021-11-05
    • 2017-01-29
    • 2021-04-08
    相关资源
    最近更新 更多