VB/VB.Net Ajout d'une dll

A

Anonymous

Invité
#1
Bonjour,

je cherche a ajouter une dll temporaire sur mon programme.
Voila ce que sa donne niveau code:

Imports System.Reflection

Public Class App
Private Const ASSEMBLY_NAME As String = "plugins\test.dll"
Private Const CLASS_NAME As String = "test"
Private Const METHOD_NAME As String = "Start"

Public Sub mMain()
Try
' On charge l'assembly.
Dim assembly__1 As Assembly = Assembly.LoadFrom(ASSEMBLY_NAME)
' On obtient la classe.
Dim type As Type = assembly__1.[GetType](CLASS_NAME)
' On obtient la méthode.
Dim method As MethodInfo = type.GetMethod(METHOD_NAME)
' On crée l'objet.
Dim target As Object = Activator.CreateInstance(type)
' On appelle la méthode.
Dim s As String = DirectCast(method.Invoke(target, New Object() {"Hello World"}), String)

MsgBox(s)

Console.ReadLine()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
End Class

Mais on m'indique que "method" est nothing.

System.NullReferenceException: Object reference not set to an instance of an object.
at PluginManager.App.mMain() in XXXX\App.vb:line 15

Ligne 15:
Dim method As MethodInfo = type.GetMethod(METHOD_NAME)

Une idée ?
 
Inscrit
29 Septembre 2011
Messages
393
Reactions
3
#2
Salut, en fait tu aimerais charger une dll au lancement de ton application ? qui peut être servir pour éviter d'envoyer ton programme + la dll ?
 
Inscrit
31 Mars 2012
Messages
102
Reactions
0
#6
salut :) si tu veux j'ai ça dans mon bot, Mp moi ton skype ou quoi si ta besoin d'aide.
 
Haut Bas