S
Sixxkilur
Guest
Public Class PlugInDemo
Dim SAVE_PATH As String = Application.StartupPath & "\Plugins\"
Private Sub btnRunPlugIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRunPlugIn.Click
Dim CBSI As String
CBSI = CStr(cboPlugIns.SelectedItem)
Dim NewPlugIn As ExtInterface.IMyPlugIn = LoadPlugIn(String.Concat(SAVE_PATH & CBSI & ".dll"))
If NewPlugIn IsNot Nothing Then
NewPlugIn.MySetting = txtSetting.Text
NewPlugIn.TestFunction(txtValue.Text)
End If
End Sub
Private Function LoadPlugIn(ByVal LoadPath As String) As ExtInterface.IMyPlugIn
Dim NewPlugIn As ExtInterface.IMyPlugIn
Try
Dim PlugInAssembly As Reflection.Assembly = Reflection.Assembly.LoadFrom(LoadPath)
Dim Types() As Type
Dim FoundInterface As Type
Types = PlugInAssembly.GetTypes
For Each PlugInType As Type In Types
FoundInterface = PlugInType.GetInterface("ExtInterface.IMyPlugIn")
If FoundInterface IsNot Nothing Then
NewPlugIn = DirectCast(PlugInAssembly.CreateInstance(PlugInType.FullName), ExtInterface.IMyPlugIn)
End If
Next
Catch ex As Exception
handle exceptions here
End Try
Return NewPlugIn
End Function
Private Sub PlugInDemo_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim myF As String = SAVE_PATH
For Each sf As String In My.Computer.FileSystem.GetFiles(myF, FileIO.SearchOption.SearchAllSubDirectories, "*.dll*")
cboPlugIns.Items.Add(IO.Path.GetFileNameWithoutExtension(sf))
Next
End Sub
End Class
In this app I am working on the Load even deep scans the directory and adds files with specified extension to the combobox. My problem is that all .dll files in the Plugins directory work fine but the ones located in sub directories like Plugins\test are show in combobaox but LoadPlugIn(String.Concat(SAVE_PATH & CBSI & ".dll")) does not go past the Plugins directory. How can I fix this to include the subdirectory file paths aswell?
Continue reading...
Dim SAVE_PATH As String = Application.StartupPath & "\Plugins\"
Private Sub btnRunPlugIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRunPlugIn.Click
Dim CBSI As String
CBSI = CStr(cboPlugIns.SelectedItem)
Dim NewPlugIn As ExtInterface.IMyPlugIn = LoadPlugIn(String.Concat(SAVE_PATH & CBSI & ".dll"))
If NewPlugIn IsNot Nothing Then
NewPlugIn.MySetting = txtSetting.Text
NewPlugIn.TestFunction(txtValue.Text)
End If
End Sub
Private Function LoadPlugIn(ByVal LoadPath As String) As ExtInterface.IMyPlugIn
Dim NewPlugIn As ExtInterface.IMyPlugIn
Try
Dim PlugInAssembly As Reflection.Assembly = Reflection.Assembly.LoadFrom(LoadPath)
Dim Types() As Type
Dim FoundInterface As Type
Types = PlugInAssembly.GetTypes
For Each PlugInType As Type In Types
FoundInterface = PlugInType.GetInterface("ExtInterface.IMyPlugIn")
If FoundInterface IsNot Nothing Then
NewPlugIn = DirectCast(PlugInAssembly.CreateInstance(PlugInType.FullName), ExtInterface.IMyPlugIn)
End If
Next
Catch ex As Exception
handle exceptions here
End Try
Return NewPlugIn
End Function
Private Sub PlugInDemo_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim myF As String = SAVE_PATH
For Each sf As String In My.Computer.FileSystem.GetFiles(myF, FileIO.SearchOption.SearchAllSubDirectories, "*.dll*")
cboPlugIns.Items.Add(IO.Path.GetFileNameWithoutExtension(sf))
Next
End Sub
End Class
In this app I am working on the Load even deep scans the directory and adds files with specified extension to the combobox. My problem is that all .dll files in the Plugins directory work fine but the ones located in sub directories like Plugins\test are show in combobaox but LoadPlugIn(String.Concat(SAVE_PATH & CBSI & ".dll")) does not go past the Plugins directory. How can I fix this to include the subdirectory file paths aswell?
Continue reading...