i use AMO to connect MSAS2005. Seems everything is fine except i do like this:
I try to restart the Analysis Service, and then connect to the server. This will cause windows prompt msmdsrv.exe error or debug info sometimes. This comes with the Connect() methed, but the codes will continue running - that means the code doesn't throw exceptions and executed as usual. I tried to sleep the thread for a while(Like in code make 10 seconds sleeping) but cann't pass the test for every time. Coding as below:
ControlService("MSSQLServerOLAPService", ServicesAccess.ServiceAction.Restart) //using ServiceController class to restart the windows service
System.Threading.Thread.Sleep(10000); //Even sleep the process for 10 Seconds
Server server = new Server();
server.Connect("localhost");
... ...
bool ControlService(string strServiceName, ServiceAction action)
{
try
{
oService = new ServiceController(strServiceName);
if (action == ServiceAction.Stop || action == ServiceAction.Restart)
{
if (!oService.Status.Equals(System.ServiceProcess.ServiceControllerStatus.Stopped) && oService.CanStop)
{
oService.Stop();
oService.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Stopped);
}
}
if (action == ServiceAction.Start || action == ServiceAction.Restart)
{
if (!oService.Status.Equals(System.ServiceProcess.ServiceControllerStatus.Running))
{
oService.Start();
oService.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Running);
}
}
}
catch (Exception e)
{
throw e;
}
return true;
}
Sometimes you need more than 10 sec for Analysis Server to start.
As for the rest. It is hard to say what is going on. If you are able to restart Analysis Server using service control manager (SCM) and then connect to it from your AMO application that would mean your ServiceControl code is not functioning correctly.
Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
yes, this is the problem i tried to describe.
we don't know if the analysis service is ready to connect even we get its "running" status from the codes. And if we connect it at this time, it will tell us it's crashed.
No comments:
Post a Comment