Akka.net 使用Akka.Persistence配置时发生System.Format异常

Akka.net 使用Akka.Persistence配置时发生System.Format异常,akka.net,akka.net-cluster,akka.net-persistence,akka.fsharp,Akka.net,Akka.net Cluster,Akka.net Persistence,Akka.fsharp,我正在努力解决解析Akka.Net配置文件时出现的System.Format异常问题 我知道异常源于配置的持久性块: persistence{ journal { plugin = "akka.persistence.journal.sql-server" sql-server { # qualified type name of the SQL Server persistence journal actor

我正在努力解决解析Akka.Net配置文件时出现的System.Format异常问题

我知道异常源于配置的持久性块:

persistence{
    journal {
      plugin = "akka.persistence.journal.sql-server"
        sql-server {
            # qualified type name of the SQL Server persistence journal actor
            class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"

            # dispatcher used to drive journal actor
            plugin-dispatcher = "akka.actor.default-dispatcher"

            # connection string used for database access
            connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

            # default SQL commands timeout
            connection-timeout = 30s

            # SQL server schema name to table corresponding with persistent journal
            schema-name = dbo

            # SQL server table corresponding with persistent journal
            table-name = EventJournal

            # should corresponding journal table be initialized automatically
            auto-initialize = off

            # timestamp provider used for generation of journal entries timestamps
            timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"

            # metadata table
            metadata-table-name = Metadata
        }
    }

    snapshot-store {
        sql-server {

            # qualified type name of the SQL Server persistence journal actor
            class = "Akka.Persistence.SqlServer.Snapshot.SqlServerSnapshotStore, Akka.Persistence.SqlServer"

            # dispatcher used to drive journal actor
            plugin-dispatcher = ""akka.actor.default-dispatcher""

            # connection string used for database access
            connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

            # default SQL commands timeout
            connection-timeout = 30s

            # SQL server schema name to table corresponding with persistent journal
            schema-name = dbo

            # SQL server table corresponding with persistent journal
            table-name = SnapshotStore

            # should corresponding journal table be initialized automatically
            auto-initialize = off
        }
    }
}
Binding session to 'C:\Users\Snimrod\Desktop\Akkling-master\examples\../src/Akkling.Cluster.Sharding/bin/Debug/Akka.dll'...
System.FormatException: Unknown escape code: S
   at Akka.Configuration.Hocon.HoconTokenizer.PullEscapeSequence()
   at Akka.Configuration.Hocon.HoconTokenizer.PullQuotedText()
   at Akka.Configuration.Hocon.HoconTokenizer.PullValue()
   at Akka.Configuration.Hocon.Parser.ParseValue(HoconValue owner, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
>    at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseText(String text, Func`2 includeCallback)
   at Akka.Configuration.ConfigurationFactory.ParseString(String hocon)
   at Akkling.Configuration.parse(String arg00) in C:\Users\Snimrod\Desktop\Akkling-master\src\Akkling\Spawning.fs:line 30
   at FSI_0003.configWithPort[a](a port) in C:\Users\Snimrod\Desktop\Akkling-master\examples\cluster-sharding.fsx:line 148
   at <StartupCode$FSI_0003>.$FSI_0003.main@() in C:\Users\Snimrod\Desktop\Akkling-master\examples\cluster-sharding.fsx:line 154
Stopped due to error
let configWithPort port =
    let config = Configuration.parse ("""
        akka {
            actor {
              provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
              serializers {
                hyperion = "Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion"
              }
              serialization-bindings {
                "System.Object" = hyperion
              }
            }
          remote {
            helios.tcp {
              public-hostname = "localhost"
              hostname = "localhost"
              port = """ + port.ToString() + """
            }
          }
          cluster {
            auto-down-unreachable-after = 5s
            seed-nodes = [ "akka.tcp://cluster-system@localhost:2551/" ]
          }

          # persistence {
          #  journal.plugin = "akka.persistence.journal.inmem"
          #  snapshot-store.plugin = "akka.persistence.snapshot-store.local"
          # }

          persistence{
              journal {
                plugin = "akka.persistence.journal.sql-server"
                  sql-server {
                      # qualified type name of the SQL Server persistence journal actor
                      class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"

                      # dispatcher used to drive journal actor
                      plugin-dispatcher = "akka.actor.default-dispatcher"

                      # connection string used for database access
                      connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

                      # default SQL commands timeout
                      connection-timeout = 30s

                      # SQL server schema name to table corresponding with persistent journal
                      schema-name = dbo

                      # SQL server table corresponding with persistent journal
                      table-name = EventJournal

                      # should corresponding journal table be initialized automatically
                      auto-initialize = off

                      # timestamp provider used for generation of journal entries timestamps
                      timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"

                      # metadata table
                      metadata-table-name = Metadata
                  }
              }

              snapshot-store {
                  sql-server {

                      # qualified type name of the SQL Server persistence journal actor
                      class = "Akka.Persistence.SqlServer.Snapshot.SqlServerSnapshotStore, Akka.Persistence.SqlServer"

                      # dispatcher used to drive journal actor
                      plugin-dispatcher = ""akka.actor.default-dispatcher""

                      # connection string used for database access
                      connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

                      # default SQL commands timeout
                      connection-timeout = 30s

                      # SQL server schema name to table corresponding with persistent journal
                      schema-name = dbo

                      # SQL server table corresponding with persistent journal
                      table-name = SnapshotStore

                      # should corresponding journal table be initialized automatically
                      auto-initialize = off
                  }
              }
          }
        }
        """)
config.WithFallback(ClusterSingletonManager.DefaultConfig())
let system1 = System.create "cluster-system" (configWithPort 2551)
反映异常的输出如下:

persistence{
    journal {
      plugin = "akka.persistence.journal.sql-server"
        sql-server {
            # qualified type name of the SQL Server persistence journal actor
            class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"

            # dispatcher used to drive journal actor
            plugin-dispatcher = "akka.actor.default-dispatcher"

            # connection string used for database access
            connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

            # default SQL commands timeout
            connection-timeout = 30s

            # SQL server schema name to table corresponding with persistent journal
            schema-name = dbo

            # SQL server table corresponding with persistent journal
            table-name = EventJournal

            # should corresponding journal table be initialized automatically
            auto-initialize = off

            # timestamp provider used for generation of journal entries timestamps
            timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"

            # metadata table
            metadata-table-name = Metadata
        }
    }

    snapshot-store {
        sql-server {

            # qualified type name of the SQL Server persistence journal actor
            class = "Akka.Persistence.SqlServer.Snapshot.SqlServerSnapshotStore, Akka.Persistence.SqlServer"

            # dispatcher used to drive journal actor
            plugin-dispatcher = ""akka.actor.default-dispatcher""

            # connection string used for database access
            connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

            # default SQL commands timeout
            connection-timeout = 30s

            # SQL server schema name to table corresponding with persistent journal
            schema-name = dbo

            # SQL server table corresponding with persistent journal
            table-name = SnapshotStore

            # should corresponding journal table be initialized automatically
            auto-initialize = off
        }
    }
}
Binding session to 'C:\Users\Snimrod\Desktop\Akkling-master\examples\../src/Akkling.Cluster.Sharding/bin/Debug/Akka.dll'...
System.FormatException: Unknown escape code: S
   at Akka.Configuration.Hocon.HoconTokenizer.PullEscapeSequence()
   at Akka.Configuration.Hocon.HoconTokenizer.PullQuotedText()
   at Akka.Configuration.Hocon.HoconTokenizer.PullValue()
   at Akka.Configuration.Hocon.Parser.ParseValue(HoconValue owner, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
>    at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseText(String text, Func`2 includeCallback)
   at Akka.Configuration.ConfigurationFactory.ParseString(String hocon)
   at Akkling.Configuration.parse(String arg00) in C:\Users\Snimrod\Desktop\Akkling-master\src\Akkling\Spawning.fs:line 30
   at FSI_0003.configWithPort[a](a port) in C:\Users\Snimrod\Desktop\Akkling-master\examples\cluster-sharding.fsx:line 148
   at <StartupCode$FSI_0003>.$FSI_0003.main@() in C:\Users\Snimrod\Desktop\Akkling-master\examples\cluster-sharding.fsx:line 154
Stopped due to error
let configWithPort port =
    let config = Configuration.parse ("""
        akka {
            actor {
              provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
              serializers {
                hyperion = "Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion"
              }
              serialization-bindings {
                "System.Object" = hyperion
              }
            }
          remote {
            helios.tcp {
              public-hostname = "localhost"
              hostname = "localhost"
              port = """ + port.ToString() + """
            }
          }
          cluster {
            auto-down-unreachable-after = 5s
            seed-nodes = [ "akka.tcp://cluster-system@localhost:2551/" ]
          }

          # persistence {
          #  journal.plugin = "akka.persistence.journal.inmem"
          #  snapshot-store.plugin = "akka.persistence.snapshot-store.local"
          # }

          persistence{
              journal {
                plugin = "akka.persistence.journal.sql-server"
                  sql-server {
                      # qualified type name of the SQL Server persistence journal actor
                      class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"

                      # dispatcher used to drive journal actor
                      plugin-dispatcher = "akka.actor.default-dispatcher"

                      # connection string used for database access
                      connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

                      # default SQL commands timeout
                      connection-timeout = 30s

                      # SQL server schema name to table corresponding with persistent journal
                      schema-name = dbo

                      # SQL server table corresponding with persistent journal
                      table-name = EventJournal

                      # should corresponding journal table be initialized automatically
                      auto-initialize = off

                      # timestamp provider used for generation of journal entries timestamps
                      timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"

                      # metadata table
                      metadata-table-name = Metadata
                  }
              }

              snapshot-store {
                  sql-server {

                      # qualified type name of the SQL Server persistence journal actor
                      class = "Akka.Persistence.SqlServer.Snapshot.SqlServerSnapshotStore, Akka.Persistence.SqlServer"

                      # dispatcher used to drive journal actor
                      plugin-dispatcher = ""akka.actor.default-dispatcher""

                      # connection string used for database access
                      connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

                      # default SQL commands timeout
                      connection-timeout = 30s

                      # SQL server schema name to table corresponding with persistent journal
                      schema-name = dbo

                      # SQL server table corresponding with persistent journal
                      table-name = SnapshotStore

                      # should corresponding journal table be initialized automatically
                      auto-initialize = off
                  }
              }
          }
        }
        """)
config.WithFallback(ClusterSingletonManager.DefaultConfig())
let system1 = System.create "cluster-system" (configWithPort 2551)
以下行导致我描述的异常:

persistence{
    journal {
      plugin = "akka.persistence.journal.sql-server"
        sql-server {
            # qualified type name of the SQL Server persistence journal actor
            class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"

            # dispatcher used to drive journal actor
            plugin-dispatcher = "akka.actor.default-dispatcher"

            # connection string used for database access
            connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

            # default SQL commands timeout
            connection-timeout = 30s

            # SQL server schema name to table corresponding with persistent journal
            schema-name = dbo

            # SQL server table corresponding with persistent journal
            table-name = EventJournal

            # should corresponding journal table be initialized automatically
            auto-initialize = off

            # timestamp provider used for generation of journal entries timestamps
            timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"

            # metadata table
            metadata-table-name = Metadata
        }
    }

    snapshot-store {
        sql-server {

            # qualified type name of the SQL Server persistence journal actor
            class = "Akka.Persistence.SqlServer.Snapshot.SqlServerSnapshotStore, Akka.Persistence.SqlServer"

            # dispatcher used to drive journal actor
            plugin-dispatcher = ""akka.actor.default-dispatcher""

            # connection string used for database access
            connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

            # default SQL commands timeout
            connection-timeout = 30s

            # SQL server schema name to table corresponding with persistent journal
            schema-name = dbo

            # SQL server table corresponding with persistent journal
            table-name = SnapshotStore

            # should corresponding journal table be initialized automatically
            auto-initialize = off
        }
    }
}
Binding session to 'C:\Users\Snimrod\Desktop\Akkling-master\examples\../src/Akkling.Cluster.Sharding/bin/Debug/Akka.dll'...
System.FormatException: Unknown escape code: S
   at Akka.Configuration.Hocon.HoconTokenizer.PullEscapeSequence()
   at Akka.Configuration.Hocon.HoconTokenizer.PullQuotedText()
   at Akka.Configuration.Hocon.HoconTokenizer.PullValue()
   at Akka.Configuration.Hocon.Parser.ParseValue(HoconValue owner, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
>    at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
   at Akka.Configuration.Hocon.Parser.ParseText(String text, Func`2 includeCallback)
   at Akka.Configuration.ConfigurationFactory.ParseString(String hocon)
   at Akkling.Configuration.parse(String arg00) in C:\Users\Snimrod\Desktop\Akkling-master\src\Akkling\Spawning.fs:line 30
   at FSI_0003.configWithPort[a](a port) in C:\Users\Snimrod\Desktop\Akkling-master\examples\cluster-sharding.fsx:line 148
   at <StartupCode$FSI_0003>.$FSI_0003.main@() in C:\Users\Snimrod\Desktop\Akkling-master\examples\cluster-sharding.fsx:line 154
Stopped due to error
let configWithPort port =
    let config = Configuration.parse ("""
        akka {
            actor {
              provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
              serializers {
                hyperion = "Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion"
              }
              serialization-bindings {
                "System.Object" = hyperion
              }
            }
          remote {
            helios.tcp {
              public-hostname = "localhost"
              hostname = "localhost"
              port = """ + port.ToString() + """
            }
          }
          cluster {
            auto-down-unreachable-after = 5s
            seed-nodes = [ "akka.tcp://cluster-system@localhost:2551/" ]
          }

          # persistence {
          #  journal.plugin = "akka.persistence.journal.inmem"
          #  snapshot-store.plugin = "akka.persistence.snapshot-store.local"
          # }

          persistence{
              journal {
                plugin = "akka.persistence.journal.sql-server"
                  sql-server {
                      # qualified type name of the SQL Server persistence journal actor
                      class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"

                      # dispatcher used to drive journal actor
                      plugin-dispatcher = "akka.actor.default-dispatcher"

                      # connection string used for database access
                      connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

                      # default SQL commands timeout
                      connection-timeout = 30s

                      # SQL server schema name to table corresponding with persistent journal
                      schema-name = dbo

                      # SQL server table corresponding with persistent journal
                      table-name = EventJournal

                      # should corresponding journal table be initialized automatically
                      auto-initialize = off

                      # timestamp provider used for generation of journal entries timestamps
                      timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"

                      # metadata table
                      metadata-table-name = Metadata
                  }
              }

              snapshot-store {
                  sql-server {

                      # qualified type name of the SQL Server persistence journal actor
                      class = "Akka.Persistence.SqlServer.Snapshot.SqlServerSnapshotStore, Akka.Persistence.SqlServer"

                      # dispatcher used to drive journal actor
                      plugin-dispatcher = ""akka.actor.default-dispatcher""

                      # connection string used for database access
                      connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

                      # default SQL commands timeout
                      connection-timeout = 30s

                      # SQL server schema name to table corresponding with persistent journal
                      schema-name = dbo

                      # SQL server table corresponding with persistent journal
                      table-name = SnapshotStore

                      # should corresponding journal table be initialized automatically
                      auto-initialize = off
                  }
              }
          }
        }
        """)
config.WithFallback(ClusterSingletonManager.DefaultConfig())
let system1 = System.create "cluster-system" (configWithPort 2551)

总之,我是Akka.Net的新手,正在努力解决出现此异常的原因。

看来HOCON解析器可能在
\
方面存在问题,并将其视为转义字符。将其更改为
\\
应该可以解决这个问题。

我猜您的连接字符串中的\正在破坏语法分析器。尝试改用\\。这就解决了它!你能把这个作为答案吗?