While I think alternative 3 could be quite useful I often have access to the assembly name and not the actual file name.
For example the assembly name might be:
Company.Product
Whereas the file name might be:
Company.Product.dll
There are times when I'll fully qualify a class such as:
"Company.Product.Namespace.MyClass, Company.Product"
and therefore I have the name of the assembly, but not the name of the file.
The fully qualified class name is useful to pass to Type.GetType(string) when passing only the full class name doesn't seem to work.
While adding ".dll" on the end is not difficult I do think there are times when the following alternative might be useful.
Instead of passing the file name you simply pass the assembly name. Which does tend to be the file name without the .dll.
Instead of using the Assembly.LoadFile function it uses Assembly.Load.
public static bool IsInDebugMode(string assemblyName)
{
var assembly = System.Reflection.Assembly.Load(assemblyName);
var attributes = assembly.GetCustomAttributes(typeof(System.Diagnostics.DebuggableAttribute), false);
if (attributes.Length > 0)
{
var debuggable = attributes[0] as System.Diagnostics.DebuggableAttribute;
if (debuggable != null)
return (debuggable.DebuggingFlags & System.Diagnostics.DebuggableAttribute.DebuggingModes.Default) == System.Diagnostics.DebuggableAttribute.DebuggingModes.Default;
else
return false;
}
else
return false;
}
However I'm sure there are plenty of times when people have the file name and therefore the previous alternative would be more suited.
So the function used depends on whether the assembly info you have access to is the assembly name or the file name.