Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to 6.0.0 (from 4.10.2) is missing IBindingRuntimePreferences #5202

Open
amjidq opened this issue Jul 18, 2023 · 9 comments
Open

Upgrade to 6.0.0 (from 4.10.2) is missing IBindingRuntimePreferences #5202

amjidq opened this issue Jul 18, 2023 · 9 comments
Labels

Comments

@amjidq
Copy link

amjidq commented Jul 18, 2023

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
Copy link
Author

amjidq commented Jul 19, 2023

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

@v-karnaukhov
Copy link

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

@munichmule
Copy link

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

@johannesmols
Copy link

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

@imcarolwang
Copy link
Contributor

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?

@bdcberuni
Copy link

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>

@Lanayx
Copy link

Lanayx commented Apr 10, 2024

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);

@bdcberuni
Copy link

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.

@yarutyunov
Copy link

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");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants