When it use with type instance ident and direct property members in F# coding, run it in WCF host, and call it from client, the errors occured as below
System.InvalidOperationException: There was an error while trying to deserialize parameter http://tempuri.org/:…. Please see InnerException for more details. —> System.InvalidOperationException: The initialization of an object or
value resulted in an object or value being accessed recursively before it was fully initialized
[<DataContract>]
type A()=
[<DefaultValue>] val mutable _Column:DateTime
[<DataMember>]
member x.Column
with get ()=x._Column
and set v=x._Column<-v
//===============================================
//***1.***
//It's wrong with type instance ident and direct property members
//Use without 'DefaultValue'
[<Sealed>]
[<DataContract>]
type B=
inherit A
val mutable _ColumnA:DateTime
new ()={inherit A();_ColumnA=DateTime.Now}
new (para) as x=new B() then //Type instance ident is 'x'
do
x.Initialize ()
member x.Initialize ()=
"TODO" |>ignore
[<DataMember>] //the type have direct property members
member x.ColumnA
with get ()=x._ColumnA
and set v=x._ColumnA<-v //The error will occurs in this position, 'The initialization of an object or value resulted in an object or value being accessed recursively before it was fully initialized'
//===============================================
//***2.***
(*
//It's wrong with type instance ident and direct property members
//Use with 'DefaultValue'
[<Sealed>]
[<DataContract>]
type B=
inherit A
new ()={inherit A()}
new (para) as x=new B() then //Type instance ident is 'x'
do
x.Initialize ()
x.ColumnA<-DateTime.Now
member x.Initialize ()=
"TODO" |>ignore
[<DefaultValue>] val mutable _ColumnA:DateTime //Use with 'DefaultValue'
[<DataMember>] //the type have direct property members
member x.ColumnA
with get ()=x._ColumnA
and set v=x._ColumnA<-v //The error will occurs in this position, 'The initialization of an object or value resulted in an object or value being accessed recursively before it was fully initialized'
*)
//===============================================
//***3.***
(*
//It's right with type instance ident and without direct property members
[<Sealed>]
[<DataContract>]
type B=
inherit A
new ()={inherit A()}
new (para) as x=new B() then //Type instance ident is 'x'
do
x.Initialize ()
member x.Initialize ()=
"TODO" |>ignore
*)
//===============================================
//***4.***
(*
// it's right when it's without type instance ident!
[<Sealed>]
[<DataContract>]
type B=
inherit A
new ()={inherit A()}
new (para)=new B() then
do
"TODO" |>ignore
*)
Many thanks to Brian’s reviewing and modification.
How can I correct this?
//------------------------------------------------------------
Addition,
namespace NS
open System
open System.ServiceModel
[<ServiceContract>]
type IService =
[<OperationContract>] abstract Query:isAsceding:bool->B[] //The parameter name 'isAsceding' is needed in WCF enviroment
namespace NS
open System
open System.ServiceModel
[<ServiceBehavior(Name="NS.Service",InstanceContextMode=InstanceContextMode.Single) >]
type Service() =
interface IService with
member x.Query isAsceding=
//TODO
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="Shared_wsHttpBinding"
closeTimeout="00:02:00"
openTimeout="00:02:00"
receiveTimeout="00:10:00"
sendTimeout="00:02:00"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="52428800"
maxReceivedMessageSize="6553600"
messageEncoding="Text"
textEncoding="utf-8"
useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="3200"
maxStringContentLength="819200"
maxArrayLength="1638400"
maxBytesPerRead="409600"
maxNameTableCharCount="1638400" />
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows"
proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/Service"
binding="wsHttpBinding"
bindingConfiguration="Shared_wsHttpBinding"
contract="NS.IService"
name="WSHttpBinding_IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
The issue has been fixed by microsoft, so the next version will do right thing, please see here