ExcelDna icon indicating copy to clipboard operation
ExcelDna copied to clipboard

Error window is shown when trying to register a second add-in

Open kolkhi opened this issue 4 years ago • 3 comments

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)

ExcelDnaTest.zip

Please, note that a similar scenario works fine when both add-ins are built with .Net Framework 4.8 (TFM - net48)

kolkhi avatar Mar 03 '22 16:03 kolkhi

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.

govert avatar Mar 03 '22 18:03 govert

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

Sergey-Vlasov avatar Mar 05 '22 06:03 Sergey-Vlasov

PR https://github.com/Excel-DNA/ExcelDna/pull/437

Sergey-Vlasov avatar Mar 05 '22 09:03 Sergey-Vlasov