@@ -70,7 +70,7 @@ public static void LoadAndRegister(IHostEnvironment env, string[] assemblies)
7070 throw Contracts . ExceptIO ( e , "Extracting extra assembly zip failed: '{0}'" , path ) ;
7171 }
7272
73- LoadAssembliesInDir ( env , dir ) ;
73+ LoadAssembliesInDir ( env , dir , false ) ;
7474 }
7575 }
7676 }
@@ -110,7 +110,75 @@ private static string GetTempPath()
110110 return Path . GetFullPath ( Path . Combine ( Path . GetTempPath ( ) , "MLNET_" + guid . ToString ( ) ) ) ;
111111 }
112112
113- private static void LoadAssembliesInDir ( IHostEnvironment env , string dir )
113+ private static readonly string [ ] _filePrefixesToAvoid = new string [ ] {
114+ "api-ms-win" ,
115+ "clr" ,
116+ "coreclr" ,
117+ "dbgshim" ,
118+ "ext-ms-win" ,
119+ "microsoft.bond." ,
120+ "microsoft.cosmos." ,
121+ "microsoft.csharp" ,
122+ "microsoft.data." ,
123+ "microsoft.hpc." ,
124+ "microsoft.live." ,
125+ "microsoft.platformbuilder." ,
126+ "microsoft.visualbasic" ,
127+ "microsoft.visualstudio." ,
128+ "microsoft.win32" ,
129+ "microsoft.windowsapicodepack." ,
130+ "microsoft.windowsazure." ,
131+ "mscor" ,
132+ "msvc" ,
133+ "petzold." ,
134+ "roslyn." ,
135+ "sho" ,
136+ "sni" ,
137+ "sqm" ,
138+ "system." ,
139+ "zlib" ,
140+ } ;
141+
142+ private static bool ShouldSkipPath ( string path )
143+ {
144+ string name = Path . GetFileName ( path ) . ToLowerInvariant ( ) ;
145+ switch ( name )
146+ {
147+ case "cqo.dll" :
148+ case "fasttreenative.dll" :
149+ case "libiomp5md.dll" :
150+ case "libvw.dll" :
151+ case "matrixinterf.dll" :
152+ case "microsoft.ml.neuralnetworks.gpucuda.dll" :
153+ case "mklimports.dll" :
154+ case "microsoft.research.controls.decisiontrees.dll" :
155+ case "microsoft.ml.neuralnetworks.sse.dll" :
156+ case "neuraltreeevaluator.dll" :
157+ case "optimizationbuilderdotnet.dll" :
158+ case "parallelcommunicator.dll" :
159+ case "microsoft.ml.runtime.runtests.dll" :
160+ case "scopecompiler.dll" :
161+ case "tbb.dll" :
162+ case "internallearnscope.dll" :
163+ case "unmanagedlib.dll" :
164+ case "vcclient.dll" :
165+ case "libxgboost.dll" :
166+ case "zedgraph.dll" :
167+ case "__scopecodegen__.dll" :
168+ case "cosmosClientApi.dll" :
169+ return true ;
170+ }
171+
172+ foreach ( var s in _filePrefixesToAvoid )
173+ {
174+ if ( name . StartsWith ( s ) )
175+ return true ;
176+ }
177+
178+ return false ;
179+ }
180+
181+ private static void LoadAssembliesInDir ( IHostEnvironment env , string dir , bool filter )
114182 {
115183 if ( ! Directory . Exists ( dir ) )
116184 return ;
@@ -119,6 +187,9 @@ private static void LoadAssembliesInDir(IHostEnvironment env, string dir)
119187 var paths = Directory . EnumerateFiles ( dir , "*.dll" ) ;
120188 foreach ( string path in paths )
121189 {
190+ if ( filter && ShouldSkipPath ( path ) )
191+ continue ;
192+
122193 LoadAssembly ( env , path ) ;
123194 }
124195 }
@@ -152,9 +223,9 @@ public AssemblyRegistrar(IHostEnvironment env, string path)
152223
153224 if ( ! string . IsNullOrEmpty ( path ) )
154225 {
155- LoadAssembliesInDir ( _env , path ) ;
226+ LoadAssembliesInDir ( _env , path , true ) ;
156227 path = Path . Combine ( path , "AutoLoad" ) ;
157- LoadAssembliesInDir ( _env , path ) ;
228+ LoadAssembliesInDir ( _env , path , true ) ;
158229 }
159230
160231 AppDomain . CurrentDomain . AssemblyLoad += CurrentDomainAssemblyLoad ;
0 commit comments