visual-studiowcfwsdlsoap-clientsvcutil.exe

Generate classes marked with the `Serializable` attribute when adding/updating a Microsoft WCF Web Service Reference


I have to consume a certain SOAP web service in my C# application.

But I use the new project structure (<Project Sdk="Microsoft.NET.Sdk">...</Project>) in Visual Studio 2019 (version 16.3.6). So instead of adding a "Service Reference", I can now add a "Connected Service" and select "Microsoft WCF Web Service Reference Provider". (That works fine when I enter the URI for the WSDL resource in the URI-textbox and press the "Go" button.)

However, after scaffolding, the generated code had two notable differences compared to the same service reference in an older C# project:

I was able to let the scaffolding tools implement the INotifyPropertyChanged interface in the generated classes by adding property "enableDataBinding": true to the ExtendedData section in ConnectedService.json and updating the service. I tried to do the same for the Serializable attribute (by adding property "serializable": true in accordance with the command line options of SvcUtil.exe), but with no success. It did not seem to have any effect.

Is there some way to let the scaffolding functionality of Visual Studio also mark the generated classes as Serializable when adding/updating a WCF service reference in my .NET app?


Solution

  • Ah. It seems that the new "Microsoft WCF Web Service Reference Provider" implementation for Connected Services does not require serializable classes.

    Last week I tested the new service reference and it works just fine without the [Serializable] attribute.