C# 使用Adomd连接到Analysis service时出错

C# 使用Adomd连接到Analysis service时出错,c#,asp.net-core,ssas,connection-string,analysisservices,C#,Asp.net Core,Ssas,Connection String,Analysisservices,当我试图连接到分析服务时,出现了一个异常 我的代码 using AdomdConnection conn = new AdomdConnection("Data Source=.\\MSSQL2019;Catalog=OLAP1"); try { conn.Open(); string commandText = query; AdomdCommand cmd = new

当我试图连接到分析服务时,出现了一个异常

我的代码

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.
使用AdomdConnection conn=new AdomdConnection(“数据源=。\\MSSQL2019;目录=OLAP1”);
尝试
{
conn.Open();
string commandText=查询;
AdomdCommand=newadomdcommand(commandText,conn);
AdomdDataReader dr=cmd.ExecuteReader();
List DIMENTIONEMS=新列表();
while(dr.Read())
{
//...
}
康涅狄格州关闭();
返回维度;
}
捕获(例外情况除外)
{
logger.LogError(ex);
返回新列表();
}
JSON对象末尾包含一个逗号,此模式不支持该逗号。更改读卡器选项。行号:23 | BytePositionLine:4。

例外情况

JSON对象末尾包含一个逗号,此模式不支持该逗号。更改读卡器选项。行号:23 | BytePositionLine: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
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader&Json,ExceptionResource,Byte nextByte,ReadOnlySpan`1字节)
在System.Text.Json.Utf8JsonReader.ConsumerNextTokenUntilaAfterallCommentsKipped(字节标记)处
位于System.Text.Json.Utf8JsonReader.ConsumeNextToken(字节标记)
位于System.Text.Json.Utf8JsonReader.consumernextotokenorrollback(字节标记)
位于System.Text.Json.Utf8JsonReader.ReadSingleSegment()处
在System.Text.Json.Utf8JsonReader.Read()处
在System.Text.Json.JsonDocument.Parse(ReadOnlySpan`1 utf8JsonSpan、Utf8JsonReader、MetadataDb和database、StackRowStack和stack)
在System.Text.Json.JsonDocument.Parse(ReadOnlyMemory`1 utf8Json,JsonReaderOptions readerOptions,Byte[]extralentedbytes)
在System.Text.Json.JsonDocument.Parse(流utf8Json,JsonDocumentOptions)
位于Microsoft.AnalysisServices.Platform.Configuration.ConfigurationHelper.TryLoadConfigurationFromJson(字符串文件名,IDictionary`2配置)
位于Microsoft.AnalysisServices.Platform.Configuration.ConfigurationHelper.LoadConfiguration(IDictionary`2配置)
在Microsoft.AnalysisServices.Platform.Configuration.ConfigurationHelper.EnsureConfigurationsLoaded()上
在Microsoft.AnalysisServices.Platform.Configuration.ConfigurationHelper.get_Connectivity()中
位于Microsoft.AnalysisServices.AdomdClient.XMLACLlient.GetTcpClient(IConnectivityOwner所有者,ConnectionInfo ConnectionInfo)
在Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenTCP连接(ConnectionInfo ConnectionInfo,SecurityMode SecurityMode)
在Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenConnectionAndCheckIfSessionTokenNeeded(ConnectionInfo ConnectionInfo)上
在Microsoft.AnalysisServices.AdomdClient.XmlaClient.c__DisplayClass92_0.b__0()上
位于Microsoft.AnalysisServices.Platform.Security.TransparentUserContext.ExecuteInUserContextImpl[TResult](函数'1操作)
在Microsoft.AnalysisServices.Platform.Security.UserContext.ExecuteInUserContext[TResult](Func`1操作)
在Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenConnection(需要ConnectionInfo、ConnectionInfo、Boolean和IsSessionToken)
在Microsoft.AnalysisServices.AdomdClient.XMLACLlient.Connect(ConnectionInfo ConnectionInfo,Boolean beginSession)
位于Microsoft.AnalysisServices.AdomdClient.XmlaClient.GetInstancePort(IConnectivityOwner所有者,ConnectionInfo ConnectionInfo)
位于Microsoft.AnalysisServices.AdomdClient.XMLACLlient.GetTcpClient(IConnectivityOwner所有者,ConnectionInfo ConnectionInfo)
在Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenTCP连接(ConnectionInfo ConnectionInfo,SecurityMode SecurityMode)
在Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenConnectionAndCheckIfSessionTokenNeeded(ConnectionInfo ConnectionInfo)上
在Microsoft.AnalysisServices.AdomdClient.XmlaClient.c__DisplayClass92_0.b__0()上
位于Microsoft.AnalysisServices.Platform.Security.TransparentUserContext.ExecuteInUserContextImpl[TResult](函数'1操作)
在Microsoft.AnalysisServices.Platform.Security.UserContext.ExecuteInUserContext[TResult](Func`1操作)
在Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenConnection(需要ConnectionInfo、ConnectionInfo、Boolean和IsSessionToken)
在Microsoft.AnalysisServices.AdomdClient.XMLACLlient.Connect(ConnectionInfo ConnectionInfo,Boolean beginSession)
位于Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Connect()处
位于Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Microsoft.AnalysisServices.AdomdClient.AdomdConnection.IXmlaClientProviderEx.ConnectXmla()
在Microsoft.AnalysisServices.AdomdClient.AdomdConnection.ConnectToXMLA(布尔createSession,布尔isHTTP)
在Microsoft.AnalysisServices.AdomdClient.AdomdConnection.Open()上
位于D:\Nikamooz\PB\DMP\src\05.Endpoints\DMP.Endpoints.Web.MVC.infrastractors.SqlServerAnalysisServices.AdomdRowLevelSecurityRepository.getdimites()中的DMP.Endpoints.Web.MVC.infrastractors.SqlServerAnalysisServices.AdomdRepository.cs:第32行

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