I'm using the Activator
to instantiate a new class based on the short name of an assembly (e.a. 'CustomModule'). It throws a FileNotFoundException
, because the assembly isn't there. Is there a way to check if a certain assembly name is present?
I'm using the following code:
System.Runtime.Remoting.ObjectHandle obj =
System.Activator.CreateInstance(assemblyName, className);
The main objective is to rather test for the presence of the assembly than to wait for the exception to occur.
If you'll notice my comment to your question it will be evident that I'm not rightly sure exactly how you want or need to go about this, but until we have a more elaborate description I can only offer you this in the hope it fits well to your situation (the key is in 'searching' the assemblies):
.NET 2.0 Compatible Code
If you want to determine whether or not the file exists before trying to load it (a good practice) then, given you have its name and know the desired location, simply try to find the file when the assembly is being resolved: