What is the best way to check if a dll is a win32 dll or if it is a clr assembly. At the moment I use this code
try
{
this.currentWorkingDirectory = Path.GetDirectoryName(assemblyPath);
//try to load the assembly
assembly = Assembly.LoadFile(assemblyPath);
return assembly != null;
}
catch (FileLoadException ex)
{
exception = ex;
}
catch (BadImageFormatException ex)
{
exception = ex;
}
catch (ArgumentException ex)
{
exception = ex;
}
catch (Exception ex)
{
exception = ex;
}
if (exception is BadImageFormatException)
{
return false;
}
But I like to check before loading because I do not want those exceptions (time)
Is there a better way?
Thanks, Tobias