如何检测是否安装了SQL Server CE 4.0 [英] How to detect if SQL Server CE 4.0 is installed
问题描述
我开发一些应用程序需要安装的SQL Server CE 4.0。
I develop some application that needs SQL Server CE 4.0 installed.
我做的所有工作的Windows 7 64位,所以我已经安装了SQL Server CE 4.0 64-下位。
I do all job under Windows 7 64-bit so I have installed SQL Server CE 4.0 64-bit.
我怎么可以做一些检查是否有安装了SQL Server CE 4.0的32位/ 64位的,当我启动应用程序/或安装?
How I can do some checking if there is installed SQL Server CE 4.0 32-bit/64-bit when I start the application/or installer?
这是一般的做法?
任何线索,文章等?
谢谢!
PS我读了这个链接的如何的InstallShield检查的SQL Server 2005(3.1)精简版(CE)安装,但它并不能帮助。
P.S. I read this link How can InstallShield check if SQL Server 2005 (3.1) Compact Edition (CE) is installed but it doesn't help.
推荐答案
就包括所有必需的文件与您的应用程序,它会在x86和x64运行 - 在这里看到我的博客文章:的 http://erikej.blogspot.com/2011/02/using-sql-server-compact-40-with.html 一>
Just include all the required files with your app, and it will run on both x86 and x64 - see my blog post here: http://erikej.blogspot.com/2011/02/using-sql-server-compact-40-with.html
您也可以使用下面的代码来检测,如果运行时提供给您的应用程序,但不是必需的,如果宇实现上面:
You can also use code below to detect if the runtime is available to your app, but not required if yu implement above:
public bool IsV40Installed()
{
try
{
System.Reflection.Assembly.Load("System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91");
}
catch (System.IO.FileNotFoundException)
{
return false;
}
try
{
var factory = System.Data.Common.DbProviderFactories.GetFactory("System.Data.SqlServerCe.4.0");
}
catch (System.Configuration.ConfigurationException)
{
return false;
}
catch (System.ArgumentException)
{
return false;
}
return true;
}
这篇关于如何检测是否安装了SQL Server CE 4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!