Hi,
Is there any scenario wherein calling GetTypes( ) on one of the loaded assembly result in firing AssemblyLoad event
I am seeing this behavior in one of my application but its hard to justify why CLR will ever do this. Overall the application is fairly complex, but the code sub-snippet is something like this:
Registered to AssemblyLoad event - I have a cache variable to store all of the loaded assembly types which is reset to null whenever the AssemblyLoad event occurs
I have another method : LoadTypes() as follows:
void LoadTypes()
{
HashMap
h = new HashMap();Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
for(int i = 0; i < assemblies.length; i++) {
Type[] types = assemblies
.GetTypes();
}
}
For one of my assembly at the GetTypes() execution, the execution flow goes into AssemblyLoadEventHandler. I am unable to digest this behavior. Can someone explain me this CLR behavior

AssemblyLoad event being fired on GetTypes call
billg51
It could be the same if you have a field which in one of the types which is of a type defined in an assembly that hasn;t been loaded yet.
Jens-Christian Larsen
Thanks for the answer. I was tried around the same lines but was playing with single type scattered in 2 dlls hence both the dll's gets loaded at same time.
Bow I had two types in first dll, first is independent of anything else and second type implements other class available in 2nd dll. This does the trick.