This question already has an answer here:
I have some code that uses the Crystal Reports runtime libraries to generate and discard a small dummy report, in order to ensure that the libraries are loaded into memory in good time before the user creates a genuine report. (It's a 'perceived performance' issue.) The performance has been notably improved when the user generates a report, so that clearly all works.
Now I need to write a unit test that proves that the Crystal libraries have indeed been loaded into memory when expected - however my attempts to test what is there using Assembly.GetExecutingAssembly().GetModules()
does not help. (GetCallingAssembly().GetModules()
is no better either.)
How can I check from within my unit test to see if these assemblies have been loaded?
TIA
The following code example uses the GetAssemblies method to get a list of all assemblies that have been loaded into the application domain. The assemblies are then displayed to the console.
P.S. : To run this code example, you need to create an assembly named CustomLibrary.dll, or change the assembly name that is passed to the GetAssemblies method.
See here on MSDN