Error in Connecting to Analysis service with Adomd

626 views Asked by At

When i was trying to connect to analysis service i have an exception.

my code

using AdomdConnection conn = new AdomdConnection("Data Source=.\\MSSQL2019;Catalog=OLAP1");
        try
        {
            conn.Open();
            string commandText = query;

            AdomdCommand cmd = new AdomdCommand(commandText, conn);
            AdomdDataReader dr = cmd.ExecuteReader();
            List<DimentionItemDto> dimentionItems = new List<DimentionItemDto>();
            while (dr.Read())
            {
                 //...
            }

            conn.Close();
            return dimentionItems;
        }
        catch (Exception ex)
        {
            logger.LogError(ex);
            return new List<DimentionItemDto>();
        }

The JSON object contains a trailing comma at the end which is not supported in this mode. Change the reader options. LineNumber: 23 | BytePositionInLine: 4.

enter image description here

exception

The JSON object contains a trailing comma at the end which is not supported in this mode. Change the reader options. LineNumber: 23 | BytePositionInLine: 4.

stacktrace

    at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.ConsumeNextTokenUntilAfterAllCommentsAreSkipped(Byte marker)
   at System.Text.Json.Utf8JsonReader.ConsumeNextToken(Byte marker)
   at System.Text.Json.Utf8JsonReader.ConsumeNextTokenOrRollback(Byte marker)
   at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.JsonDocument.Parse(ReadOnlySpan`1 utf8JsonSpan, Utf8JsonReader reader, MetadataDb& database, StackRowStack& stack)
   at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory`1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedBytes)
   at System.Text.Json.JsonDocument.Parse(Stream utf8Json, JsonDocumentOptions options)
   at Microsoft.AnalysisServices.Platform.Configuration.ConfigurationHelper.TryLoadConfigurationFromJson(String fileName, IDictionary`2 configuration)
   at Microsoft.AnalysisServices.Platform.Configuration.ConfigurationHelper.LoadConfiguration(IDictionary`2 configuration)
   at Microsoft.AnalysisServices.Platform.Configuration.ConfigurationHelper.EnsureConfigurationIsLoaded()
   at Microsoft.AnalysisServices.Platform.Configuration.ConfigurationHelper.get_Connectivity()
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.GetTcpClient(IConnectivityOwner owner, ConnectionInfo connectionInfo)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenTcpConnection(ConnectionInfo connectionInfo, SecurityMode securityMode)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenConnectionAndCheckIfSessionTokenNeeded(ConnectionInfo connectionInfo)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.<>c__DisplayClass92_0.<OpenConnection>b__0()
   at Microsoft.AnalysisServices.Platform.Security.TransparentUserContext.ExecuteInUserContextImpl[TResult](Func`1 action)
   at Microsoft.AnalysisServices.Platform.Security.UserContext.ExecuteInUserContext[TResult](Func`1 action)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenConnection(ConnectionInfo connectionInfo, Boolean& isSessionTokenNeeded)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.Connect(ConnectionInfo connectionInfo, Boolean beginSession)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.GetInstancePort(IConnectivityOwner owner, ConnectionInfo connectionInfo)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.GetTcpClient(IConnectivityOwner owner, ConnectionInfo connectionInfo)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenTcpConnection(ConnectionInfo connectionInfo, SecurityMode securityMode)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenConnectionAndCheckIfSessionTokenNeeded(ConnectionInfo connectionInfo)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.<>c__DisplayClass92_0.<OpenConnection>b__0()
   at Microsoft.AnalysisServices.Platform.Security.TransparentUserContext.ExecuteInUserContextImpl[TResult](Func`1 action)
   at Microsoft.AnalysisServices.Platform.Security.UserContext.ExecuteInUserContext[TResult](Func`1 action)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenConnection(ConnectionInfo connectionInfo, Boolean& isSessionTokenNeeded)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.Connect(ConnectionInfo connectionInfo, Boolean beginSession)
   at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Connect()
   at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Microsoft.AnalysisServices.AdomdClient.AdomdConnection.IXmlaClientProviderEx.ConnectXmla()
   at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.ConnectToXMLA(Boolean createSession, Boolean isHTTP)
   at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.Open()
   at DMP.Endpoints.Web.MVC.Infrastracturs.SqlServerAnalysisServices.AdomdRowLevelSecurityRepository.GetDimItems() in D:\Nikamooz\PB\DMP\src\05.Endpoints\DMP.Endpoints.Web.MVC\Infrastracturs\SqlServerAnalysisServices\AdomdRepository.cs:line 32
1

There are 1 answers

0
ColdCodeHah On

I guess the exception came from you not given code"//...",is json string convert to list entity exception