1- Imports System.Configuration
1+ Imports System.Configuration
22Imports System.Data.Common
33Imports System.IO
44Imports System.Reflection
@@ -46,14 +46,15 @@ Partial Public MustInherit Class Connection
4646 End Sub
4747
4848 Private Shared Sub _staticInitCompleteProviders()
49- Dim asms As New Dictionary (Of String , Reflection.Assembly )
49+ Dim asms As New List (Of String )
5050 Dim asmName As String
5151 Dim connectionType As Type
5252 Dim conn As Connection
5353 Dim referencedAsms As Reflection.Assembly() = AppDomain.CurrentDomain.GetAssemblies()
5454 For Each asm As Reflection.Assembly In referencedAsms
55+ asmName = asm.GetName().Name
56+ asms.Add(asmName)
5557 If Connection._staticInitIsDatabasicSubAssembly(asm) Then
56- asmName = asm.GetName().Name
5758 connectionType = asm.GetType(asmName + ".Connection" )
5859 If Not TypeOf connectionType Is Type Then Continue For
5960 conn = Activator.CreateInstance(connectionType)
@@ -63,6 +64,29 @@ Partial Public MustInherit Class Connection
6364 )
6465 End If
6566 Next
67+ Try
68+ Dim appDirAsms As IEnumerable( Of Assembly ) = (
69+ From file In Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory)
70+ Where Path.GetExtension(file).ToLower() = ".dll"
71+ Select Assembly .LoadFrom(file)
72+ )
73+ For Each asm As System.Reflection.Assembly In appDirAsms
74+ asmName = asm.GetName().Name
75+ If (
76+ Not asms.Contains(asmName) And
77+ Connection._staticInitIsDatabasicSubAssembly(asm)
78+ ) Then
79+ connectionType = asm.GetType(asmName + ".Connection" )
80+ If Not TypeOf connectionType Is Type Then Continue For
81+ conn = Activator.CreateInstance(connectionType)
82+ Connection._supportedProviders.Add(conn.ClientName, connectionType)
83+ Connection._providersResources.Add(
84+ conn.ClientName, Activator.CreateInstance(conn.ProviderResource)
85+ )
86+ End If
87+ Next
88+ Catch ex As Exception
89+ End Try
6690 End Sub
6791
6892 Private Shared Function _staticInitIsDatabasicSubAssembly(asm As Reflection.Assembly) As Boolean
0 commit comments