Dynamics AX 2012 RegConfig不起作用

问题描述:

我目前正在为使用Dynamics AX和2个镜像SQL服务器的环境开发故障转移服务,并且在使AX以预期的方式工作时遇到一些问题.

I'm currently developping a failover service for an environment using Dynamics AX and 2 mirrored SQL servers, and I have some issues getting AX to work the way I expect it to.

我开发了一项服务,该服务可以执行以下操作: -尝试连接到SQL Server实例 -使用可访问的SQL Server启动Dynamics AX.

I have developped a service which does the following : - try to connect to the SQL servers instances - start Dynamics AX using the reachable SQL server.

为此,我创建了2个AX配置文件(.axc),每个文件都指向一个SQL Server.

To do this, I have created 2 AX configuration files (.axc), each one pointing to a SQL server.

但是,当我尝试启动该服务时,无论使用哪种方式,AX始终会开始使用通过AX服务器配置工具设置的配置.

But when I try to start the service, no mater which way I use, AX always start using the configuration that is set using the AX server configuration tool.

这是我尝试启动AX服务的命令:

Here are the command I've tried to start the AX service :

sc start AOS60$01 -regConfig=Config1
net start AOS60$01 /"-regConfig=Config1"

该服务始终可以成功启动,但是不关心regConfig参数.

The service always start successfully, but doesn't care about the regConfig parameter.

作为任何人都想知道如何解决此问题?

As anybody an idea about how to solve this issue?

此致

Thomas T.

使用-regConfig参数启动服务后,寻找了一段时间后,我最终放弃并开发了一种直接编辑注册表项的方法启动配置值.

After looking for a while after a way to start the service with the -regConfig parameter, I finally gave up and developped a method which directly edit the Registry key holding the startup configuration value.

 private void UpdateRegistry(string parameter)
        {
            RegistryKey key = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\services\\Dynamics Server\\6.0\\01", true);
            key.SetValue("Current", parameter, RegistryValueKind.String);
            key.Close();
        }

 public void StartLocalServiceWithCLI(string serviceToStart, string parameter)
        {
            try
            {
                UpdateRegistry(parameter);

                Process process = new System.Diagnostics.Process();
                ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                startInfo.FileName = "cmd.exe";
                startInfo.Arguments = string.Format("/C sc start {0} ", serviceToStart);
                process.StartInfo = startInfo;
                process.Start();

                logger.WriteInfo(string.Format("Process {0} starting,  parameters [{1}]", serviceToStart, parameter));

            }
            catch (Exception e)
            {
                logger.WriteError(string.Format("Error starting process {0}, parameters [{1}]\nError details :{2}", serviceToStart, parameter, e.Message));
            }
        }