I have a project which ran fine as an Azure Function in v1 of the Functions runtime, but I'm busy rewriting it for v2 and I'm stuck.
My Azure Function relies on a library of mine, which in turn depends on another library. Both libraries depend on the Open XML SDK, which I've installed in those projects via NuGet. They both also have System.IO.Packaging installed via NuGet.
If I run my code through a console app, it runs fine. When I try to run it as an Azure Function, it gets partway through my library code but then the functions runtime falls over with the error:
System.Private.CoreLib: Exception while executing function: getWorkbook. ExcelGenerator: Could not load file or assembly 'System.IO.Packaging, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
I've tried adding System.IO.Packaging to the Azure Function project (which I realise I ought not to need to do) but it then falls over with a new error:
System.Private.CoreLib: Exception while executing function: getWorkbook. ExcelGenerator: Could not load type 'System.IO.Packaging.CompressionOption' from assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I'm suspicious about the 0.0.0.0 version number in the first error, and I really don't understand the second one (or honestly why adding System.IO.Packaging to the Azure Function makes any difference at all, given that this is just running compiled library code).
One other curious thing is that WindowsBase does not show up in the "Assemblies" dependency list for my Azure Function, but it does show up checked in the "add reference" dialog box. If I uncheck it, I get a mysterious error saying "No assembly reference with the name "{0}" could be found in the project".
I'm pretty sure somehow System.IO.Packaging or WindowsBase just isn't making it through to the Azure deployment, but I'm not sure how. I'm rapidly discovering that I don't know very much about how DLL dependencies work at all let alone in Azure - any ideas?