I created 3 projects: class library (referenced by two following), web service and client application. Web service is added as Service reference (Connected Service) to the client project. The problem is that I need to get from web service an object of type ClassLibrary.AB
but by a default I got ClientProject.ServiceProject.AB
(as the service reference seems to work as any other reference it expects AB
type to be a member of reference type, in this scenario ServiceProject.AB
). I tried to switch "Configure Service Reference... > Reuse types in referenced assemblies" on and off but without success. Could you please give me some directions how should I configure it to get object of ClassLibrary
namespace? Code for clarification:
Class library AB class:
using System;
using System.Runtime.Serialization;
namespace ClassLibrary
{
[Serializable]
[DataContract(Name = "AB", Namespace = "ClassLibrary")]
public class AB
{
[DataMember(Name = "a")]
private int a;
[DataMember(Name = "b")]
private byte[] b;
<some_more_methods_here>
}
}
Web service method:
using ClassLibrary;
[...]
[WebMethod]
public AB calledMethod(byte[] x)
{
int a = [...]
byte[] b = [...]
AB ab = new AB(a, b);
return ab;
}
Failing client code:
using ClassLibrary;
[...]
byte[] x = [...]
var serviceProjectSoapClient = new ServiceProject.ServiceProjectSoapClient();
AB ab = new AB();
ab = serviceProjectSoapClient.calledMethod(x); // here error occurs because of types missmatch