Error window is shown when trying to register a second add-in
Hello,
I have a problem when trying to register 2 Excel add-ins. Attached is the VS2022 solution, containing 2 projects. Each project is a simple test add-in (TFM - net6.0-windows, ExcelDna version - 1.6.0-preview2, Excel version - 2016 x64). I can successfully open Excel with 1 add-in, but when I try to add and activate another one (from the Developer->Excel AddIns toolbar), I'm getting the following exception error:
Assertion failed!
Program: ...bin\Debug\net6.0-windows\ExcelDnaTest3-AddIn64.xll File: C:\Work\Excel-DNA\ExcelDna\Source\ExcelDna.Host\host.cpp Line: 61
Expression: load_assembly_and_get_function_pointer != nullptr && "Failure: get_dotnet_load_assembly()"
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts
(Press Retry to debug the application - JIT must be enabled)
Please, note that a similar scenario works fine when both add-ins are built with .Net Framework 4.8 (TFM - net48)
Thanks for reporting this. The .NET 6 support is still very new and fragile, and I don't think I've tried multiple add-ins before. But this is a scenario I expect can be supported fine, and will look into the problem.
For second add-in hostfxr_initialize_for_runtime_config returns Success_HostAlreadyInitialized = 1, but we currently consider anything other than Success=0 as an error.
See https://github.com/dotnet/runtime/blob/main/docs/design/features/host-error-codes.md
PR https://github.com/Excel-DNA/ExcelDna/pull/437