gpt4 book ai didi

c# - 'NHibernate.Spatial.Type.GeometryType' 处理的“GeoAPI.Geometries.IGeometry”不可序列化

转载 作者:行者123 更新时间:2023-11-30 16:49:46 26 4
gpt4 key购买 nike

我们正在使用几个使用 NHibernate 的网络应用程序连接到 PostGIS 服务器。我们的日志文件充斥着此警告:

the custom type 'GeoAPI.Geometries.IGeometry' handled by 'NHibernate.Spatial.Type.GeometryType' is not Serializable

我使用 Google 进行了搜索,看到很多其他人报告了同样的问题,但我还没有找到任何解决方案。

我什至不确定这是 NHibernate 还是 GeoAPI 的问题。

非常感谢任何帮助。

最佳答案

我可以向您展示导致此警告的一系列事件。

  1. PostGisDialect.cs - 这是与 PostGIS 一起使用的方言。请注意:

    public IGeometryUserType CreateGeometryUserType()
    {
    return new PostGisGeometryType();
    }
  2. PostGisGeometryType - 注意它实现了 GeometryTypeBase。

  3. GeometryTypeBase .请注意:

    public System.Type ReturnedType
    {
    get { return typeof(IGeometry); }
    }
  4. GeometryType.cs - 现在这个用于处理您的几何列映射。请注意:

    this.geometryUserType = SpatialDialect.LastInstantiated.CreateGeometryUserType();
    ...
    public System.Type ReturnedType
    {
    get { return this.geometryUserType.ReturnedType; }
    }
  5. 最后一篇:CustomType :

    if (!userType.ReturnedType.IsSerializable)
    {
    LoggerProvider.LoggerFor(typeof(CustomType)).WarnFormat("the custom type '{0}' handled by '{1}' is not Serializable: ", userType.ReturnedType, userTypeClass);
    }

因此 GeometryType.ReturnValue 应该是可序列化的,以避免出现此警告。 GeometryType 使用 PostGisDialect,后者又使用 PostGisGeometryType,它继承自 GeometryTypeBase,它总是返回 IGeometry 作为 ReturnedType。当然,接口(interface)不能序列化,因此出现此警告(并且它应该对实际上从 GeometryTypeBase 继承的任何几何类型产生相同的警告,例如 Oracle 或 Sql Server)。实现 IGeometry 的实际类型实际上是可序列化的。

摘要是什么?我认为在这种情况下,此检查只会返回误报。也许它应该检查 ReturnType 是否是接口(interface),在这种情况下不产生警告。在此处使用接口(interface)是完全合法的。

实际上有一个 Unresolved 问题:here ,已经 2 岁了,但他们没有深入挖掘以意识到实际问题似乎是什么。我会向他们发布这篇文章的链接,也许他们会修复它。

关于c# - 'NHibernate.Spatial.Type.GeometryType' 处理的“GeoAPI.Geometries.IGeometry”不可序列化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35983333/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com