Winforms AddIn, Net10, load a .dll into Default ALC instead of Excel-DNA context

17 views
Skip to first unread message

Brad Walker

unread,
May 22, 2026, 5:04:25 PM (yesterday) May 22
to Excel-DNA
I'm converting a VSTO add-in to Excel-DNA and I've run into a Catch-22 situation.

The add-in makes extensive use of PropertyGrids, so my classes and properties are decorated with Attributes specifying the TypeConverter, Editor, etc. used to display the properties.

I have implemented a number of TypeConverters with associated custom attributes to set formatting options, all in a separate .dll. This all worked great under VSTO, but we need to move on to Excel-DNA, given the lack of MS love.

The issue is:
1. I need to handle AssemblyResolve events so that the .dll will get added to the Default AssembleLoadContext. Otherwise, .NET doesn't find the TypeConverters.

2. I need to NOT add the .dll to the default ALC, or I will have two copies of my .dll, and reflection will determine that my custom attributes are not the same as themselves, and not let me cast them in my Typeconverters. I can see them in the PropertyDescriptor (by name) but inside the executing Typeconverter, they are incompatible. So I get Display1Attribute cannot be cast to Display1Attribute'.

I think it could work if I could get my .dll loaded in only the Default ALC, but I haven't found a way to do that. Any suggestions would be very appreciated.

Thanks,
Brad


Govert van Drimmelen

unread,
May 22, 2026, 5:47:27 PM (yesterday) May 22
to exce...@googlegroups.com

Hi Brad,

 

Is it possible that the TypeConverter will be resolved from the add-in’s ALX if you wrap the loading code in an EnterContextualReflection block?

For most cases where type resolution goes wrong, it’s because an library deep down is using type or assembly loading code that is not ‘contextual aware’.

Having the ContextualReflection in place causes those internal API calls to also respect the ALC.

 

If this does not resolve your issue, I would be keen to experiment with a small example.

 

Regards,

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 visit https://groups.google.com/d/msgid/exceldna/b4d70bb5-3034-40bc-aed2-c959364637a0n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages