Microsoft Velocity 在同一类型的不同版本之间进行转换
我在给定类型的不同版本之间从 Microsoft Velocity 缓存中转换缓存对象时遇到问题。
例如,当从两个组件访问 Velocity 缓存时就会出现这种情况:
- 来自代码库的一个版本的网站 来自代码
- 库较新版本的后续版本的 Windows 服务
网站将 Customer 类型的对象放入缓存,Windows 服务从缓存中读取相同的对象,然后尝试在代码库的后续版本的后续版本中转换为“Customer”类型。
这会产生铸造错误,如下所述: http://social.msdn.microsoft .com/Forums/en/velocity/thread/f264c5b1-8cfe-49f3-8b86-711810f88140
如何使用 Microsoft Velocity 避免此转换错误?
有可能避免吗?或者我是否必须采取防御措施:捕获转换异常,从缓存中清除对象,读取新实例并将其保存到缓存中?
I have an issue with casting the cached objects from Microsoft Velocity caching beteween different versions of a given type.
This shows up, for example, when the Velocity cache is accessed from two components:
- a website from one build of the code base
- a Windows service from a later build of a later revision of the code base
The website puts an object of type Customer in the cache, and the Windows service reads the same object from the cache, and then tries to cast to the type Customer' in the later build of a later revision of the code base.
This yields a casting error, like the one described here:
http://social.msdn.microsoft.com/Forums/en/velocity/thread/f264c5b1-8cfe-49f3-8b86-711810f88140
How can I avoid this casting error with Microsoft Velocity?
Is it possible to avoid? Or do I have to be defensive: catch the casting exception, clear the object from the cache, read a new instance, and save that to the cache?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是为了完成此线程在 msdn (http://social.msdn.microsoft.com/Forums/en/velocity/thread/f264c5b1-8cfe-49f3-8b86-711810f88140) 上关闭,
问题在于放置的实体在 App_Code 文件夹下,每次更改代码时都会触发重新编译,而不是预编译库本身。
Just for the sake of completion this thread was closed at msdn (http://social.msdn.microsoft.com/Forums/en/velocity/thread/f264c5b1-8cfe-49f3-8b86-711810f88140)
The problem was with entities being placed under App_Code folder for that was triggering recompile every time the code was changed i.e. rather than a pre-compiled library as such.