dotnet / wcf

This repo contains the client-oriented WCF libraries that enable applications built on .NET Core to communicate with WCF services.
MIT License
1.7k stars 559 forks source link

System.ServiceModel.InstanceContextMode not found in System.ServiceModel.Primitives (8.0.0, and lower) nuget package #5637

Open kankman opened 3 weeks ago

kankman commented 3 weeks ago

I added the nuget package "system.servicemodel.primitives" (8.0.0). The enum InstanceContextMode is not present there.

The source Code of the enum is here InstanceContextMode.cs on git . The decompiled source of the dll in lib folder of the nuget package looks the same (everything right).

I found out, that the file used in the project is in ref folder not in lib. The file sizes differ extremely: In ref folder: 113KB In lib folder: 2.28MB

mconnew commented 1 week ago

This is a due to a problem we're working on where types are being documented from our implementation assembly instead of our reference assembly. We have some types semi ported (or in the case of an enum, fully as there's no implementation with enums) to help keep the code as similar as possible between .NET Framework and .NET. This makes it easier and more reliable to decide if any security fixes need to be ported over in either direction. InstanceContextMode is in this category. The class DispatchRuntime is common between client and server code on .NET Framework. When you have a service, you can specify the InstanceContextMode which is used to provide a default implementation of IInstanceContextProvider. There's effectively a factory method which gets passed the configured InstanceContextMode which returns the appropriate IInstanceContextProvider instance. On the client code path for DispatchRuntime, this factory method is passed InstanceContextMode.PerSession so the factory method will always provide the same concrete type. We could have striped out the enum and removed it from the method call, but as much code was ported without changes as possible.

In client scenarios, as far as I'm aware (I did check in case there was a scenario I wasn't aware of but I couldn't find anything) InstanceContextMode can't affect any behavior in a WCF client. Why do you need it? If there's a usage scenario I've missed, we can make evaluate enabling that scenario.

kankman commented 1 week ago

We are currently porting our Net Framework Projects to Net8 to. WE have a lot of wcf services hosted and I wanted to host them in NetFramework as WCF for downward compatibility and as REST. I wanted them to use the same interfaces for WCF and REST and use them for their clients as well. The WCF Hosting infos in the Interfaces are not necessary for the clients.

After a lot of trouble with the "Mixed Hosting" of both, we decided to only use REST Services and also migrate all at once.