@@ -42,6 +42,23 @@ public static ContainerConfiguration WithAssembliesInPath(
4242
4343 var loadedNames = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
4444
45+ // Connector post-builds often copy transitive dependencies (contracts, Kiota, etc.) into
46+ // plugins-* alongside the implementation. Those DLLs are already in the app base or default
47+ // context — loading them again from the plugin path causes duplicate loads and type/MEF issues.
48+ var hostAssemblySimpleNames = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
49+ foreach ( var assemblyName in AssemblyLoadContext . Default . Assemblies . Select ( a => a . GetName ( ) . Name ) )
50+ {
51+ if ( ! string . IsNullOrEmpty ( assemblyName ) )
52+ hostAssemblySimpleNames . Add ( assemblyName ) ;
53+ }
54+
55+ foreach ( var dllPath in Directory . GetFiles ( baseDir , "*.dll" ) )
56+ {
57+ var simpleName = Path . GetFileNameWithoutExtension ( dllPath ) ;
58+ if ( ! string . IsNullOrEmpty ( simpleName ) )
59+ hostAssemblySimpleNames . Add ( simpleName ) ;
60+ }
61+
4562 foreach ( var combinedPath in existingPaths )
4663 {
4764 var dllPaths = Directory . GetFiles ( combinedPath , "*.dll" , searchOption ) ;
@@ -50,7 +67,9 @@ public static ContainerConfiguration WithAssembliesInPath(
5067 {
5168 var fullPath = Path . GetFullPath ( dllPath ) ;
5269 var name = Path . GetFileNameWithoutExtension ( fullPath ) ;
53- if ( loadedNames . Contains ( name ) )
70+ if ( string . IsNullOrEmpty ( name )
71+ || hostAssemblySimpleNames . Contains ( name )
72+ || loadedNames . Contains ( name ) )
5473 continue ;
5574 try
5675 {
0 commit comments