[Mono-dev] Mono Embeded : class field initialization problem
Damien
maitredede at gmail.com
Mon Jun 26 02:48:13 UTC 2017
Hi,
I am embeding Mono 5.0.1 in a native app. I have noticed a strange thing.
I have compiled an assembly (Library project, targeting framework 4.6.2)
with Visual Studio 2017 (with legacy csproj format).
In my class, I have fields that are writter like this :
class SoClassy
{
private readonly ClassyAlso myField = new ClassyAlso();
public SoClassy() { }
}
In my native code, I have :
MonoObject* obj = mono_object_new(domain, klass);
mono_runtime_object_init(obj);
It seams that in that case, the field is null.
When written this way, it works :
class SoClassy
{
private readonly ClassyAlso myField;
public SoClassy()
{
myField = new ClassyAlso()
}
}
Is it related to VS2017 compiler ? or Mono does not handle field
initialization properly ?
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-devel-list/attachments/20170626/b639c8c3/attachment.html>
More information about the Mono-devel-list
mailing list