I'm getting this error message when trying to obtain all the enums defined in a assembly via Reflection:
An unhandled exception of type 'System.Reflection.ReflectionTypeLoadException' occurred in mscorlib.dll
Additional information:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Why says it is unable to load some types?, what I'm doing wrong?, how do I retrieve the LoaderExceptions
property if necessary?.
This is the code:
VB.NET:
Dim ass As Assembly = Assembly.Load("Elektro.Interop")
Dim types As IEnumerable(Of Type) =
From t As Type In ass.GetTypes()
Where t.IsEnum
C#:
Assembly ass = Assembly.Load("Elektro.Interop");
var types = from t in ass.GetTypes()
where t.IsEnum
select t;
Note: I have access to the loaded assembly's source-code, if a kind of direct modification in that assembly is suggested to try search for or to solve this.
Aucun commentaire:
Enregistrer un commentaire