I’ve written some code that runs an MDX query against an SQL Server Analysis services. Unit tests on my dev machine work fine – however the TeamCity installation also runs the unit tests and only the ones connecting to the analysis services give an exception stating:
Test method GetNumCompaniesPerIndustryTest threw exception:
Microsoft.AnalysisServices.AdomdClient.AdomdConnectionException: The connection either timed out or was lost.
---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
This is the error I was getting before when my connection string wasn’t right. The weird thing is that the server with TeamCity also has a VS 2010 installation so I can open the solution form the /buildAgent/work folder and run the unit tests. All tests work fine from VS – so there’s no connection problem it seems.
Connection string is in a settings file inside the DLL in application scope.
Turned out that the QA environment was running in a different Application Pool with corresponding user. I had to add this user to the BI database users.