.netvisual-studiovisual-studio-project

.NET SDK project type reference issue


I have this in my new style .csproj:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
  <ItemGroup>
    <Reference Include="System.Data.SqlServerCe">
      <HintPath>..\OtherProject\System.Data.SqlServerCe.dll</HintPath>
    </Reference>
  </ItemGroup>

</Project>

But VS keeps resolving the reference to:

C:\Users\Me\.nuget\packages\microsoft.sqlserver.compact\4.0.8876.1\lib\net40\System.Data.SqlServerCe.dll

But this is the wrong assembly version (the one in the file system is 4.0.0.1, and the nuget one is 4.0.0.0)

What do I need to add to my csproj?


Solution

  • Please try specifying Version=4.0.0.1, or any version you desire, in the <Reference> tag:

    <Reference Include="System.Data.SqlServerCe, Version=4.0.0.1">
      <HintPath>..\OtherProject\System.Data.SqlServerCe.dll</HintPath>
    </Reference>