--------------------------------------------------
Excel-DNA is now registered on GitHub Sponsors.
By signing up for a monthly contribution you encourage further development and support.
--------------------------------------------------
This is a case where the .NET libraries don’t deal well with the “AssemblyLoadContexts” that were introduced in .NET Core. When the baml content from WPF is compiled at runtime, the assembly resolution goes wrong unless you set up the “Contextual Reflection” context in advance.
To deal with this you need to wrap such critical places like this:
public MyUserControl()
{
_control = new ElementHost();
_control.Location = new System.Drawing.Point(0, 0);
_control.Dock = DockStyle.Fill;
using (var ctx = System.Runtime.Loader.AssemblyLoadContext.EnterContextualReflection(this.GetType().Assembly))
{
var control = new MyWpfControl();
_control.Child = control;
Controls.Add(_control);
}
}
The .NET developers have decided not to change the requirement to insert this magic into your code in places that can trigger some code loading calls at runtime. And you cannot know what code inside another library might require this. This is one way in which .NET 6 provides significantly less isolation than .NET Framework, by design.
More reading here:
runtime/AssemblyLoadContext.ContextualReflection.md at main · dotnet/runtime (github.com)
-Govert
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/0fbb9a59-399c-426d-8101-66314d9f5bc3n%40googlegroups.com.