wcf icon indicating copy to clipboard operation
wcf copied to clipboard

Upgrade to 6.0.0 (from 4.10.2) is missing IBindingRuntimePreferences

Open amjidq opened this issue 2 years ago • 9 comments

I have a wcf CustomBinding that is using BasicHttpBinding. After the upgrade to 6.0.0 I get the following error in VS 2022

Error CS7069 Reference to type 'IBindingRuntimePreferences' claims it is defined in 'System.ServiceModel.Primitives', but it could not be found

I have added the nuget package Primitives. As well as alot of others to test with no joy

Looking in github, the interface exists in the RTM tag but not the 6.0.0 tag is this the problem??? Or am I doing something wrong??

https://github.com/dotnet/wcf/blob/v6.0.0-rtm/src/System.ServiceModel.Primitives/src/System/ServiceModel/Channels/IBindingRuntimePreferences.cs

https://github.com/dotnet/wcf/blob/v6.0.0/src/System.ServiceModel.Primitives/src/System/ServiceModel/Channels/IBindingRuntimePreferences.cs

I have replicated this on a new console app with a class library with a single class ConsoleApp1.zip](https://github.com/dotnet/wcf/files/12075724/ConsoleApp1.zip)

TestClass.cs

using System.ServiceModel;
using System.ServiceModel.Channels;

namespace TestNamespace
{

    public abstract class TestClass
    {
        private static CustomBinding BuildBinding()
        {
            //ERROR ON LINE BELOW
            var binding = new CustomBinding(new BasicHttpBinding
            {
                MaxBufferSize = int.MaxValue,
                ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max,
                MaxReceivedMessageSize = int.MaxValue,
                AllowCookies = true,
                Security =
                {
                    Mode = BasicHttpSecurityMode.TransportWithMessageCredential,
                }
            });

            return binding;

        }
    }
}

The ClassLibrary1.csproj file is as follows

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

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.ServiceModel.Duplex" Version="6.0.0" />
    <PackageReference Include="System.ServiceModel.Http" Version="6.0.0" />
    <PackageReference Include="System.ServiceModel.NetTcp" Version="6.0.0" />
    <PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0" />
    <PackageReference Include="System.ServiceModel.Security" Version="6.0.0" />
    <PackageReference Include="System.ServiceModel.Syndication" Version="6.0.0" />
  </ItemGroup>

</Project>

ConsoleApp1.zip

amjidq avatar Jul 18 '23 04:07 amjidq

hey, thanks for the fix. DO you know when the fix will be available and is there a nightly build I could test on???

amjidq avatar Jul 19 '23 00:07 amjidq

Hi! Very important feature for my project too. Is where any information about plans of releasing it?

v-karnaukhov avatar Jul 21 '23 12:07 v-karnaukhov

@imcarolwang @HongGit @mconnew Hey guys, could you provide a workaround or something?

munichmule avatar Aug 02 '23 19:08 munichmule

Having the same issue here, when will this be released?

johannesmols avatar Aug 04 '23 07:08 johannesmols

I am also not sure of the release schedule. To unblock compiling, try cast type BasicHttpBinding to type Binding explicitly when passing it as parameter for composing CustomBinding instance?

imcarolwang avatar Aug 04 '23 07:08 imcarolwang

Same issue with the interface System.ServiceModel.Channels.IMergeEnabledMessageProperty.

Can be easily reproduced with the following test:

using System.ServiceModel.Channels;
using Xunit;

namespace ServiceModelPrimitives;

public class ServiceModelPrimitivesTests
{
    [Fact]
    public void UsingHttpRequestMessageProperty_ShouldCompile()
    {
        var actual = new HttpRequestMessageProperty();
        Assert.NotEqual(null, actual);
    }
}

Will throw the following compilation error:

Error CS7069 : Reference to type 'IMergeEnabledMessageProperty' claims it is defined in 'System.ServiceModel.Primitives', but it could not be found

Reproducible using System.ServiceModel.Http version 6.0.0, 6.0.1, 6.0.2 on dotnet 6, dotnet 7 and dotnet 8.

Here's the csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <IsPackable>false</IsPackable>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.ServiceModel.Http" Version="6.0.2" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
    <PackageReference Include="xunit" Version="2.4.2" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="coverlet.collector" Version="6.0.0">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>
</Project>

bdcberuni avatar Nov 15 '23 21:11 bdcberuni

So, it's really wierd This doesn't compile [CS7069] Reference to type 'IMergeEnabledMessageProperty' claims it is defined in 'System.ServiceModel.Primitives', but it could not be found

        var actual = new HttpRequestMessageProperty();
        Assert.NotEqual(null, actual);

this compiles well

        var actual = new HttpRequestMessageProperty();
        Assert.NotNull(actual);

Lanayx avatar Apr 10 '24 17:04 Lanayx

So, it's really wierd This doesn't compile [CS7069] Reference to type 'IMergeEnabledMessageProperty' claims it is defined in 'System.ServiceModel.Primitives', but it could not be found

        var actual = new HttpRequestMessageProperty();
        Assert.NotEqual(null, actual);

this compiles well

        var actual = new HttpRequestMessageProperty();
        Assert.NotNull(actual);

I suppose it's because XUnit Assert.Equal is creating a custom EqualityComparer that uses reflection, which triggers the exception to be thrown.

bdcberuni avatar Apr 11 '24 02:04 bdcberuni

the only way i could get around this issue is to do this:

//request.Should().NotBeNull();
if (request == null) throw new InvalidOperationException("Request is null");

yarutyunov avatar May 06 '24 21:05 yarutyunov