找回密码
 立即注册

QQ登录

只需一步,快速开始

tingche

银牌会员

17

主题

76

帖子

3877

积分

银牌会员

积分
3877

活字格认证

tingche
银牌会员   /  发表于:2013-12-11 19:13  /   查看:6876  /  回复:8
在完成用 spread7j 替换 spread5j 后,项目中对 asp.net内置方法
SetAndReleaseItemExclusive(ByVal context As HttpContext, ByVal id As String, ByVal item As SessionStateStoreData, ByVal lockId As Object, ByVal newItem As Boolean)
进行了重写,在这个方法中,对 item.items 进行序列化后报错,代码如下
Dim sessItems As Byte() = Serialize(DirectCast(item.Items, SessionStateItemCollection))

对比spread 5j 与 spread7j 后报错处 报错为 items项里spread 5内 为二进制流Stream.IO.MemoryStream,spread7内为{g},不能完成序列化, 请问你们有碰到过类似问题吗?如果有,能提供点解决经验吗? 非常感谢!

8 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-12-12 13:34:00
沙发
回复 1楼tingche的帖子

tingche 你好,
不好意思,我们之前也没有遇到过类似问题。
如果需要,可以上传一个简单的 Demo 过来,我们协助调查看是否能给点建议。
回复 使用道具 举报
tingche
银牌会员   /  发表于:2013-12-16 15:27:00
板凳
在spread7j 替换 spread5j 的时候,出现报错提示,
错误提示如下:

{"Type 'gx' in Assembly 'FarPoint.Web.SpreadJ, Version=7.0.4001.2010, Culture=neutral, PublicKeyToken=a5fa960294d899e7' is not marked as serializable."}

请问你们是否有这样问题的解决 经历?能解决吗?请教!!!

或者说,在spread7J,运用到会话存储提供程序的时候,你们有没有Demo?有的话,能否发个给我调试下?

我在spread论坛里找到了如下资料,http://gcdn.grapecity.com/showtopic-10334.html
但是解决过程中没有找到资料里的SaveOrLoadSheetState属性,请帮忙看看!!
另外,我们现在用的是日文版的spread, 请问这个解决中文版spread7 session 问题的方法能用吗?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-12-16 17:40:00
地板
回复 3楼tingche的帖子

由于我们没有SpreadJ日文版测试换行,所以我们会使用 Spread 7.0 V2 英文版测试您的问题:

Spread 内置有存储Session的事件,具体使用方式请参考 Demo:
11317.zip (7.57 KB, 下载次数: 898)
回复 使用道具 举报
tingche
银牌会员   /  发表于:2013-12-16 18:59:00
5#
FpSpread1.SaveOrLoadSheetState+=new FarPoint.Web.Spread.SheetViewStateEventHandler(FpSpread1_SaveOrLoadSheetState);

不好意思,帮忙看看这句代码,在vb.net里,好像不能实现,谢谢!
回复 使用道具 举报
tingche
银牌会员   /  发表于:2013-12-17 10:26:00
6#
实际上我遇到的问题,是这样的,

spread7j替换spread5j

spread7j替换spread5j


在web.config中 配置 SESION方式如下:
  <sessionState cookieless="false" regenerateExpiredSessionId="true" mode="Custom" timeout="10" customProvider="SessionStateStore">
      <providers>
        <clear/>
        <add name="SessionStateStore" type="Goe.CommonPresentation.SessionStateStore" connectionStringName="SessionServices" writeExceptionsToEventLog="false" sessionTime="10000"/>
      </providers>
    </sessionState>
    <httpRuntime maxRequestLength="102400" requestValidationMode="2.0"/>

运行后报错:
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.

[SerializationException: Type 'gx' in Assembly 'FarPoint.Web.SpreadJ, Version=7.0.4001.2010, Culture=neutral, PublicKeyToken=a5fa960294d899e7' is not marked as serializable.]
   System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +9472677
   System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +247
   System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +160
   System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) +491
   System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) +54
   System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +542
   System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +133
   System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1762

[HttpException (0x80004005): Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.]
   System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1847
   System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(Object value, BinaryWriter writer) +34
   System.Web.SessionState.SessionStateItemCollection.Serialize(BinaryWriter writer) +638
   Goe.CommonPresentation.SessionStateStore.Serialize(SessionStateItemCollection items) in D:\GSCM_GOE\Goe\CommonPresentation\session\SessionStateStore.vb:428
   Goe.CommonPresentation.SessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) in D:\GSCM_GOE\Goe\CommonPresentation\session\SessionStateStore.vb:155
   System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +807
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +75

与我发出的那个连接所遇到的问题应该是一致的,你们提出的解决思路,我正在验证日文版下是否可行,但遇到vb.net代码下对事件的注册,

Me.FpSpread1.SaveOrLoadSheetState += new FarPoint.Web.Spread.SheetViewStateEventHandler(FpSpread1_SaveOrLoadSheetState)

c#转vb.net问题,vb.net好像不能这么写,

AddHandler fsCommon.SaveOrLoadSheetState, New FarPoint.Web.Spread.SheetViewStateEventHandler(AddressOf fsCommon_SaveOrLoadSheetState)

这么写行吗?

如果代码转换没有问题,经过这么修改后,依然会提示序列化报错,是否需要下载spread更新程序?然后再在后台做以上相应代码处理?

期待你们的帮助,谢谢!!!
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-12-17 15:29:00
7#
回复 6楼tingche的帖子

VB.NET Demo:

11317_VB.NET.zip (34.28 KB, 下载次数: 922)
回复 使用道具 举报
tingche
银牌会员   /  发表于:2013-12-18 13:38:00
8#
很遗憾,没能解决我所面临的问题。

我们在用spread的时候,对session进行了相关处理,用到了SessionStateStore 类 继承SessionStateStoreProviderBase
来对页面会话状态数据进行了存储

现在的问题就是,在获取页面数据的时候,spread7j 替换spread5j 后,在获取页面信息时,出现在了在用spread5j与用spread7j时获取到的信息不一致,相关信息存在截图中的item项内,其中第一项是页面和用户相关信息,没有不一致,但是从第二项开始,spread5j获取到的数据为MemoryStream的数据,而spread7j获取到的数据为{gx},{gx}无法用在后面的序列化上,而这个获取页面信息的过程,是重写SessionStateStoreProviderBase类的SetAndReleaseItemExclusive方法实现的,因此,我们无法干预其获取的过程,也就无法在获取到不合符要求的spread7j的页面信息处进行处理。请教你们是否有思路解决这类问题。另附一张跟踪程序的截图,看是否有助于理解我的问题。程序Demo因为是项目内遇到的问题,无法剥离部分程序出来。请谅解。

再次感谢,并希望有所收获!


session_spread7j_compare_spread5j

session_spread7j_compare_spread5j
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-12-18 17:21:00
9#
回复 8楼tingche的帖子

tingche 你好,

感谢你的详细描述,很抱歉我们没有做过类似的操作。

是否可以获取 Spread7J 在通过 Save 方法转换为 MemoryStream。这样就可以获取 SpreadJ5 时的 item.items[1] 中的值进行序列化了。

仅仅是一点建议,希望能够对你有所帮助。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部