繁体   English   中英

Visual Studio 2012无法构建引用其他项目的新项目

[英]Visual Studio 2012 Fails To Build New Project That References Other Projects

我有一个已经使用了几年的解决方案。 今天,在几个月的不断发展中,我第一次添加了一个新项目。 一切都很好,并被编码掉了。 去构建,发现找不到我添加的任何项目引用。

找不到类型或名称空间名称“ blah”(您是否缺少使用目录或程序集引用?)

这些引用是针对同一解决方案中的项目的,并已验证它们是CSPROJ文件中的项目引用。 Visual Studio找不到引用没有问题,因为我可以针对引用的对象进行编码。 只有在构建时才会出现问题。 当前正在使用AnyCPU进行调试。

在进行Google搜索时,我不断发现新项目或参考中的问题可能是目标框架是.NET 4 Client Profile。 然而,这种情况并非如此。 所有项目都是.NET 4,而不是Client Profile(我已验证)。 更奇怪的是,这些引用在现有项目中都工作良好。

如果我创建新项目.NET 4.5,则可以构建它。这使我认为.NET 4的目标框架出了点问题。我目前迷失了方向,不确定该怎么做。

以下是项目文件。 我必须清除文件名和项目名。

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" 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>{48AED04F-6928-45F4-8C1D-A5E6713B5120}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>MyNamespace</RootNamespace>
    <AssemblyName>MyNamespace</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkProfile />
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>..\Build\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <Prefer32Bit>false</Prefer32Bit>
  </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>
    <Prefer32Bit>false</Prefer32Bit>
  </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.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="SomeFileThatReferences.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Ref1.csproj">
      <Project>{6E0EEABF-52D7-4020-9242-AFDC33B5DAA0}</Project>
      <Name>Billing.Bills</Name>
    </ProjectReference>
    <ProjectReference Include="..\Ref2.csproj">
      <Project>{6764A403-DA4C-42FF-A89F-E1EEA7FEF0A3}</Project>
      <Name>Billing.Business</Name>
    </ProjectReference>
    <ProjectReference Include="..\Ref3.csproj">
      <Project>{9D9AB79F-D52A-4EC8-B2B7-9C605EFDBFDE}</Project>
      <Name>Billing.Reports</Name>
    </ProjectReference>
    <ProjectReference Include="..\Csla\Csla.Net4\Csla.Net4.csproj">
      <Project>{1FCE45FF-C391-4ED1-A9C4-F71CAF8773E6}</Project>
      <Name>Csla.Net4</Name>
    </ProjectReference>
    <ProjectReference Include="..\Ref4.csproj">
      <Project>{3972242B-DF6A-4B9B-9121-6138090CA114}</Project>
      <Name>Core</Name>
    </ProjectReference>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

预先感谢您的任何回答/建议。

弄清楚了。 显然我错过了我不了解的参考。 所有其他项目都引用了Microsoft的BCL可移植性包。 一旦我在NuGet中看到它,并且除新项目外,所有项目都拥有它,我立即引用了它,现在一切都建立了。

那是一次有趣的幽灵狩猎。

此烦人的错误的另一个原因。 通过查看警告消息发现了这一点。 生成时的错误消息未提供所需的信息:

警告6无法解析主要参考“ C:..-通向您的解决方案参考 .dll”,因为它是根据“ .NETFramework,Version = v4.5.1”框架构建的。 此版本比当前目标框架“ .NETFramework,Version = v4.5”更高。

由于我正在全新安装VStudio,因此好像默认项目尚未设置为我拥有的更高版本。 因此,版本差异(从较低版本引用较高版本)可以做到这一点。

暂无
暂无

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

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