Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wix 确定是否安装了SqlLocalDB_Wix_Localdb_Wix3.7 - Fatal编程技术网

Wix 确定是否安装了SqlLocalDB

Wix 确定是否安装了SqlLocalDB,wix,localdb,wix3.7,Wix,Localdb,Wix3.7,我正在寻找一种在WiX中确定是否安装了SQLLocalDB的方法。我该怎么做我可以检查注册表项吗?-是时,哪个键?注册表搜索应执行以下操作: <Property Id="LOCALDB"> <RegistrySearch Id="SearchForLocalDB" Root="HKLM" Key="SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer

我正在寻找一种在WiX中确定是否安装了SQLLocalDB的方法。我该怎么做我可以检查注册表项吗?-是时,哪个键?

注册表搜索应执行以下操作:

<Property Id="LOCALDB">
   <RegistrySearch Id="SearchForLocalDB" Root="HKLM" 
                   Key="SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer\CurrentVersion"
                   Name="CurrentVersion"
                   Type="raw" />
</Property>


这将使您获得版本。

从注册表中进行检查可能不会一直有效,因为如果用户卸载localDb,则注册表项可能仍然存在

下面是我用来从命令行识别localDB安装的函数-

    internal static bool IsLocalDBInstalled()
    {
        // Start the child process.
        Process p = new Process();
        // Redirect the output stream of the child process.
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.FileName = "cmd.exe";
        p.StartInfo.Arguments = "/C sqllocaldb info";
        p.StartInfo.CreateNoWindow = true;
        p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
        p.Start();
        // Do not wait for the child process to exit before
        // reading to the end of its redirected stream.
        // p.WaitForExit();
        // Read the output stream first and then wait.
        string sOutput = p.StandardOutput.ReadToEnd();
        p.WaitForExit();

        //If LocalDb is not installed then it will return that 'sqllocaldb' is not recognized as an internal or external command operable program or batch file.
        if (sOutput == null || sOutput.Trim().Length == 0 || sOutput.Contains("not recognized"))
            return false;
        if (sOutput.ToLower().Contains("mssqllocaldb")) //This is a defualt instance in local DB
            return true;
        return false;
    }

个人我更喜欢测试与数据库实例的连接,而不是将自己连接到特定的实例/版本。@christopher painter-如何在WiX中执行此操作以决定是否安装LocalDB?我认为可以使用自定义引导程序UI为用户提供安装LocalDB或提供其他连接详细信息的选择验证。这是一个广泛的问题,需要详细的设计,而不是简单的答案。根据MSDN,AppSearch属性必须是公共属性。还有ICE52警告。是的,捆绑的时间太多了。:)固定的。