Dynamics AX 2012 RegConfig does not work

╄→尐↘猪︶ㄣ 提交于 2019-12-13 01:34:37

问题


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.

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.

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

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.

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

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

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

As anybody an idea about how to solve this issue?

Regards,

Thomas T.


回答1:


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));
            }
        }


来源:https://stackoverflow.com/questions/26466035/dynamics-ax-2012-regconfig-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!