The most simple way to determine the .NET CF version targeted by a Rebex DLL is to use .NET's FileVersionInfo
to retrieve the "description", which includes the platform name:
public static Version GetCompactFrameworkPlatform(string assemblyPath)
{
var info = FileVersionInfo.GetVersionInfo(assemblyPath);
string description = info.FileDescription;
if (description.EndsWith(" for .NET Compact Framework 3.9", StringComparison.Ordinal) ||
description.EndsWith(" for .NET CF 3.9", StringComparison.Ordinal))
{
return new Version(3, 9);
}
if (description.EndsWith(" for .NET Compact Framework 3.5", StringComparison.Ordinal) ||
description.EndsWith(" for .NET CF 3.5", StringComparison.Ordinal))
{
return new Version(3, 5);
}
if (description.EndsWith(" for .NET Compact Framework 2.0", StringComparison.Ordinal) ||
description.EndsWith(" for .NET CF 2.0", StringComparison.Ordinal))
{
return new Version(2, 0);
}
return null;
}
This code is suitable for Rebex DLLs published in 2017 or later.