Radarr/src/NzbDrone.Host/PlatformValidation.cs

58 lines
1.7 KiB
C#
Raw Normal View History

using System;
using System.Diagnostics;
using System.Reflection;
using NLog;
using NzbDrone.Common.EnvironmentInfo;
2013-08-31 01:42:30 +00:00
using NzbDrone.Common.Instrumentation;
namespace NzbDrone.Host
{
public static class PlatformValidation
{
2014-12-17 07:12:26 +00:00
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(PlatformValidation));
private const string DOWNLOAD_LINK = "http://www.microsoft.com/en-us/download/details.aspx?id=42643";
public static bool IsValidate(IUserAlert userAlert)
{
2014-12-07 20:54:07 +00:00
if (OsInfo.IsNotWindows)
{
return true;
}
if (!IsAssemblyAvailable("System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"))
{
userAlert.Alert("It looks like you don't have the correct version of .NET Framework installed. You will now be directed the download page.");
try
{
Process.Start(DOWNLOAD_LINK);
}
2014-05-31 22:11:33 +00:00
catch (Exception)
{
userAlert.Alert("Oops. Couldn't start your browser. Please visit http://www.microsoft.com/net to download the latest version of .NET Framework");
}
return false;
}
return true;
}
private static bool IsAssemblyAvailable(string assemblyString)
{
try
{
Assembly.Load(assemblyString);
return true;
}
catch (Exception e)
{
Logger.Warn("Couldn't load {0}", e.Message);
return false;
}
}
}
}