﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-软件设计开发</title><link>http://www.cnblogs.com/virusswb/</link><description>.NET UML OO DataBase</description><language>zh-cn</language><lastBuildDate>Sat, 04 Jul 2009 09:39:29 GMT</lastBuildDate><pubDate>Sat, 04 Jul 2009 09:39:29 GMT</pubDate><ttl>60</ttl><item><title>无法保存webpart的属性设置，发生意外，异常来自 HRESULT:0x80020009(DISP_E_EXCEPTION)</title><link>http://www.cnblogs.com/virusswb/archive/2009/05/18/1459098.html</link><dc:creator>virus</dc:creator><author>virus</author><pubDate>Mon, 18 May 2009 00:48:00 GMT</pubDate><guid>http://www.cnblogs.com/virusswb/archive/2009/05/18/1459098.html</guid><wfw:comment>http://www.cnblogs.com/virusswb/comments/1459098.html</wfw:comment><comments>http://www.cnblogs.com/virusswb/archive/2009/05/18/1459098.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cnblogs.com/virusswb/comments/commentRss/1459098.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/virusswb/services/trackbacks/1459098.html</trackback:ping><description><![CDATA[<p>&nbsp; &nbsp; 还有就是今天发现的一个问题，我写了一些helper的类，比如说获取某一个列表存放的字典值，就是键值对，根据键获取值，开始我在这个方法中使用了</p>
<p>&nbsp; using(SPSite site=SPContext.Current.Site)</p>
<p>{&nbsp;</p>
<p>&nbsp; using(SPWeb web=SPContext.Current.Web)</p>
<p>{<br />
&nbsp; &nbsp; SPList list=............</p>
<p>&nbsp; &nbsp; ............<br />
}<br />
}<br />
</p>
<p>&nbsp; &nbsp; 在用户控件中调用了这个helper类的方法之后，编译成功。添加这个webpart的时候，提示&#8220;无法保存webpart的属性设置，发生意外，异常来自 HRESULT:0x80020009(DISP_E_EXCEPTION)&#8221;的错误信息，后来经过断点跟踪，而且代码前天还没有问题，就是在添加了这个helper类就出问题了，我把这个类库生成的dll从bin目录删除，把获取键值对的代码写在webpart中就没有问题了，所以判断是上面这段代码出了问题。</p>
<p>&nbsp; &nbsp; 跟踪调试发现是在引用的方法中最好不要使用using来释放SPSite和SPWeb，应为在调用地方就是用了using来打开SPSite和SPWeb了，在传入方法之后，在方法中在写using的话，就会出现这个问题。然后所有的webpart都不能添加，也不能修改属性了。开始以为出了什么大问题，很是着急。</p>
<p>&nbsp; &nbsp; 其实也是using的错误使用，在帮助类的方法中不能释放外部的资源，否则外部继续使用的时候就会有问题，可能是因为被内部方法释放了，找不到的缘故吧，不知道理解的对不对呢？有知道具体原因的，可以告知我。</p>
<p>&nbsp; &nbsp; 想想这个错误，也可能不止sharepoint编程会碰到，在其他时候也可能会碰到，应该是编程 的方式方法出错了吧。</p>
<img src ="http://www.cnblogs.com/virusswb/aggbug/1459098.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47970/" target="_blank">19岁天才黑客发布首个iPhone 3GS破解软件</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item></channel></rss>