{"id":843,"date":"2008-09-08T09:56:27","date_gmt":"2008-09-08T08:56:27","guid":{"rendered":"http:\/\/www.craigmurphy.com\/blog\/?p=843"},"modified":"2008-09-08T09:56:27","modified_gmt":"2008-09-08T08:56:27","slug":"the-importance-of-calling-close","status":"publish","type":"post","link":"http:\/\/www.craigmurphy.com\/blog\/?p=843","title":{"rendered":"The importance of calling .Close()"},"content":{"rendered":"<p>Courtesy of <a href=\"http:\/\/www.andrewwestgarth.co.uk\/Blog\/\">Andrew Westgarth<\/a>, via IM, I found myself look at Visual Basic code last week.  Andrew&#8217;s &#8220;designer&#8221; was having problems editing some files that made up an application that Andrew was developing&#8230;seemed that something was keeping a lock on the files such that they couldn&#8217;t be edited.  I suggested a couple of things, including hard-coding the filename (avoiding use of Server.MapPath) just to see what happened.  <\/p>\n<p>However, after a little experimentation, it turns out that the XmlReader instance wasn&#8217;t being closed and as such was keeping a lock on the XSL\/T file in question.  The solution was to call the .Close() method.  It&#8217;s obvious now, however sometimes whilst in thick of it, it&#8217;s very easy forget to call such methods, nobody&#8217;s perfect.  <\/p>\n<p>Andrew provides a full write-up over here:<\/p>\n<p><strong>***warning contains VisualBasic code***<\/strong><br \/>\n<a href=\"http:\/\/www.andrewwestgarth.co.uk\/Blog\/post\/2008\/09\/05\/Cant-Save-your-XSLT-File-Have-You-Closed-Your-XMLReader.aspx\">Can&#8217;t Save your XSL\/T File? Have You Closed Your XMLReader?\/a><\/p>\n<p>Technorati Tags: <a href=\"http:\/\/technorati.com\/tag\/Server.MapPath\" rel=\"tag\">Server.MapPath<\/a>, <a href=\"http:\/\/technorati.com\/tag\/XMLReader\" rel=\"tag\">XMLReader<\/a>, <a href=\"http:\/\/technorati.com\/tag\/XMLTextReader\" rel=\"tag\">XMLTextReader<\/a>, <a href=\"http:\/\/technorati.com\/tag\/Close\" rel=\"tag\">Close<\/a>, <a href=\"http:\/\/technorati.com\/tag\/lock\" rel=\"tag\">lock<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Courtesy of Andrew Westgarth, via IM, I found myself look at Visual Basic code last week. Andrew&#8217;s &#8220;designer&#8221; was having problems editing some files that made up an application that Andrew was developing&#8230;seemed that something was keeping a lock on the files such that they couldn&#8217;t be edited. I suggested a couple of things, including &hellip; <a href=\"http:\/\/www.craigmurphy.com\/blog\/?p=843\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">The importance of calling .Close()<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,22,3],"tags":[],"class_list":["post-843","post","type-post","status-publish","format-standard","hentry","category-net","category-community","category-development"],"_links":{"self":[{"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=843"}],"version-history":[{"count":0,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/843\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=843"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}