Open rob-oehm-automation opened 3 months ago
Thank you for the pull request @rob-oehm-automation - I'll have a look.
@rob-oehm-automation I'm interested in understanding your use case. Thank you
I have a need to load some assemblies dynamically but still want the convenience of distribution via a single xll. .NET dlls packed and then re-extracted are not identical files, I guess the packing process does some IL rewriting so a re-extracted file isn't loaded correctly as a .NET Assembly.
Hi @rob-oehm-automation - you say
.NET dlls packed and then re-extracted are not identical files
The assemblies should be identical after extraction - the Excel-DNA build does not do any IL rewriting or any other change. The assemblies are packed in compressed format (this can be disabled in the project file) but when loaded should be 100% identical to the built binary.
It would be easier to use the existing assembly packing mechanism (maybe exposing an access helper) than adding support for general file packing.
In the past I've suggested that add-in libraries should pack any additional files as normal resources into the .NET .dll output, keeping the Excel-DNA packing for the special cases where the library load resolution needs to be done by the Excel-DNA loader.
I'm not completely against adding the more general option - it could be more convenient than the built-in .NET resource management mechanism. But it would be a duplication of that functionality in a sense.
There must be some issues with my extraction code then. I will investigate that further.
Hi @govert
This PR is my attempt to address #331 and adds a
File
element type to the .dna schema as well as the corresponding code to pack and unpack the files.By inspection, this code should achieve this, however, I am not sure of the process to generate tests to ensure that this code is working as expected. It looks like the packing tests rely on known-good binary files, what do I need to do to create one of these files with an embedded file?
The main changes are:
FileType
to the DnaLibrary xsd schemaDnaFile
class for xml serializationpublic static IEnumerable<string> ExcelDnaUtil.GetPackedFileNames()
public static byte[] ExcelDnaUtil.GetPackedFileBytes(string name)