Hi Candy,
I suggest you make your simple example which works as expected more
and more complicated until you see the point where the unexpected
behaviour occurs.
In the Debug trace and Fusion log, you'd by looking for cases where
the unreferenced assembly is loaded from its full path.
You can compare the load entries between the simple case where
everything works as we expect, and the full add-in where the
unexpected happens.
If the debug trace shows only the assembly name:
'excel.exe' (Managed (v2.0.50727)): Loaded 'DynamicDelegates'
then its loaded with no context (from bytes, not locking the file).
If the debug trace shows the full path:
'excel.exe': Loaded 'C:\Program Files (x86)\Common Files\microsoft
shared\VBA\VBA7\VBE7.DLL', Cannot find or open the PDB file
then you're probably in the Load or LoadFrom context (locking the
file).
The fusion log will be even more explicit - it will show the probing
in cases where the runtime loader is trying to load an assembly (which
we don't expect for the assemblies that are not referenced, to be
explicitly loaded by Excel-DNA instead of the loader).
-Govert