質問

I have the following code that loads a dll file and creates a new type based on the content of the dll file :

    Dim Assembly As Assembly = Assembly.LoadFrom("C:\Test.dll")

    AppDomain.CurrentDomain.Load(Assembly.GetName())
    Dim ClassType As Type = Assembly.GetType("Test.ClassTest")

    'This line doesn't compile
    Dim Instance As ClassType

The type ClassType is created successfullly but I'm unable to instanciate it or use it in the last line.

Does anyone know how to instanciate a new type created during run time ?

Thank you in advance.

役に立ちましたか?

解決

Solution :

    Dim Assembly As Assembly = Assembly.LoadFrom("C:\Test.dll")

    AppDomain.CurrentDomain.Load(Assembly.GetName())
    Dim ClassType As Type = Assembly.GetType("Test.ClassTest")

    Dim Instance = Activator.CreateInstance(ClassType)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top