IL2CPP results in corrupted build.

The application I’m developing needs to get metadata, such as thumbnail, artist, album etc, from audio files. In order to obtain the meta I use plugin taglib sharp. The plugin works perfectly fine when I build with mono, but after I switch the backend to IL2CPP I get runtime Constructor on type 'TagLib.Riff.File' not found exception.
I have no clue what to do now. How can I make it work? If the Mono supported ARM64, I would just build with Mono.

1 Like

I suspect that managed code stripping is removing the constructor for this type since it is likely used only via reflection.

Managed code stripping is disabled by default for Mono, but is enabled for IL2CPP. You can indicate to the managed code stripping system that you don’t want it to remove code from a given assembly or for a given type or method specifically. See Unity - Manual: Managed code stripping for details.

@JoshPeterson , It’s been couple of hours since I’m trying to resolve this issue using managed code stripping and can’t make it working.
The link.xml is located under the Assets folder.
This is its content:

<linker>
       <assembly fullname="TagLib">
              <type fullname="TagLib.Riff.File" preserve="all"/>
       </assembly>

       <assembly fullname="TagLib.Riff">
              <type fullname="TagLib.Riff.File" preserve="all"/>
       </assembly>

       <assembly fullname="TagLib.Riff">
              <type fullname="TagLib.File" preserve="all"/>
       </assembly>

       <assembly fullname="TagLib">
              <type fullname="TagLib.File" preserve="all"/>
       </assembly>
</linker>

The exception points to TagLib.Riff.File, but in the code the full reference to the File is TagLib.File
7427906--909470--upload_2021-8-18_15-57-10.png

Not sure how to configure the link.xml to make it working
Is it possible to disable stripping for a whole dll file?

7427906--909470--upload_2021-8-18_15-57-10.png

Yes this should work:

This assumes the name of the assembly is TabLib.dll.

1 Like

I got it working: the assmebly turned out to be taglib-sharp
This is the working link.xml
```xml
**


   <assembly fullname="taglib-sharp">
          <type fullname="TagLib.File" preserve="all"/>
   </assembly>

**
```

2 Likes

In my case, I got an error related to ‘TagLib.Mpeg.AudioFile’
So I made a small change to the .XML file provided by @blablaalb (Thanks)

<linker>
       <assembly fullname="TagLibSharp">
              <type fullname="TagLib.Riff.File" preserve="all"/>
       </assembly>
       <assembly fullname="TagLibSharp">
              <type fullname="TagLib.File" preserve="all"/>
       </assembly>
      
        <assembly fullname="TagLibSharp">
              <type fullname="TagLib.Mpeg.AudioFile" preserve="all"/>
       </assembly>

</linker>