dotnet / runtimelab

This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
MIT License
1.42k stars 198 forks source link

marshaling of classes? #897

Closed jtorjo closed 3 years ago

jtorjo commented 3 years ago

While compiling my project with .net native, I run into an error:

Lit_happy_120.mp3:EETypeRva:0x00067310(System.Runtime.InteropServices.MissingInteropDataException): NAudio.Wave.Mp3WaveFormat is missing structure marshalling data. To enable structure marshalling data, add a MarshalStructure directive to the application rd.xml file. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=393965

I've added marshaling info here:

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Library Name="naudio.uwp">
    <Namespace Name="NAudio.Wave">
        <Type Name="WaveFormat" MarshalStructure="Required All"/>
    </Namespace>

</Library>

However, the same error gets thrown.

I've read here: https://github.com/dotnet/corert/issues/5374#issuecomment-455706335 that CoreRT only supports structs for now.

Has this been fixed?

Will this be fixed?

MichalStrehovsky commented 3 years ago

Class marshalling is now supported.

NAudio.Wave.Mp3WaveFormat is missing structure marshalling data <Type Name="WaveFormat" MarshalStructure="Required All"/>

The exception is about one type, but the RD.XML is about another type. Is that your issue?

jtorjo commented 3 years ago

That is my issue, thanks. But I don't understand what I'm doing wrong :) Please help :)

EDIT: What .net native compiler version do i need?

MichalStrehovsky commented 3 years ago

That is my issue, thanks. But I don't understand what I'm doing wrong :) Please help :)

I meant the exception is about Mp3WaveFormat, but your RD.XML has WaveFormat.

jtorjo commented 3 years ago

Oh my! Thanks, I must be blind! Let me try it now!

jtorjo commented 3 years ago

Thanks! That was the issue! Unfortunately, it opened a can of worms (DllImport issues), which I'm not prepared to deal with now. I will properly solve this at a later time, but it's definitely awesome to know class marshalling works!