Rilevare Assembly .NET - Detecting .NET Assemblies
// Compilazione: csc detect.cs
// Esecuzione: detect nomefile.ext (ext = estensione)
using System;
using System.IO;
using System.Reflection;
// How to detect a (EXE/DLL) .NET assembly?
public class DetectDotNet
{
public static void Main()
{
// Get command-line
String[] clargs = Environment.GetCommandLineArgs();
// Just one?
if (clargs.Length == 2)
{
try
{
// Try to load the assembly
Assembly A = Assembly.LoadFrom(clargs[1]);
// Success!
Console.WriteLine("Assembly .NET detected!");
}
// Error:
catch (ReflectionTypeLoadException Err)
{
Console.WriteLine(Err.ToString());
}
// I/O error
catch (IOException)
{
Console.WriteLine("File not found!");
}
// Invalid format - Win32?
catch (BadImageFormatException)
{
Console.WriteLine("Assembly .NET NOT detected...");
}
}
else
Console.WriteLine("detect < assemblyname.ext >");
}
}
Click here - Clicca qui