简体   繁体   English

找不到元数据文件.dll

[英]Metadata file .dll could not be found

My project can't find the namespaces. 我的项目找不到名称空间。 Does someone know what the problem is? 有人知道问题出在哪里吗?

I have tried a lot of option to fix the problem. 我尝试了很多选择来解决此问题。 But not one of them works. 但其中没有一个有效。

I have tried: clean solution, build solution, refactor and 我尝试过:干净的解决方案,构建解决方案,重构和

Right click on the solution and click Properties. 右键单击解决方案,然后单击属性。

Click Configuration on the left. 单击左侧的配置。

Make sure the check box under Build for the project it can't find is checked. 确保选中“构建”下无法找到的项目的复选框。

If it is already checked, uncheck, hit apply and check the boxes again. 如果已选中,请取消选中,单击应用,然后再次选中复选框。

Here is a screenshot of my code. 这是我的代码的屏幕截图。 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>

Here is the code that you asked for. 这是您要求的代码。 Hopefully you can help with my problem. 希望您能为我解决问题。

The reason is conflict between your namespace in ProductLogic class and the name of Product class from NTier.Domain namespace. 原因是您的ProductLogic类中的名称空间与NTier.Domain名称空间中的Product类的名称之间存在冲突。 It has not much to do with the project reference. 它与项目参考关系不大。 In this case VS has priority over current namespace, not class from other namespace. 在这种情况下,VS优先于当前名称空间,而不是其他名称空间的类。 You need to use NTier.Domain.Product each time for each Product class usage in that case or change your NTier.BLL.Product Namespace to something else; 在这种情况下,每次使用每种Product类时,都需要使用NTier.Domain.Product ,或者将NTier.BLL.Product命名空间更改为其他名称。 for instance NTier.BLL.ProductLogic 例如NTier.BLL.ProductLogic

It also doesn't seem true you "can't" use Ntier.Domain namespace (referring to the screenshot attached and comment in there): it's grayed out because it is not used at all (as VS doesn't connect any of Product strings used in code to the class you would like it to do, but to current namespace, so none of classes from Ntier.Domain is used and VS says you "you can remove that reference, it's not used"), to check that: if you put our mouse over Product reference you should see something like that: 您似乎“不能”使用Ntier.Domain命名空间(请参阅附件中的屏幕快照并在其中进行注释),这似乎也不是真的:因为它根本没有使用,它呈灰色显示(因为VS无法连接任何Product代码中使用的字符串将传递给您想要的类,但传递给当前的名称空间,因此不使用Ntier.Domain任何类,并且VS表示您“可以删除该引用,不使用它”),以检查:如果将鼠标悬停在“产品参考”上,您应该会看到类似以下内容:

在此处输入图片说明

which informs you that VS is not seeing a class there, but your current namespace 通知您VS在那里没有看到类,但是您当前的名称空间是

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

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