nissl-lab / npoi

a .NET library that can read/write Office formats without Microsoft Office installed. No COM+, no interop.
Apache License 2.0
5.67k stars 1.43k forks source link

Unity IL2CCP #210

Closed ItsAntiUp closed 5 years ago

ItsAntiUp commented 5 years ago

Hello. This plugin was working fine for a long time, but recently, I decided to change Unity's scripting backend from Mono to IL2CCP. Due to that, it stopped working completely. When trying to create a xlsx file it fails on the very first line (IWorkbook wb = new XSSFWorkbook();) It still works on ARMv7 and x86 architectures, but not ARM64. I do not know what exactly might cause this issue and how can I fix it. Any help would be appreciated.

Kurisama91 commented 5 years ago

Running into this issue as well. I'm trying to debug it.

Kurisama91 commented 5 years ago
<i>AndroidPlayer(Google_Pixel_3_XL@192.168.0.140)</i> NullReferenceException: Object reference not set to an instance of an object.
  at NPOI.XSSF.UserModel.XSSFFactory.CreateDocumentPart (NPOI.POIXMLDocumentPart parent, NPOI.OpenXml4Net.OPC.PackageRelationship rel, NPOI.OpenXml4Net.OPC.PackagePart part) [0x00000] in <00000000000000000000000000000000>:0 
  at NPOI.POIXMLDocumentPart.Read (NPOI.POIXMLFactory factory, System.Collections.Generic.Dictionary`2[TKey,TValue] context) [0x00000] in <00000000000000000000000000000000>:0 
  at NPOI.POIXMLDocument.Load (NPOI.POIXMLFactory factory) [0x00000] in <00000000000000000000000000000000>:0 
  at NPOI.XSSF.UserModel.XSSFWorkbook..ctor (System.IO.Stream is1) [0x00000] in <00000000000000000000000000000000>:0 
  at ExcelReader.ReadFile (System.String localFilePath) [0x00000] in <00000000000000000000000000000000>:0 
  at QuestionDatabase+<LoadQuestionsFromFile>d__7.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 
Rethrow as POIXMLException
  at NPOI.XSSF.UserModel.XSSFFactory.CreateDocumentPart (NPOI.POIXMLDocumentPart parent, NPOI.OpenXml4Net.OPC.PackageRelationship rel, NPOI.OpenXml4Net.OPC.PackagePart part) [0x00000] in <00000000000000000000000000000000>:0 
  at NPOI.POIXMLDocumentPart.Read (NPOI.POIXMLFactory factory, System.Collections.Generic.Dictionary`2[TKey,TValue] context) [0x00000] in <00000000000000000000000000000000>:0 
  at NPOI.POIXMLDocument.Load (NPOI.POIXMLFactory factory) [0x00000] in <00000000000000000000000000000000>:0 
  at NPOI.XSSF.UserModel.XSSFWorkbook..ctor (System.IO.Stream is1) [0x00000] in <00000000000000000000000000000000>:0 
  at ExcelReader.ReadFile (System.String localFilePath) [0x00000] in <00000000000000000000000000000000>:0 
  at QuestionDatabase+<LoadQuestionsFromFile>d__7.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 

(Filename: currently not available on il2cpp Line: -1)
Kurisama91 commented 5 years ago

The error seems to only happen on ARM64 with IL2CPP. It works fine with Mono and doing the 32bit builds but Android's new rules forces me over to having to use IL2CPP just so I can build for ARM64

ItsAntiUp commented 5 years ago

I tried to debug this aswell. All i got was this:

NullReferenceException: Object reference not set to an instance of an object. at NPOI.XSSF.UserModel.XSSFFactory.CreateDocumentPart (NPOI.POIXMLRelation descriptor) [0x00000] in <00000000000000000000000000000000>:0 at NPOI.POIXMLDocumentPart.CreateRelationship (NPOI.POIXMLRelation descriptor, NPOI.POIXMLFactory factory, System.Int32 idx, System.Boolean noRelation) [0x00000] in <00000000000000000000000000000000>:0 at NPOI.XSSF.UserModel.XSSFWorkbook.OnWorkbookCreate () [0x00000] in <00000000000000000000000000000000>:0 at Sections+d__264.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystem

ItsAntiUp commented 5 years ago

If anyone's wondering, I got it working with IL2CPP. In Unity's Asset forder add a "link.xml" file, which contains this code:

assembly fullname="NPOI" preserve="all" assembly fullname="NPOI.OOXML" preserve="all" assembly fullname="NPOI.OpenXml4Net" preserve="all" assembly fullname="NPOI.OpenXmlFormats" preserve="all"

And now everyting works as intended!

Kurisama91 commented 5 years ago

I love you @TwerkyMan thank you so much