Hallo,
Ich arbeite noch an gerade an eiem Pluginsystem und versuche zu Prüfen ob die Pluginklasse ein Interface namens "PluginConnector.Connector" implementiert.
Mein Ansatz:
Problem: Er zeigt mir keine MsgBox, wenn der Code auf ein echtes Plugin stößt, während es die Dateien in dem Ordner "Plugins" durchgeht.
Warum?
Ich arbeite noch an gerade an eiem Pluginsystem und versuche zu Prüfen ob die Pluginklasse ein Interface namens "PluginConnector.Connector" implementiert.
Mein Ansatz:
VB.NET-Quellcode
- Private Function LoadPlugins() As Boolean
- Dim PluginDirectory As String = Application.StartupPath & "\Plugins"
- Dim PluginAssembly As Assembly
- If Directory.Exists(PluginDirectory) Then
- For Each File As String In Directory.GetFiles(PluginDirectory, "*.dll")
- Try
- PluginAssembly = Assembly.LoadFile(File)
- Catch ex As Exception
- Continue For
- End Try
- For Each MyType As Type In PluginAssembly.GetTypes
- Dim intf As Type() = MyType .GetInterfaces()
- For i As Integer = 0 To intf.Length - 1
- If intf(i) Is GetType(PluginConnector.Connector) Then
- 'It is a valid Plugin?
- MsgBox(File, MsgBoxStyle.Information, "Valid Plugin")
- Else
- MsgBox(File, MsgBoxStyle.Critical, "Invalid Plugin")
- Return True
- End If
- Next
- Return False
- Next
- Next
- End If
- Return True
- End Function
Problem: Er zeigt mir keine MsgBox, wenn der Code auf ein echtes Plugin stößt, während es die Dateien in dem Ordner "Plugins" durchgeht.
Warum?
C# Developer
Learning C++
Learning C++