Mono Embeded : class field initialization problem
Damien <[email protected]> Mon, 26 Jun 2017 13:48:13 +1100
| Newsgroups | gmane.comp.gnome.mono.devel |
|---|---|
| Message-ID | <CADw1o27iL4kO5RWw9BzHk3m=-QqzSeH8nVQ1XAkwA=ez1qT-Zw@mail.gmail.com> |
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.
_______________________________________________
Mono-devel-list mailing list
[email protected]
http://lists.dot.net/mailman/listinfo/mono-devel-list