ExcelDna icon indicating copy to clipboard operation
ExcelDna copied to clipboard

upgrading from 1.5.1 to 1.6.0 causes invalid XLL file

Open Eddict opened this issue 1 year ago • 3 comments

i was upgrading a project from 1.5.1 to 1.6.0 but Excel gave me the (in)famous "ActiveX component can't create object" error. upon investigating i unzipped/extracted the EXCELDNA file from the XLL file. in 1.5.1 that is also a zip compressed file (containing folder ".rsrc" and files ".reloc" and ".text"), but in 1.6.0 it is not a zip compressed file, but i don't what it is. opening the XLL in Excel will give an unsupported format error.

file attached; EXCELDNA (renamed to EXCELDNA.zip for upload policy reasons)

any idea(s)?

Eddict avatar Mar 02 '23 11:03 Eddict

Is this the error you refer to - I also post about the solution there. https://groups.google.com/g/exceldna/c/onRDZLJwoBY/m/ddsjBDbsBAAJ

The main discovery I made in February that is relevant to your question relates to how COM interfaces are exposed with .NET 6. You now need an explicit 'default interface' for your type - this will cause the class to implement IDispatch (if it is ComVisible). So you can change your code with an empty interface like this:

    public interface IMyUserControl { }

    [ComVisible(true)]
    [Guid("E2197CEB-6ADC-4EAB-80FD-0A9EE161BA14")]
    [ComDefaultInterface(typeof(IMyUserControl))]
    public class MyUserControl : UserControl, IMyUserControl { }

govert avatar Mar 02 '23 17:03 govert

Is this the error you refer to - I also post about the solution there. https://groups.google.com/g/exceldna/c/onRDZLJwoBY/m/ddsjBDbsBAAJ

no it is not. i tried your suggestion though but same outcome. so what about the fact that the EXCELDNA file (the only file inside the XLL archive) is not a zip file anymore? is that expected/new in 1.6.0?

Eddict avatar Mar 03 '23 20:03 Eddict

The XLL file is not an archive. It is a normal Windows .dll file. It has some assemblies embedded as resources. By default, these assemblies are embedded:

  • EXCELDNA.MANAGEDHOST
  • EXCELDNA.INTEGRATION
  • EXCELDNA.LOADER

Unless your project is called "ExcelDna" there will not be an embedded assembly just called "EXCELDNA". But I assume you are referring to one of the other assemblies.

These embedded resources are sometimes compressed too (to make the .XLL file smaller). This compression was removed in some of the 1.6.x versions, leaving the assembly embedded without compression.

In addition, we tried some obfuscation too, using a simple encoding on the embedded assemblies. This was to see if the false-positive detections from anti virus programs can be reduced.

In the end it seemed the encoding made things worse, and so we reverted back to compression only in the latest preview versions. You might try 1.7.0-rc1 as an indication of where we stand now.

I don't expect any of these changes to cause an "invalid XLL file" or to give you an "ActiveX component can't create object" error. You might be mixing some observations about the implementation of the embedded resource packing, with other problems you are running into.

govert avatar Mar 04 '23 13:03 govert