Mono Embeded : class field initialization problem

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Mono Embeded : class field initialization problem

Damien DALY-3
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
[hidden email]
http://lists.dot.net/mailman/listinfo/mono-devel-list
Loading...