I'm building a ExcelDNA plugin that requires the full version of .Net (4.0 or 3.5) (I'm using some parts of System.Web). Because of this, users that only have the client version are getting errors.
I like to prompt the user with an "get the latest" version popup on startup if only the client version is installed.
Is there any foolproof way to check if the full version is installed? By googling it seems many recommends checking the registry, byt this seems error prone as there are many .Net versions. In such a case what paths do I need to check to build:
bool IsFullDotNetVersion()
{
}
Would it be possible/good idea to check the existence for a feature that's only available in the full version? I.e. Is it possible to check is System.Web is present in the environment? (not included in client version of .Net right?)
As a side question: How can I easy test my application with different .net version installed on my system. Is there any .Net switcher?
Look in the GAC to see if System.Web
(or whatever assembly you need) is present.
Here is some code that works on my machine.
private static const string BasePath = @"c:\windows\assembly";
public static bool HasDotNetFullversion()
{
var gacFolders = new List<string>()
{
"GAC", "GAC_32", "GAC_64", "GAC_MSIL",
"NativeImages_v2.0.50727_32", "NativeImages_v2.0.50727_64"
};
var assemblyFolders = from gacFolder in gacFolders
let path = Path.Combine(BasePath, gacFolder)
where Directory.Exists(path)
from directory in Directory.GetDirectories(path)
select directory;
var hasSystemWeb = assemblyFolders.Any(x =>
x.EndsWith("system.web", StringComparison.InvariantCultureIgnoreCase));
}
Possible duplicate. How to detect what .NET Framework versions and service packs are installed? short answer is that you need to read the registry
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With