Reputation: 1183
I'm trying to port an integration library to a SOAP webservice from a full .NET Framework project to a .NET Standard based Project. I have already achieved to create the proxy clases (Reference.cs) using the new dotnet-svcutil.exe that is inside of WCF Connected Service package, with some effort as this is not as straightforward as the good old "Add Service Reference..." option that was so easy to use (at least with the complex wsdl/xsd files I need to deal with).
Anyway, the other thing I did in my full .NET Framework solution is to generate the serialization code inside my solution, so that the first WCF call does not pay the cost of dynamically generating the serialization assemblies. I originally followed this blogpost which is awesome. Basically guides you to using svcutil.exe /t:xmlSerializer YourAssembly.dll
to create the serialization code to a file and compile it along with your solution.
But now, in the .NET Core / .NET Standard port I'm struggling to make this work.
First, the new dotnet-svcutil.exe lacks support for generating this c# code for serialization. There's no /t:xmlSerializer option available.
Second, if I use the .NET Framework svcutil.exe (versión 4.6.1055.0) I get the following message:
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.6.1055.0]
Copyright (c) Microsoft Corporation. All rights reserved.
Generating XML serializers...
Warning: There were errors loading types in an assembly loaded from 'c:\Proyectos\MTO\AmadeusWs\src\AmadeusWs\bin\Debug\netstandard1.4\AmadeusWs.dll' some types in the assembly could not be loaded and will not be available to the tool.
No se puede cargar el archivo o ensamblado 'System.ServiceModel.Primitives, Version=4.1.1.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' ni una de sus dependencias. El sistema no puede encontrar el archivo especificado.
No se puede cargar el archivo o ensamblado 'System.ServiceModel.Primitives, Version=4.1.1.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' ni una de sus dependencias. El sistema no puede encontrar el archivo especificado.
No se puede cargar el archivo o ensamblado 'NodaTime, Version=2.0.0.0, Culture=neutral,
Error: No se puede cargar el archivo o ensamblado 'System.ServiceModel.Primitives, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ni una de sus dependencias. El sistema no puede encontrar el archivo especificado.
It seems to me that the old svcutil cannot load nuget references on the fly to generate the serialization code.
Can someone point to a procedure to generate the serialization code in this brave new world of .NET Core WCF?
Thanks!! Germán
Upvotes: 3
Views: 1998
Reputation: 23
Old post but this answer could help to people that found this topic recently: I was able to generate the serialization code without troubles following this guide: https://learn.microsoft.com/en-us/dotnet/core/additional-tools/dotnet-svcutil.xmlserializer-guide Basically you need to add the nuget package in the client, and be sure you have the XmlSerializerFormat attribute in your calls. And that's it! You'll get an auto-generated new assembly with the code.
Upvotes: 1