我正在尝试使用WCF服务,即.NET核心项目中的.NET框架。 我将该服务作为项目参考包含在.NET核心项目中,您可以在.csproj设置中看到。
VS2017抱怨服务需要System.ServiceModel assemble reference.
我尝试添加System.ServiceModel
,但它有以下错误:
错误无法解析'.NETFramework,Version = v4.6.2(win7-x64)'的'System.ServiceModel(> = 4.0.0)'。
我尝试将其添加到csproj文件中,如下所示:
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<PackageReference Include="System.ServiceModel" Version="4.0.0.0" />
</ItemGroup>
这是整个csproj文件:
<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net462</TargetFrameworks>
<RuntimeIdentifiers>win7-x64;</RuntimeIdentifiers>
<AssemblyName>SimpleTokenProvider.Test</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>SimpleTokenProvider.Test</PackageId>
</PropertyGroup>
<ItemGroup>
<None Update="Views;Areas\**\Views">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Services\Services.csproj" />
<ProjectReference Include="..\..\src\SimpleTokenProvider\SimpleTokenProvider.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp1.1'">
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.NETCore.Portable.Compatibility" Version="1.0.1-rc2-24027" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<PackageReference Include="System.ServiceModel" Version="4.0.0.0" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services" />
</ItemGroup>