江南白衣

陌上發花,可以緩緩醉矣
忍把浮名,換了淺斟低唱
我不是聖賢豪士,我衹有一腔熱血
posts - 113, comments - 418, trackbacks - 14, articles - 0
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理
原文地址:http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2001893&SiteID=1 I replace 
   I replace the reference assembly System.Data.SqlServerCe with version 3.5 beta2 in Microsoft.Practices.EnterpriseLibrary.Data.SqlCe. When I used the Data.SqlCe block in application, an exception ("Cannot access a disposed object named SqlCeConnection") threw. This didn't occur in SSCE 3.5 beta1 and early versions.

   Finally I found the difference between beta1 and beta2.

   In the SqlCeConnection class, there is a RemoveWeakReference method. this is code snippet of beta1:

internal void RemoveWeakReference(object value)
            {
            if (this.weakReferenceCache != null)
            {
            this.weakReferenceCache.Remove(value);
            }
            }

 and this is for beta2:


internal void RemoveWeakReference(object value)
            {
            if (this.weakReferenceCache == null)
            {
            throw new ObjectDisposedException("SqlCeConnection");
            }
            this.weakReferenceCache.Remove(value);
            }
            


So, if we dispose a connection before a command, such as:
SqlCeConnection cn;
SqlCeCommand cmd;
...
cn.Dispose();
cmd.Dispose(); // Error, an exception will be threw.
Is it a bug of Beta2?

=================================================
This is a issue in Beta2. Most probably we will fix in SSCE 3.5 RTM. The Bug Id: 13211 tracks this issue.

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2007-11-08 13:43 编辑过


相关链接: