0

当我尝试连接到分析服务时,我遇到了异常。

我的代码

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.

在此处输入图像描述

例外

JSON 对象末尾包含一个逗号,此模式不支持该逗号。更改阅读器选项。行号:23 | 字节位置内线:4。

堆栈跟踪

    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
4

1 回答 1

0

我猜这个异常来自你没有给出代码“//...”,是json字符串转换为列表实体异常

于 2020-11-25T08:43:02.203 回答