dinytro
Messages postés31Date d'inscriptionmardi 19 mars 2002StatutMembreDernière intervention20 juillet 2005
-
21 avril 2005 à 10:33
dinytro
Messages postés31Date d'inscriptionmardi 19 mars 2002StatutMembreDernière intervention20 juillet 2005
-
21 avril 2005 à 16:50
Bonjour,
je souhaiterais récupérer le type d'une assembly que je charge avec la methode
Ensuite je parcours les type de l'assembly et si je trouve un type en question qui correspond au nom de la DLL que j'ai ouverte (pathAssembly) je dois faire un traitement particulier :
/* Get the name of the lib */
string paramSlit = ",";
string[]tmpSplit = assemblyNamespace.Split(paramSlit.ToCharArray());
string libName = tmpSplit[0];
// Get All the Types in the Assembly
ArrType = SampleAssembly.GetTypes();
foreach (Type type in ArrType)
{
MethodInfo[] methods = type.GetMethods (BindingFlags.Public
|BindingFlags.Instance
|BindingFlags.DeclaredOnly
|BindingFlags.Static
|BindingFlags.NonPublic
|BindingFlags.FlattenHierarchy);
foreach (MethodInfo methodInfo in methods)
{
if (type.Name.Trim() == libName.Trim())
{
//Traitement
}
}
}
Ceci fonctionne donc très bien mais seulement voilà, je voudrais éviter de parcourir tous les type alors que je connais le nom de celui que je cherche puisqu'il a le nom de ma dll...
J'ai donc essayé ceci :
Type t = SampleAssembly.GetType(libName,true);
mais j'obtiens cette erreur :
An unhandled exception of type 'System.TypeLoadException' occurred in ApplicationEssai8.exe
Additional information: Could not load type Demo2 from assembly Demo2, Version=1.0.1931.28903, Culture=neutral, PublicKeyToken=null.
Pouvez vous m'aider ?
est-ce que ça viendrais du paramètre passé à GetType qui ne va pas ?
Merci
A voir également:
Could not load type 'adodb.fieldstointernalfieldsmarshaler' from assembly