Govert,
I've just uploaded patch 9689 (this is my first time collaborating via
codeplex, so hopefully this was correct). I've provided a diff on
ExcelDnaLoader.cpp; as you can see, it's actually quite
straightforward (it piggy-backs on the HPC logic to short circuit the
creation of the isolated AppDomain). It creates a new attribute
"UseDefaultDomain" that can be specified in the .dna file (although,
given how much I dislike the spirit of this patch, perhaps your longer
name is better ;) ). As to whether I think this is a worthwhile
contribution: Frankly, I hated even having to do this, but the simple
truth was there was no alternate way to deal with the 3rd party
library we rely on (if a managed/unmanaged guru has any suggestions on
other means of working around the GC handle-across-appdomains issue in
a 3rd party lib, I'd love to hear them). So, there is definitely a use
case for it, but I would probably document it as being a method of
last resort. For example, this approach actually interferes with some
other in-house add-ins we have written (not on ExcelDNA) that also
tries to do its own custom loading. This has to do with the fact both
add-ins install their own assembly resolution methods in the default
app domain, so whichever gets there "first" ends up trying to resolve
assemblies for the other, but they live in different filepaths and
things break for one of them. Arguably, both should remove their
assembly resolution routines when they are done initializing, but I
suspect this will cause any late-binding assemblies to fail to load
properly. Since we had been intending to port our existing add-ins to
ExcelDNA anyway, I went ahead and did that sooner rather than later to
avoid this issue. But, it's definitely a potential issue.
Also, as you will note from the comment ~l.508 of the patched
ExcelDnaLoader.cpp, I toggled the forceFromBytes flag in the call to
LoadLoaderIntoAppDomain, which may break the HPC codepath (I haven't
tested this). This may be a bug; the code works as-is in our case.