Vb.net Can';不要打开多个模块

Vb.net Can';不要打开多个模块,vb.net,module,Vb.net,Module,我正在编写一个需要列出多个模块的应用程序。 问题是,我加载的每个模块实际上都是我加载的第一个模块 打开模块的函数: Public Function openModule(path As String) As ctxModule.ctxModule Dim asm As Assembly = Nothing Dim myType As System.Type = Nothing Dim implementsIPlugin As Boolean = Nothing T

我正在编写一个需要列出多个模块的应用程序。 问题是,我加载的每个模块实际上都是我加载的第一个模块

打开模块的函数:

Public Function openModule(path As String) As ctxModule.ctxModule
    Dim asm As Assembly = Nothing
    Dim myType As System.Type = Nothing
    Dim implementsIPlugin As Boolean = Nothing
    Try
        asm = Assembly.LoadFrom(path)
        Dim fullClassName As String = "Main"
        myType = asm.GetType(fullClassName)
        implementsIPlugin = GetType(ctxModule.ctxModule).IsAssignableFrom(myType)
        If implementsIPlugin Then
            Return Activator.CreateInstance(myType)
        End If
    Catch ex As Exception
    End Try
    Return Nothing
End Function
调用函数的代码:

Public Sub load_modules()
    modules.Clear()
    modulePaths.Clear()
    For Each F As String In My.Computer.FileSystem.GetFiles(path_modules)
        If F.EndsWith(".03MDL") Then
            Dim m As ctxModule.ctxModule = Nothing
            m = openModule(F)
            If IsNothing(m) = False Then
                modules.Add(m)
                modulePaths.Add(m, F)
            Else : End If
            m = Nothing
        Else : End If
    Next
End Sub
“模块”列表中的每个模块都是第一个模块。因此,列表如下所示:

  • 单元1
  • 单元1
  • 单元1
但我应该是这样的:

  • 单元1
  • 单元2
  • 单元3

希望有人能提供帮助:S

每次调用
openModule
时,
path
是否包含不同的值?是的,到另一个模块^^^没有人知道,我如何解决此问题可能问题出在加载模块上。我假设是不同的.03MDL文件,它们的工作方式类似于dll。但是列表中的“模块X”是从哪里来的,我不明白。您能否在load_模块中发布For的每个行程?请沿着小路走。