[英]When creats fsc an init@ variable?
If I deserialize from XML I get the following error: The initialization of an object or value resulted in an object or value being accessed recursively before it was fully initialized.
如果我从XML反序列化,我会收到以下错误:
The initialization of an object or value resulted in an object or value being accessed recursively before it was fully initialized.
My F# code looks as following: 我的F#代码如下所示:
[<...>]
[<...>]
[<DataContract>]
type DerivedClass() as X = class
inherit BaseClass()
[<DataMember>]
[<Input>]
[<DefaultValue>]
val mutable MemberName: myType
....
I used ILSpy to look at the result and getting the init@117 value that guards against Access before initilazation. 我使用ILSpy来查看结果并获取初始化之前防止Access的init @ 117值。
...
[..., DataContract]
[System.Serializable]
public class DerivedClass : BaseClass
{
[..., DefaultValue, DataMember]
public modulName.myType MemberName;
internal int init@117;
...
All my other classes don't get an init@ variable and deserialize as expected. 我的所有其他类都没有获得init @变量并按预期反序列化。 Why is the init@ sometimes created and sometimes not?
为什么init @有时会创建,有时不会? The answer could help me to fix my code.
答案可以帮助我修复我的代码。
Edit 编辑
The number after the @ stands for the sourc code line of the type. @后面的数字代表该类型的源代码行。
Edit 2 编辑2
Referencing the type with as
creates the HasSelfReferentialConstructor
reponsible for the InstanceMembersNeedSafeInitCheck
so changing 与引用类型
as
创建HasSelfReferentialConstructor
为reponsible InstanceMembersNeedSafeInitCheck
因此改变
...
type DerivedClass() as X = class
...
to 至
...
type DerivedClass() = class
...
solved the issue for me. 为我解决了这个问题。
Referencing the type with as
creates the HasSelfReferentialConstructor reponsible for theInstanceMembersNeedSafeInitCheck
so changing 使用
as
引用类型会为InstanceMembersNeedSafeInitCheck创建reponsible for theInstanceMembersNeedSafeInitCheck
因此可以更改
...
type DerivedClass() as X = class
...
to 至
...
type DerivedClass() = class
...
solved the issue for me. 为我解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.