Search code examples
c#androidxamarinexceptionnpoi

Exception thrown in NPOI while opening a file, but only in release mode


I just made a class that can translate an Excel file into a list of C# objects. I am currently working on Xamarin.Android. All worked fine in debug mode, the file was opening correctly. But when I changed to release mode, it just crashes without any exception message, but only the stacktrace (that I don't understand :s)

I believe my permissions are correctly setup, I checked them in the application settings.

I tried with a Windows application, it works.

I tried to change the file's location, but nothing changed.

try
{
     book = new XSSFWorkbook(filePath.GetStream());
}
catch (Exception e) // Exception without message
{
    onResult(new SyncProductsSummary(false, 0, 0, e));
    return;
}

filePath.GetStream works just fine, I get the actual file size, and I also tried NOT using this, but by giving the filePath as string, nothing changed.

Here's the stacktrace I get: stacktrace

If the image doesn't work (I'm not sure how to use this): https://pasteboard.co/IgbV96W.jpg


Solution

  • If it is working in the debug configuration, but not the release configuration, it is likely due to the linker settings. Like Jason mentioned, your release configuration may be trying to "Link All" which would require linker configuration for use. Try using one of the other two settings.

    If you are unfamiliar, you can find these settings in your project build settings.

    Xamarin Android Project Linker Settings