0
WCF strage行爲最近我遇到了在WCF序列化一個怪異的行爲。與對象序列化
它是一種簡單的服務,這暴露出一個經營合同,並返回一個類的對象(此類不飾以[Serializable接口]或[DataContract]屬性。
然而,當我打電話從客戶端這一操作它的工作原理完美和消費者收到該類的對象(與實際數據)
據我認爲它不應該通過電線,因爲它不能被序列化,請讓我知道,如果我失去了一些東西
代碼示例
public class MyService:IService
{
public Person GetPerson()
{
Person person = new Person();
person.Name = "Brian";
return person;
}
}
public class Person
{
public string Name { get; set; }
}
<services>
<service name="MyService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/MyService"/>
</baseAddresses>
</host>
<endpoint address="TestService1"
binding="basicHttpBinding"
contract="BindingTestServer.IService" ></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>