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.
我正在构建一个ExcelDNA插件,它需要. net的完整版本(4.0或3.5)(我正在使用System.Web的某些部分)。因此,只有客户端版本的用户会收到错误。
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:
是否有简单的方法来检查是否安装了完整的版本?通过谷歌搜索,似乎很多人建议检查注册表,byt似乎很容易出错,因为有很多。net版本。在这种情况下,我需要检查哪些路径才能构建:
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?)
是否有可能/好主意去检查是否存在一个只在完整版本中可用的特性?即是否有可能检查Is系统。Web存在于环境中吗?(没有包含在。net的客户端版本中,对吗?)
As a side question: How can I easy test my application with different .net version installed on my system. Is there any .Net switcher?
作为一个附带问题:如何使用安装在系统上的不同。net版本轻松地测试我的应用程序。有。net切换器吗?
3 个解决方案
#1
2
Look in the GAC to see if System.Web
(or whatever assembly you need) is present.
查看一下GAC,看看是否有系统。Web(或您需要的任何程序集)是存在的。
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));
}
#2
1
Possible duplicate. How to detect what .NET Framework versions and service packs are installed? short answer is that you need to read the registry
可能的重复。如何检测安装了哪些。net框架版本和服务包?简而言之,您需要阅读注册表
#3
0
I would suggest that rather than try and detect which .net version the client computer has, you might just bundle the full .net installer into your installation program.
我建议您不要尝试检测客户端计算机的。net版本,而是将完整的。net安装程序打包到您的安装程序中。
In other words, detect it at the point of install and take the appropriate actions. This is the usual way of dealing with potentially missing framework parts.
换句话说,在安装时检测它并采取适当的操作。这是处理可能丢失的框架部分的常用方法。
#1
2
Look in the GAC to see if System.Web
(or whatever assembly you need) is present.
查看一下GAC,看看是否有系统。Web(或您需要的任何程序集)是存在的。
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));
}
#2
1
Possible duplicate. How to detect what .NET Framework versions and service packs are installed? short answer is that you need to read the registry
可能的重复。如何检测安装了哪些。net框架版本和服务包?简而言之,您需要阅读注册表
#3
0
I would suggest that rather than try and detect which .net version the client computer has, you might just bundle the full .net installer into your installation program.
我建议您不要尝试检测客户端计算机的。net版本,而是将完整的。net安装程序打包到您的安装程序中。
In other words, detect it at the point of install and take the appropriate actions. This is the usual way of dealing with potentially missing framework parts.
换句话说,在安装时检测它并采取适当的操作。这是处理可能丢失的框架部分的常用方法。