<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" 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/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Tim Mackey's Weblog - .Net General</title>
    <link>http://tim.mackey.ie/</link>
    <description>mostly.Net</description>
    <language>en-ie</language>
    <copyright>Tim Mackey</copyright>
    <lastBuildDate>Sun, 01 Jan 2012 22:19:39 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>tim@mackey.ie</managingEditor>
    <webMaster>tim@mackey.ie</webMaster>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=b2a5320e-a121-4a33-b15b-924638047fe7</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,b2a5320e-a121-4a33-b15b-924638047fe7.aspx</pingback:target>
      <dc:creator>Tim Mackey</dc:creator>
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,b2a5320e-a121-4a33-b15b-924638047fe7.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=b2a5320e-a121-4a33-b15b-924638047fe7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p class="title">
Data truncated to 255 characters with Excel Jet/ODBC driver: <a href="http://support.microsoft.com/kb/189897">http://support.microsoft.com/kb/189897</a><br /></p>
Solution: <a href="http://support.sas.com/kb/31/765.html">http://support.sas.com/kb/31/765.html</a><br /><pre><span style="font-family: monospace;"><strong>My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet\4.0\Engines\Excel<br /></strong></span></pre><p>
Set to 0 to avoid the truncation problem!
</p><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=b2a5320e-a121-4a33-b15b-924638047fe7" /></body>
      <title>Locating the TypeGuessRows registry key on Windows 64-bit operating systems</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,b2a5320e-a121-4a33-b15b-924638047fe7.aspx</guid>
      <link>http://tim.mackey.ie/LocatingTheTypeGuessRowsRegistryKeyOnWindows64bitOperatingSystems.aspx</link>
      <pubDate>Sun, 01 Jan 2012 22:19:39 GMT</pubDate>
      <description>&lt;p class="title"&gt;
Data truncated to 255 characters with Excel Jet/ODBC driver: &lt;a href="http://support.microsoft.com/kb/189897"&gt;http://support.microsoft.com/kb/189897&lt;/a&gt;
&lt;br&gt;
&lt;/p&gt;
Solution: &lt;a href="http://support.sas.com/kb/31/765.html"&gt;http://support.sas.com/kb/31/765.html&lt;/a&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="font-family: monospace;"&gt;&lt;strong&gt;My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet\4.0\Engines\Excel&lt;br&gt;
&lt;/strong&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Set to 0 to avoid the truncation problem!
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=b2a5320e-a121-4a33-b15b-924638047fe7" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,b2a5320e-a121-4a33-b15b-924638047fe7.aspx</comments>
      <category>.Net General</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=ef1b363f-dc12-4106-a797-6d2c37c7b905</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,ef1b363f-dc12-4106-a797-6d2c37c7b905.aspx</pingback:target>
      <dc:creator>Tim Mackey</dc:creator>
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,ef1b363f-dc12-4106-a797-6d2c37c7b905.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=ef1b363f-dc12-4106-a797-6d2c37c7b905</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">I'm using Asp.Net to open excel files and
read the values cell by cell, normally i prefer to import Excel files as a datatable,
but some documents don't fit the strict rows/columns format required for importing
into a DataTable.  the code i'm using is based on <a href="http://dotnetperls.com/excel-interop">this
from dotnetperls</a>.  worked fine for the most part on my dev PC but I had a
few issues trying to get this to work on a 32bit version of excel on a 64 bit Windows
2008 server. 
<br />
here's what i had to do to get it working: 
<br /><ul><li>
disable macros (throwing exceptions opening the workbook), requires a reference to
the Microsoft.Office.Core assembly:<br />
excelApp.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable;  
// disable macros</li><li>
give launch / open permissions to the Excel application in DCOM config, this was tricky
because it isn't shown in a 64 bit OS if the program is 32 bit, i found <a href="http://social.technet.microsoft.com/Forums/en-US/w7itproappcompat/thread/dde69147-a01a-4eb1-8ea9-31adbf874bed/">the
answer here</a>.</li><li>
set the identity in DCOM for Excel to the interactive user.</li></ul><p><br /></p><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=ef1b363f-dc12-4106-a797-6d2c37c7b905" /></body>
      <title>Excel interop with .Net / Server 2008</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,ef1b363f-dc12-4106-a797-6d2c37c7b905.aspx</guid>
      <link>http://tim.mackey.ie/ExcelInteropWithNetServer2008.aspx</link>
      <pubDate>Wed, 28 Dec 2011 21:16:30 GMT</pubDate>
      <description>I'm using Asp.Net to open excel files and read the values cell by cell, normally i prefer to import Excel files as a datatable, but some documents don't fit the strict rows/columns format required for importing into a DataTable.&amp;nbsp; the code i'm using is based on &lt;a href="http://dotnetperls.com/excel-interop"&gt;this
from dotnetperls&lt;/a&gt;.&amp;nbsp; worked fine for the most part on my dev PC but I had a
few issues trying to get this to work on a 32bit version of excel on a 64 bit Windows
2008 server. 
&lt;br&gt;
here's what i had to do to get it working: 
&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
disable macros (throwing exceptions opening the workbook), requires a reference to
the Microsoft.Office.Core assembly:&lt;br&gt;
excelApp.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable;&amp;nbsp;&amp;nbsp;
// disable macros&lt;/li&gt;
&lt;li&gt;
give launch / open permissions to the Excel application in DCOM config, this was tricky
because it isn't shown in a 64 bit OS if the program is 32 bit, i found &lt;a href="http://social.technet.microsoft.com/Forums/en-US/w7itproappcompat/thread/dde69147-a01a-4eb1-8ea9-31adbf874bed/"&gt;the
answer here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
set the identity in DCOM for Excel to the interactive user.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=ef1b363f-dc12-4106-a797-6d2c37c7b905" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,ef1b363f-dc12-4106-a797-6d2c37c7b905.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=f64c50ed-6a72-4d18-b966-079bd740282f</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,f64c50ed-6a72-4d18-b966-079bd740282f.aspx</pingback:target>
      <dc:creator>Tim Mackey</dc:creator>
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,f64c50ed-6a72-4d18-b966-079bd740282f.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=f64c50ed-6a72-4d18-b966-079bd740282f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">if you use SqlMetal to generate DataContext
classes against an SQL database, you might run into some problems with GridView and
deleting a row, when using a LinqDataSource.<br />
this was a very frustrating problem to track down, apparently there is a bug in the
LinqDataSource with datetime fields.  i kept getting this error: ChangeConflictException:
Row not found or changed<br />
and there was no apparent reason why it was happening, because the same code worked
for other tables.  I eventually narrowed it down to the only difference between
the two tables, a non nullable datetime field. changing this field to nullable removed
the problem. 
<br /><a href="http://forums.asp.net/t/1016914.aspx">this thread</a> was useful in troubleshooting
the problem.<br />
i also found that calling DataBind() on the LinqDataSource before re-binding the GridView
helped get rid of this error message.<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=f64c50ed-6a72-4d18-b966-079bd740282f" /></body>
      <title>Gridview Delete via LinqDataSource fails with ChangeConflictException: Row not found or changed</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,f64c50ed-6a72-4d18-b966-079bd740282f.aspx</guid>
      <link>http://tim.mackey.ie/GridviewDeleteViaLinqDataSourceFailsWithChangeConflictExceptionRowNotFoundOrChanged.aspx</link>
      <pubDate>Tue, 14 Sep 2010 11:50:05 GMT</pubDate>
      <description>if you use SqlMetal to generate DataContext classes against an SQL database, you might run into some problems with GridView and deleting a row, when using a LinqDataSource.&lt;br&gt;
this was a very frustrating problem to track down, apparently there is a bug in the
LinqDataSource with datetime fields.&amp;nbsp; i kept getting this error: ChangeConflictException:
Row not found or changed&lt;br&gt;
and there was no apparent reason why it was happening, because the same code worked
for other tables.&amp;nbsp; I eventually narrowed it down to the only difference between
the two tables, a non nullable datetime field. changing this field to nullable removed
the problem. 
&lt;br&gt;
&lt;a href="http://forums.asp.net/t/1016914.aspx"&gt;this thread&lt;/a&gt; was useful in troubleshooting
the problem.&lt;br&gt;
i also found that calling DataBind() on the LinqDataSource before re-binding the GridView
helped get rid of this error message.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=f64c50ed-6a72-4d18-b966-079bd740282f" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,f64c50ed-6a72-4d18-b966-079bd740282f.aspx</comments>
      <category>.Net General</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=c947af7f-9cb4-4018-a856-c92855b04738</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,c947af7f-9cb4-4018-a856-c92855b04738.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,c947af7f-9cb4-4018-a856-c92855b04738.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=c947af7f-9cb4-4018-a856-c92855b04738</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">I got a request from a client for a 'mini'
navigation menu to appear on a page to allow the user to 'jump' to the various sections
of the page.  Maintaining a set of named anchor hyperlinks in a document (with
a javascript-based select menu) is not really an option for someone who doesn't know
HTML, which is most people who use content management.  In the wrong hands this
creates more trouble than it's worth.  
<br />
so i started thinking. the documents in question are well structured, using paragraphs
and headings, as enforced by the content management system.  i worked out this
solution which is exactly what i need, a maintenance free javascript jump menu, that
doesn't add clutter to the document with named anchors.  it assumes that the
all H2 tags should be displayed as links in the menu.  the javascript iterates
through the H2 tags and loads up the menu, with a ScrollTo function used when an item
is selected.<br /><br />
here's a <a href="/content/binary/jumpmenu.png">screenshot<br /><img style="border: 1px solid rgb(0, 0, 0);" src="http://tim.mackey.ie/content/binary/jumpmenu.png" border="1" width="420" height="257" /></a><br /><br />
The code for the HTML page:<br /><pre>&lt;script src="/JumpMenu.js" type="text/javascript"&gt;&lt;/script&gt;<br />
&lt;select id="jumpNavSelect" name="jumpNavSelect" onchange="JumpToHeading(this.selectedIndex)"&gt;<br />
&lt;option value=""&gt;On this page...&lt;/option&gt;<br />
&lt;/select&gt;<br /></pre>and the JumpMenu.js file<br /><pre>var array;<br /><br />
function CreateAnchorMenu() {<br />
array = document.getElementsByTagName("h2"); 
<br />
var src = document.getElementById('jumpNavSelect');<br />
// iterate through all H2 headings, add dropdown items for each. 
<br />
for (var i = 0; i &lt; array.length; i++) {<br />
var heading = array[i];<br />
var text = heading.firstChild.nodeValue;<br />
if (!text)<br />
continue;<br />
src[i+1] = new Option(text, i);<br />
}<br />
}<br /><br />
function JumpToHeading(HeadingIndex) {<br />
if (HeadingIndex == 0)<br />
return;<br />
var heading = array[HeadingIndex-1];<br />
ScrollToElement(heading);<br />
}<br /><br />
function ScrollToElement(theElement) {<br />
var selectedPosX = 0;<br />
var selectedPosY = 0;<br />
while (theElement != null) {<br />
selectedPosX += theElement.offsetLeft;<br />
selectedPosY += theElement.offsetTop;<br />
theElement = theElement.offsetParent;<br />
}<br />
window.scrollTo(selectedPosX, selectedPosY);<br />
}<br /><br />
window.onload = CreateAnchorMenu;<br /></pre><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=c947af7f-9cb4-4018-a856-c92855b04738" /></body>
      <title>Javascript dynamic anchor select menu</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,c947af7f-9cb4-4018-a856-c92855b04738.aspx</guid>
      <link>http://tim.mackey.ie/JavascriptDynamicAnchorSelectMenu.aspx</link>
      <pubDate>Tue, 21 Apr 2009 12:30:58 GMT</pubDate>
      <description>I got a request from a client for a 'mini' navigation menu to appear on
a page to allow the user to 'jump' to the various sections of the
page.&amp;nbsp; Maintaining a set of named anchor hyperlinks in a document (with
a javascript-based select menu) is not really an option for someone who
doesn't know HTML, which is most people who use content management.&amp;nbsp; In
the wrong hands this creates more trouble than it's worth.&amp;nbsp; &lt;br&gt;
so i started thinking. the documents in question are well structured, using paragraphs
and headings, as enforced by the content management system.&amp;nbsp; i worked out this
solution which is exactly what i need, a maintenance free javascript jump menu, that
doesn't add clutter to the document with named anchors.&amp;nbsp; it assumes that the
all H2 tags should be displayed as links in the menu.&amp;nbsp; the javascript iterates
through the H2 tags and loads up the menu, with a ScrollTo function used when an item
is selected.&lt;br&gt;
&lt;br&gt;
here's a &lt;a href="/content/binary/jumpmenu.png"&gt;screenshot&lt;br&gt;
&lt;img style="border: 1px solid rgb(0, 0, 0);" src="http://tim.mackey.ie/content/binary/jumpmenu.png" border="1" width="420" height="257"&gt;&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
The code for the HTML page:&lt;br&gt;
&lt;pre&gt;&amp;lt;script src="/JumpMenu.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;&lt;br&gt;
&amp;lt;select id="jumpNavSelect" name="jumpNavSelect" onchange="JumpToHeading(this.selectedIndex)"&amp;gt;&lt;br&gt;
&amp;lt;option value=""&amp;gt;On this page...&amp;lt;/option&amp;gt;&lt;br&gt;
&amp;lt;/select&amp;gt;&lt;br&gt;
&lt;/pre&gt;and the JumpMenu.js file&lt;br&gt;
&lt;pre&gt;var array;&lt;br&gt;
&lt;br&gt;
function CreateAnchorMenu() {&lt;br&gt;
array = document.getElementsByTagName("h2"); 
&lt;br&gt;
var src = document.getElementById('jumpNavSelect');&lt;br&gt;
// iterate through all H2 headings, add dropdown items for each. 
&lt;br&gt;
for (var i = 0; i &amp;lt; array.length; i++) {&lt;br&gt;
var heading = array[i];&lt;br&gt;
var text = heading.firstChild.nodeValue;&lt;br&gt;
if (!text)&lt;br&gt;
continue;&lt;br&gt;
src[i+1] = new Option(text, i);&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
function JumpToHeading(HeadingIndex) {&lt;br&gt;
if (HeadingIndex == 0)&lt;br&gt;
return;&lt;br&gt;
var heading = array[HeadingIndex-1];&lt;br&gt;
ScrollToElement(heading);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
function ScrollToElement(theElement) {&lt;br&gt;
var selectedPosX = 0;&lt;br&gt;
var selectedPosY = 0;&lt;br&gt;
while (theElement != null) {&lt;br&gt;
selectedPosX += theElement.offsetLeft;&lt;br&gt;
selectedPosY += theElement.offsetTop;&lt;br&gt;
theElement = theElement.offsetParent;&lt;br&gt;
}&lt;br&gt;
window.scrollTo(selectedPosX, selectedPosY);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
window.onload = CreateAnchorMenu;&lt;br&gt;
&lt;/pre&gt;&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=c947af7f-9cb4-4018-a856-c92855b04738" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,c947af7f-9cb4-4018-a856-c92855b04738.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=1f65c32e-7a99-4fe1-b58c-92c8241bcc13</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,1f65c32e-7a99-4fe1-b58c-92c8241bcc13.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,1f65c32e-7a99-4fe1-b58c-92c8241bcc13.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=1f65c32e-7a99-4fe1-b58c-92c8241bcc13</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <pre>Cstr(CDate({Table.Column}), "dd/MM/yyyy")</pre>
        <p>
        </p>
        <img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=1f65c32e-7a99-4fe1-b58c-92c8241bcc13" />
      </body>
      <title>Crystal Reports date format (in code)</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,1f65c32e-7a99-4fe1-b58c-92c8241bcc13.aspx</guid>
      <link>http://tim.mackey.ie/CrystalReportsDateFormatInCode.aspx</link>
      <pubDate>Fri, 27 Feb 2009 17:47:52 GMT</pubDate>
      <description>&lt;pre&gt;Cstr(CDate({Table.Column}), "dd/MM/yyyy")&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=1f65c32e-7a99-4fe1-b58c-92c8241bcc13" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,1f65c32e-7a99-4fe1-b58c-92c8241bcc13.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=7e32c01d-1f87-41c8-995a-11c74cd8ce42</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,7e32c01d-1f87-41c8-995a-11c74cd8ce42.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,7e32c01d-1f87-41c8-995a-11c74cd8ce42.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=7e32c01d-1f87-41c8-995a-11c74cd8ce42</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">thanks to Kev for his <a href="http://blog.zygonia.net/2006/03/12/SystemXmlXmlNamespaceManagerXPathAndTheDefaultNamespace.aspx">brilliant
post</a> about solving this problem, where you know you have the correct XPath expression
but .Net is not giving you any nodes :(<br />
his solution is the correct one, an alternative approach is to remove the xmlns from
the root element before you load the XmlDocument so that you can use the default empty
namespace (or something like that).<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=7e32c01d-1f87-41c8-995a-11c74cd8ce42" /></body>
      <title>XPath problems, SelectNodes returns no nodes</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,7e32c01d-1f87-41c8-995a-11c74cd8ce42.aspx</guid>
      <link>http://tim.mackey.ie/XPathProblemsSelectNodesReturnsNoNodes.aspx</link>
      <pubDate>Thu, 16 Oct 2008 18:05:36 GMT</pubDate>
      <description>thanks to Kev for his &lt;a href="http://blog.zygonia.net/2006/03/12/SystemXmlXmlNamespaceManagerXPathAndTheDefaultNamespace.aspx"&gt;brilliant
post&lt;/a&gt; about solving this problem, where you know you have the correct XPath expression
but .Net is not giving you any nodes :(&lt;br&gt;
his solution is the correct one, an alternative approach is to remove the xmlns from
the root element before you load the XmlDocument so that you can use the default empty
namespace (or something like that).&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=7e32c01d-1f87-41c8-995a-11c74cd8ce42" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,7e32c01d-1f87-41c8-995a-11c74cd8ce42.aspx</comments>
      <category>.Net General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=7296d6d4-8f83-4e25-bc9c-4ca51fd79c2f</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,7296d6d4-8f83-4e25-bc9c-4ca51fd79c2f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,7296d6d4-8f83-4e25-bc9c-4ca51fd79c2f.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=7296d6d4-8f83-4e25-bc9c-4ca51fd79c2f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">i assumed that File.WriteAllText() would
assume UTF8 encoding since all strings are unicode in .net by default, so i never
bothered specifying the encoding in the 3rd parameter.  But it was causing me
grief with accented characters, and i finally worked it out that i needed to specify
UTF8 explicitly. 
<br /><pre>File.WriteAllText(filepath, text, Encoding.UTF8);</pre><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=7296d6d4-8f83-4e25-bc9c-4ca51fd79c2f" /></body>
      <title>Encoding issues with File.WriteAllText</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,7296d6d4-8f83-4e25-bc9c-4ca51fd79c2f.aspx</guid>
      <link>http://tim.mackey.ie/EncodingIssuesWithFileWriteAllText.aspx</link>
      <pubDate>Wed, 20 Aug 2008 14:00:46 GMT</pubDate>
      <description>i assumed that File.WriteAllText() would assume UTF8 encoding since all strings are unicode in .net by default, so i never bothered specifying the encoding in the 3rd parameter.&amp;nbsp; But it was causing me grief with accented characters, and i finally worked it out that i needed to specify UTF8 explicitly. &lt;br&gt;
&lt;pre&gt;File.WriteAllText(filepath, text, Encoding.UTF8);&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=7296d6d4-8f83-4e25-bc9c-4ca51fd79c2f" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,7296d6d4-8f83-4e25-bc9c-4ca51fd79c2f.aspx</comments>
      <category>.Net General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=78885c9a-4521-45bc-9eb8-137e811914fc</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,78885c9a-4521-45bc-9eb8-137e811914fc.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,78885c9a-4521-45bc-9eb8-137e811914fc.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=78885c9a-4521-45bc-9eb8-137e811914fc</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">if you ever send a string across a web
service, and write it out to a file, make sure you specify Encoding.UTF8 explicitly.
otherwise characters such as the EURO symbol may not render correctly in some browsers
(IE6).  it took me ages to pin this down, because everything i read about was
about HTTP header charset values, or HTML document charsets, or database encodings. 
In my case i was using the default encoding and this messed up EURO symbols. I suspect
it is because of the string being serialized in the web service, but haven't the time
to look into it any further.  it's fixed now anyhow.<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=78885c9a-4521-45bc-9eb8-137e811914fc" /></body>
      <title>Euro symbol character problems...</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,78885c9a-4521-45bc-9eb8-137e811914fc.aspx</guid>
      <link>http://tim.mackey.ie/EuroSymbolCharacterProblems.aspx</link>
      <pubDate>Thu, 17 Jul 2008 16:25:32 GMT</pubDate>
      <description>if you ever send a string across a web service, and write it out to a file, make sure you specify Encoding.UTF8 explicitly. otherwise characters such as the EURO symbol may not render correctly in some browsers (IE6).&amp;nbsp; it took me ages to pin this down, because everything i read about was about HTTP header charset values, or HTML document charsets, or database encodings.&amp;nbsp; In my case i was using the default encoding and this messed up EURO symbols. I suspect it is because of the string being serialized in the web service, but haven't the time to look into it any further.&amp;nbsp; it's fixed now anyhow.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=78885c9a-4521-45bc-9eb8-137e811914fc" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,78885c9a-4521-45bc-9eb8-137e811914fc.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=5d5bf00e-e298-4da6-a9fd-13710fb54836</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,5d5bf00e-e298-4da6-a9fd-13710fb54836.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,5d5bf00e-e298-4da6-a9fd-13710fb54836.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=5d5bf00e-e298-4da6-a9fd-13710fb54836</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">this wasn't very obvious to work out, and
i couldn't find a decent solution online, so i came up with this.<br /><pre>this.DropDownList1.Attributes.Add("onchange", "if(!confirm('Are you sure you want to delete this item?')) return;");<br /></pre>This works with .Net 2 and 3 and 3.5, but may break with future versions if
.Net changes the javascript code for AutoPostBack drop down lists.  The reason
it works now is because .Net adds the custom 'onchange' attribute before it's on doPostBack()
function call.  So if we return from the confirm prompt, the form will not submit.  
<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=5d5bf00e-e298-4da6-a9fd-13710fb54836" /></body>
      <title>Confirm prompt for DropDownList</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,5d5bf00e-e298-4da6-a9fd-13710fb54836.aspx</guid>
      <link>http://tim.mackey.ie/ConfirmPromptForDropDownList.aspx</link>
      <pubDate>Thu, 31 Jan 2008 16:32:13 GMT</pubDate>
      <description>this wasn't very obvious to work out, and i couldn't find a decent solution online, so i came up with this.&lt;br&gt;
&lt;pre&gt;this.DropDownList1.Attributes.Add("onchange", "if(!confirm('Are you sure you want to delete this item?')) return;");&lt;br&gt;
&lt;/pre&gt;This works with .Net 2 and 3 and 3.5, but may break with future versions if
.Net changes the javascript code for AutoPostBack drop down lists.&amp;nbsp; The reason
it works now is because .Net adds the custom 'onchange' attribute before it's on doPostBack()
function call.&amp;nbsp; So if we return from the confirm prompt, the form will not submit.&amp;nbsp; 
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=5d5bf00e-e298-4da6-a9fd-13710fb54836" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,5d5bf00e-e298-4da6-a9fd-13710fb54836.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=6fbec280-7f81-4759-a895-5a5230e00929</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,6fbec280-7f81-4759-a895-5a5230e00929.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,6fbec280-7f81-4759-a895-5a5230e00929.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=6fbec280-7f81-4759-a895-5a5230e00929</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">if, like me, you were running VS 2008 Beta
2 on a server and you had crystal reports working fine, and then recompiled your projects
in VS 2008 RTM, you may get an error like this when you try and create a crystal report
on a production server:<br /><pre>System.Runtime.InteropServices.COMException (0x800736B1):
Retrieving the COM class factory for component with CLSID
{5FF57840-5172-4482-9CA3-541C7878AE0F} failed due to the following error:
800736b1. at CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor()</pre>
In my case, i had installed Crystal Reports Runtime for VS 2008 Beta 2, and i never
installed the runtime for the RTM version.  it should be available on your VS
machine, if you opted for CR in the VS installer:<br />
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5<br /><br />
should probably uninstall the old version of the CR runtime while you're at it too.  
<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=6fbec280-7f81-4759-a895-5a5230e00929" /></body>
      <title>Deploy Crystal Reports for VS 2008 (RTM)</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,6fbec280-7f81-4759-a895-5a5230e00929.aspx</guid>
      <link>http://tim.mackey.ie/DeployCrystalReportsForVS2008RTM.aspx</link>
      <pubDate>Tue, 27 Nov 2007 11:32:12 GMT</pubDate>
      <description>if, like me, you were running VS 2008 Beta 2 on a server and you had crystal reports working fine, and then recompiled your projects in VS 2008 RTM, you may get an error like this when you try and create a crystal report on a production server:&lt;br&gt;
&lt;pre&gt;System.Runtime.InteropServices.COMException (0x800736B1):
Retrieving the COM class factory for component with CLSID
{5FF57840-5172-4482-9CA3-541C7878AE0F} failed due to the following error:
800736b1. at CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor()&lt;/pre&gt;
In my case, i had installed Crystal Reports Runtime for VS 2008 Beta 2, and i never
installed the runtime for the RTM version.&amp;nbsp; it should be available on your VS
machine, if you opted for CR in the VS installer:&lt;br&gt;
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5&lt;br&gt;
&lt;br&gt;
should probably uninstall the old version of the CR runtime while you're at it too.&amp;nbsp; 
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=6fbec280-7f81-4759-a895-5a5230e00929" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,6fbec280-7f81-4759-a895-5a5230e00929.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
      <category>Windows Server 2003</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=2047a926-01c1-478b-923c-9143ae2b115f</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,2047a926-01c1-478b-923c-9143ae2b115f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,2047a926-01c1-478b-923c-9143ae2b115f.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=2047a926-01c1-478b-923c-9143ae2b115f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">how weird is this.  i upgraded my
CMS editor to XHTML and i suddenly find that any pages with an IFRAME have the footer
cut off, completely invisible.  i found out it was because the self-closing tag
(as per XHTML) screws up the page layout in IE and FF.  you have to use &lt;/iframe&gt;,
which unfortunately breaks XHTML validation, but i can live with that.<br />
for more info see this <a href="http://geekswithblogs.net/mohamed/archive/2006/10/07/93443.aspx">blog
post</a> that explains it further.<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=2047a926-01c1-478b-923c-9143ae2b115f" /></body>
      <title>IFRAME causes all content beneath to disappear</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,2047a926-01c1-478b-923c-9143ae2b115f.aspx</guid>
      <link>http://tim.mackey.ie/IFRAMECausesAllContentBeneathToDisappear.aspx</link>
      <pubDate>Mon, 19 Nov 2007 11:20:35 GMT</pubDate>
      <description>how weird is this.&amp;nbsp; i upgraded my CMS editor to XHTML and i suddenly find that any pages with an IFRAME have the footer cut off, completely invisible.&amp;nbsp; i found out it was because the self-closing tag (as per XHTML) screws up the page layout in IE and FF.&amp;nbsp; you have to use &amp;lt;/iframe&amp;gt;, which unfortunately breaks XHTML validation, but i can live with that.&lt;br&gt;
for more info see this &lt;a href="http://geekswithblogs.net/mohamed/archive/2006/10/07/93443.aspx"&gt;blog
post&lt;/a&gt; that explains it further.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=2047a926-01c1-478b-923c-9143ae2b115f" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,2047a926-01c1-478b-923c-9143ae2b115f.aspx</comments>
      <category>.Net General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=844bcd3d-df43-4b3b-9fdc-8f86293f850e</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,844bcd3d-df43-4b3b-9fdc-8f86293f850e.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,844bcd3d-df43-4b3b-9fdc-8f86293f850e.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=844bcd3d-df43-4b3b-9fdc-8f86293f850e</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h2>Note: this doesn't really work..
</h2>
        <p>
i'm just leaving it here for interest.  the approach will work for the first
invocation of either v2 or v3 client, but after a v2 client has used the web service,
any v3 clients will fail.  MS told me this is not supported because of the 2
soapExtensions interfere with each other in the pipeline etc
</p>
        <hr size="2" width="100%" />
My asp.net CMS has some winforms clients running WSE2, and i'm doing an upgrade to
the client (and server) to use WSE3, but i want to support both versions.  Both
WSE2 and WSE3 clients are using a CustomUsernameTokenManager.  it was a bit tricky
to work out, but here is what i ended up doing. thanks to brian o'keefe for his <a href="http://groups.google.com/group/microsoft.public.dotnet.framework.webservices.enhancements/browse_thread/thread/e1bed90a5b50ed2d/49fb76d46fa81b7d?lnk=gst&amp;q=version+2+3#49fb76d46fa81b7d">newsgroup
post</a> for most of the answer.  Your exact config might vary but hopefully
it will save you some of the hassle of working all this out.<br /><ul><li>
Leave the existing web service in place, e.g. Service_WSE2.asmx<br /></li><li>
Create a new web service for the WSE3 client, essentially copy/paste the ASMX file,
e.g. Service_WSE3.asmx</li><li>
Create a new CustomUsernameTokenManager for the WSE3 service which inherits from Microsoft.Web.Services3.Security.Tokens.UsernameTokenManager. 
In my case it was as easy as copy/paste from the WSE2 token manager and change all
the WSE2 namespaces to WSE3.<br /></li><li>
then in web.config, make sure both WSE config sections are listed:<br /><pre>&lt;configuration&gt;<br />
&lt;configSections&gt;<br />
&lt;section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration,
Microsoft.Web.Services3,Version=3.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/&gt;<br />
&lt;section name="microsoft.web.services2" type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration,
Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/&gt;<br />
&lt;/configSections&gt;<br /></pre></li><li><p>
add in references to both the assemblies for the compilation section (not 100% sure
if this is necessary, but at least it means the app will not compile on the production
server if you forget to deploy either of the WSE assemblies, instead of waiting till
one of your clients connects).<br /></p><pre>	&lt;compilation defaultLanguage="c#" debug="true"&gt;<br />
&lt;assemblies&gt;<br />
&lt;add assembly="Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;<br />
&lt;add assembly="Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;</pre></li><li><p>
remove the &lt;webServices&gt; section from &lt;system.web&gt;, because each web service
should be configured by location, not global as this interferes.<br /></p><pre>	&lt;location path="Service_WSE2.asmx"&gt;<br />
&lt;system.web&gt;<br />
&lt;webServices&gt;<br />
&lt;soapExtensionTypes&gt;<br />
&lt;add type="Microsoft.Web.Services2.WebServicesExtension, Microsoft.Web.Services2,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1" group="0"
/&gt;<br />
&lt;/soapExtensionTypes&gt; 
<br />
&lt;/webServices&gt;<br />
&lt;/system.web&gt;<br />
&lt;/location&gt;<br /><br />
&lt;location path="Service_WSE3.asmx"&gt;<br />
&lt;system.web&gt;<br />
&lt;webServices&gt;<br />
&lt;soapExtensionTypes&gt;<br />
&lt;clear/&gt;<br />
&lt;/soapExtensionTypes&gt;<br />
&lt;soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/&gt;<br />
&lt;soapExtensionImporterTypes&gt;<br />
&lt;add type="Microsoft.Web.Services3.Description.WseExtensionImporter, Microsoft.Web.Services3,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/&gt;<br />
&lt;/soapExtensionImporterTypes&gt; 
<br />
&lt;/webServices&gt;<br />
&lt;/system.web&gt;<br />
&lt;/location&gt;</pre></li><li>
my webservice policy are defined in policyCache.config files, so the following web.config
sections point each version of WSE to the right file:<br /><pre>	&lt;microsoft.web.services3&gt;<br />
&lt;policy fileName="policyCache_WSE3.config"/&gt;<br />
&lt;security&gt;<br />
&lt;securityTokenManager&gt;<br />
&lt;add type="Whatever.CustomUsernameTokenManager3" namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
localName="UsernameToken"/&gt;<br />
&lt;/securityTokenManager&gt;<br />
&lt;/security&gt;<br />
&lt;/microsoft.web.services3&gt;<br />
&lt;microsoft.web.services2&gt;<br />
&lt;messaging&gt;<br />
&lt;maxRequestLength&gt;10000&lt;/maxRequestLength&gt;<br />
&lt;/messaging&gt;<br />
&lt;security&gt;<br />
&lt;securityTokenManager type="Whatever.CustomUsernameTokenManager2, MyAssemblyName"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"<br />
qname="wsse:UsernameToken" /&gt;<br />
&lt;defaultTtlInSeconds&gt;86400&lt;/defaultTtlInSeconds&gt;<br />
&lt;timeToleranceInSeconds&gt;86400&lt;/timeToleranceInSeconds&gt;<br />
&lt;/security&gt;<br />
&lt;policy&gt;<br />
&lt;cache name="policyCache_WSE2.config" /&gt;<br />
&lt;/policy&gt;<br />
&lt;/microsoft.web.services2&gt;</pre></li><li>
and lastly, the policy cache files themselves:<br />
WSE 3 version<br /><pre>&lt;?xml version="1.0"?&gt;<br />
&lt;policies xmlns="http://schemas.microsoft.com/wse/2005/06/policy"&gt;<br />
&lt;extensions&gt;<br />
&lt;extension name="usernameOverTransportSecurity" type="Microsoft.Web.Services3.Design.UsernameOverTransportAssertion,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/&gt;<br />
&lt;extension name="requireActionHeader" type="Microsoft.Web.Services3.Design.RequireActionHeaderAssertion,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/&gt;<br />
&lt;/extensions&gt;<br />
&lt;policy name="usernameTokenSecurity"&gt; 
<br />
&lt;usernameOverTransportSecurity /&gt;<br />
&lt;requireActionHeader /&gt;<br />
&lt;/policy&gt;<br />
&lt;/policies&gt;</pre></li><li>
WSE 2 version<br /><pre>&lt;?xml version="1.0"?&gt;<br />
&lt;policyDocument xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy" xmlns="http://schemas.microsoft.com/wse/2003/06/Policy"&gt;<br />
&lt;mappings xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy"&gt;<br /><br />
&lt;endpoint uri="http://localhost/Service_WSE2.asmx"&gt;<br />
&lt;defaultOperation&gt;<br />
&lt;request policy="#username-token-signed" /&gt;<br />
&lt;response policy="" /&gt;<br />
&lt;fault policy="" /&gt;<br />
&lt;/defaultOperation&gt;<br />
&lt;/endpoint&gt;<br /><br />
&lt;defaultEndpoint&gt;<br />
&lt;defaultOperation&gt;<br />
&lt;request policy="" /&gt;<br />
&lt;response policy="" /&gt;<br />
&lt;fault policy="" /&gt;<br />
&lt;/defaultOperation&gt;<br />
&lt;/defaultEndpoint&gt;<br /><br />
&lt;/mappings&gt;<br />
&lt;policies xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;<br />
&lt;wsp:Policy wsu:Id="username-token-signed" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:wssp="http://schemas.xmlsoap.org/ws/2002/12/secext"&gt;<br />
&lt;wsp:MessagePredicate wsp:Usage="wsp:Required" Dialect="http://schemas.xmlsoap.org/2002/12/wsse#part"&gt;<br />
wsp:Body() wsp:Header(wsa:To) wsp:Header(wsa:Action) wsp:Header(wsa:MessageID) wse:Timestamp()<br />
&lt;/wsp:MessagePredicate&gt;<br />
&lt;wssp:Integrity wsp:Usage="wsp:Required"&gt;<br />
&lt;wssp:TokenInfo&gt;<br />
&lt;SecurityToken xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"&gt;<br />
&lt;wssp:TokenType&gt;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken&lt;/wssp:TokenType&gt;<br />
&lt;wssp:Claims&gt;<br />
&lt;wssp:UsePassword wsp:Usage="wsp:Required" /&gt;<br />
&lt;/wssp:Claims&gt;<br />
&lt;/SecurityToken&gt;<br />
&lt;/wssp:TokenInfo&gt;<br />
&lt;wssp:MessageParts Dialect="http://schemas.xmlsoap.org/2002/12/wsse#part"&gt;<br />
wsp:Body() wsp:Header(wsa:Action) wsp:Header(wsa:FaultTo) wsp:Header(wsa:From) wsp:Header(wsa:MessageID)
wsp:Header(wsa:RelatesTo) wsp:Header(wsa:ReplyTo) wsp:Header(wsa:To) wse:Timestamp()<br />
&lt;/wssp:MessageParts&gt;<br />
&lt;/wssp:Integrity&gt;<br />
&lt;/wsp:Policy&gt;<br />
&lt;/policies&gt;<br />
&lt;/policyDocument&gt;<br /></pre></li></ul><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=844bcd3d-df43-4b3b-9fdc-8f86293f850e" /></body>
      <title>Running WSE 2 and 3 side by side</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,844bcd3d-df43-4b3b-9fdc-8f86293f850e.aspx</guid>
      <link>http://tim.mackey.ie/RunningWSE2And3SideBySide.aspx</link>
      <pubDate>Fri, 16 Nov 2007 12:16:50 GMT</pubDate>
      <description>&lt;h2&gt;Note: this doesn't really work..
&lt;/h2&gt;
&lt;p&gt;
i'm just leaving it here for interest.&amp;nbsp; the approach will work for the first
invocation of either v2 or v3 client, but after a v2 client has used the web service,
any v3 clients will fail.&amp;nbsp; MS told me this is not supported because of the 2
soapExtensions interfere with each other in the pipeline etc
&lt;/p&gt;
&lt;hr size="2" width="100%"&gt;
My asp.net CMS has some winforms clients running WSE2, and i'm doing an upgrade to
the client (and server) to use WSE3, but i want to support both versions.&amp;nbsp; Both
WSE2 and WSE3 clients are using a CustomUsernameTokenManager.&amp;nbsp; it was a bit tricky
to work out, but here is what i ended up doing. thanks to brian o'keefe for his &lt;a href="http://groups.google.com/group/microsoft.public.dotnet.framework.webservices.enhancements/browse_thread/thread/e1bed90a5b50ed2d/49fb76d46fa81b7d?lnk=gst&amp;amp;q=version+2+3#49fb76d46fa81b7d"&gt;newsgroup
post&lt;/a&gt; for most of the answer.&amp;nbsp; Your exact config might vary but hopefully
it will save you some of the hassle of working all this out.&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
Leave the existing web service in place, e.g. Service_WSE2.asmx&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
Create a new web service for the WSE3 client, essentially copy/paste the ASMX file,
e.g. Service_WSE3.asmx&lt;/li&gt;
&lt;li&gt;
Create a new CustomUsernameTokenManager for the WSE3 service which inherits from Microsoft.Web.Services3.Security.Tokens.UsernameTokenManager.&amp;nbsp;
In my case it was as easy as copy/paste from the WSE2 token manager and change all
the WSE2 namespaces to WSE3.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
then in web.config, make sure both WSE config sections are listed:&lt;br&gt;
&lt;pre&gt;&amp;lt;configuration&amp;gt;&lt;br&gt;
&amp;lt;configSections&amp;gt;&lt;br&gt;
&amp;lt;section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration,
Microsoft.Web.Services3,Version=3.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/&amp;gt;&lt;br&gt;
&amp;lt;section name="microsoft.web.services2" type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration,
Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/&amp;gt;&lt;br&gt;
&amp;lt;/configSections&amp;gt;&lt;br&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
add in references to both the assemblies for the compilation section (not 100% sure
if this is necessary, but at least it means the app will not compile on the production
server if you forget to deploy either of the WSE assemblies, instead of waiting till
one of your clients connects).&lt;br&gt;
&lt;/p&gt;
&lt;pre&gt;	&amp;lt;compilation defaultLanguage="c#" debug="true"&amp;gt;&lt;br&gt;
&amp;lt;assemblies&amp;gt;&lt;br&gt;
&amp;lt;add assembly="Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&amp;gt;&lt;br&gt;
&amp;lt;add assembly="Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&amp;gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
remove the &amp;lt;webServices&amp;gt; section from &amp;lt;system.web&amp;gt;, because each web service
should be configured by location, not global as this interferes.&lt;br&gt;
&lt;/p&gt;
&lt;pre&gt;	&amp;lt;location path="Service_WSE2.asmx"&amp;gt;&lt;br&gt;
&amp;lt;system.web&amp;gt;&lt;br&gt;
&amp;lt;webServices&amp;gt;&lt;br&gt;
&amp;lt;soapExtensionTypes&amp;gt;&lt;br&gt;
&amp;lt;add type="Microsoft.Web.Services2.WebServicesExtension, Microsoft.Web.Services2,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1" group="0"
/&amp;gt;&lt;br&gt;
&amp;lt;/soapExtensionTypes&amp;gt; 
&lt;br&gt;
&amp;lt;/webServices&amp;gt;&lt;br&gt;
&amp;lt;/system.web&amp;gt;&lt;br&gt;
&amp;lt;/location&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;location path="Service_WSE3.asmx"&amp;gt;&lt;br&gt;
&amp;lt;system.web&amp;gt;&lt;br&gt;
&amp;lt;webServices&amp;gt;&lt;br&gt;
&amp;lt;soapExtensionTypes&amp;gt;&lt;br&gt;
&amp;lt;clear/&amp;gt;&lt;br&gt;
&amp;lt;/soapExtensionTypes&amp;gt;&lt;br&gt;
&amp;lt;soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/&amp;gt;&lt;br&gt;
&amp;lt;soapExtensionImporterTypes&amp;gt;&lt;br&gt;
&amp;lt;add type="Microsoft.Web.Services3.Description.WseExtensionImporter, Microsoft.Web.Services3,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/&amp;gt;&lt;br&gt;
&amp;lt;/soapExtensionImporterTypes&amp;gt; 
&lt;br&gt;
&amp;lt;/webServices&amp;gt;&lt;br&gt;
&amp;lt;/system.web&amp;gt;&lt;br&gt;
&amp;lt;/location&amp;gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
my webservice policy are defined in policyCache.config files, so the following web.config
sections point each version of WSE to the right file:&lt;br&gt;
&lt;pre&gt;	&amp;lt;microsoft.web.services3&amp;gt;&lt;br&gt;
&amp;lt;policy fileName="policyCache_WSE3.config"/&amp;gt;&lt;br&gt;
&amp;lt;security&amp;gt;&lt;br&gt;
&amp;lt;securityTokenManager&amp;gt;&lt;br&gt;
&amp;lt;add type="Whatever.CustomUsernameTokenManager3" namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
localName="UsernameToken"/&amp;gt;&lt;br&gt;
&amp;lt;/securityTokenManager&amp;gt;&lt;br&gt;
&amp;lt;/security&amp;gt;&lt;br&gt;
&amp;lt;/microsoft.web.services3&amp;gt;&lt;br&gt;
&amp;lt;microsoft.web.services2&amp;gt;&lt;br&gt;
&amp;lt;messaging&amp;gt;&lt;br&gt;
&amp;lt;maxRequestLength&amp;gt;10000&amp;lt;/maxRequestLength&amp;gt;&lt;br&gt;
&amp;lt;/messaging&amp;gt;&lt;br&gt;
&amp;lt;security&amp;gt;&lt;br&gt;
&amp;lt;securityTokenManager type="Whatever.CustomUsernameTokenManager2, MyAssemblyName"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&lt;br&gt;
qname="wsse:UsernameToken" /&amp;gt;&lt;br&gt;
&amp;lt;defaultTtlInSeconds&amp;gt;86400&amp;lt;/defaultTtlInSeconds&amp;gt;&lt;br&gt;
&amp;lt;timeToleranceInSeconds&amp;gt;86400&amp;lt;/timeToleranceInSeconds&amp;gt;&lt;br&gt;
&amp;lt;/security&amp;gt;&lt;br&gt;
&amp;lt;policy&amp;gt;&lt;br&gt;
&amp;lt;cache name="policyCache_WSE2.config" /&amp;gt;&lt;br&gt;
&amp;lt;/policy&amp;gt;&lt;br&gt;
&amp;lt;/microsoft.web.services2&amp;gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
and lastly, the policy cache files themselves:&lt;br&gt;
WSE 3 version&lt;br&gt;
&lt;pre&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;br&gt;
&amp;lt;policies xmlns="http://schemas.microsoft.com/wse/2005/06/policy"&amp;gt;&lt;br&gt;
&amp;lt;extensions&amp;gt;&lt;br&gt;
&amp;lt;extension name="usernameOverTransportSecurity" type="Microsoft.Web.Services3.Design.UsernameOverTransportAssertion,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/&amp;gt;&lt;br&gt;
&amp;lt;extension name="requireActionHeader" type="Microsoft.Web.Services3.Design.RequireActionHeaderAssertion,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/&amp;gt;&lt;br&gt;
&amp;lt;/extensions&amp;gt;&lt;br&gt;
&amp;lt;policy name="usernameTokenSecurity"&amp;gt; 
&lt;br&gt;
&amp;lt;usernameOverTransportSecurity /&amp;gt;&lt;br&gt;
&amp;lt;requireActionHeader /&amp;gt;&lt;br&gt;
&amp;lt;/policy&amp;gt;&lt;br&gt;
&amp;lt;/policies&amp;gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
WSE 2 version&lt;br&gt;
&lt;pre&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;br&gt;
&amp;lt;policyDocument xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy" xmlns="http://schemas.microsoft.com/wse/2003/06/Policy"&amp;gt;&lt;br&gt;
&amp;lt;mappings xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy"&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;endpoint uri="http://localhost/Service_WSE2.asmx"&amp;gt;&lt;br&gt;
&amp;lt;defaultOperation&amp;gt;&lt;br&gt;
&amp;lt;request policy="#username-token-signed" /&amp;gt;&lt;br&gt;
&amp;lt;response policy="" /&amp;gt;&lt;br&gt;
&amp;lt;fault policy="" /&amp;gt;&lt;br&gt;
&amp;lt;/defaultOperation&amp;gt;&lt;br&gt;
&amp;lt;/endpoint&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;defaultEndpoint&amp;gt;&lt;br&gt;
&amp;lt;defaultOperation&amp;gt;&lt;br&gt;
&amp;lt;request policy="" /&amp;gt;&lt;br&gt;
&amp;lt;response policy="" /&amp;gt;&lt;br&gt;
&amp;lt;fault policy="" /&amp;gt;&lt;br&gt;
&amp;lt;/defaultOperation&amp;gt;&lt;br&gt;
&amp;lt;/defaultEndpoint&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;/mappings&amp;gt;&lt;br&gt;
&amp;lt;policies xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&amp;gt;&lt;br&gt;
&amp;lt;wsp:Policy wsu:Id="username-token-signed" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:wssp="http://schemas.xmlsoap.org/ws/2002/12/secext"&amp;gt;&lt;br&gt;
&amp;lt;wsp:MessagePredicate wsp:Usage="wsp:Required" Dialect="http://schemas.xmlsoap.org/2002/12/wsse#part"&amp;gt;&lt;br&gt;
wsp:Body() wsp:Header(wsa:To) wsp:Header(wsa:Action) wsp:Header(wsa:MessageID) wse:Timestamp()&lt;br&gt;
&amp;lt;/wsp:MessagePredicate&amp;gt;&lt;br&gt;
&amp;lt;wssp:Integrity wsp:Usage="wsp:Required"&amp;gt;&lt;br&gt;
&amp;lt;wssp:TokenInfo&amp;gt;&lt;br&gt;
&amp;lt;SecurityToken xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"&amp;gt;&lt;br&gt;
&amp;lt;wssp:TokenType&amp;gt;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken&amp;lt;/wssp:TokenType&amp;gt;&lt;br&gt;
&amp;lt;wssp:Claims&amp;gt;&lt;br&gt;
&amp;lt;wssp:UsePassword wsp:Usage="wsp:Required" /&amp;gt;&lt;br&gt;
&amp;lt;/wssp:Claims&amp;gt;&lt;br&gt;
&amp;lt;/SecurityToken&amp;gt;&lt;br&gt;
&amp;lt;/wssp:TokenInfo&amp;gt;&lt;br&gt;
&amp;lt;wssp:MessageParts Dialect="http://schemas.xmlsoap.org/2002/12/wsse#part"&amp;gt;&lt;br&gt;
wsp:Body() wsp:Header(wsa:Action) wsp:Header(wsa:FaultTo) wsp:Header(wsa:From) wsp:Header(wsa:MessageID)
wsp:Header(wsa:RelatesTo) wsp:Header(wsa:ReplyTo) wsp:Header(wsa:To) wse:Timestamp()&lt;br&gt;
&amp;lt;/wssp:MessageParts&amp;gt;&lt;br&gt;
&amp;lt;/wssp:Integrity&amp;gt;&lt;br&gt;
&amp;lt;/wsp:Policy&amp;gt;&lt;br&gt;
&amp;lt;/policies&amp;gt;&lt;br&gt;
&amp;lt;/policyDocument&amp;gt;&lt;br&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=844bcd3d-df43-4b3b-9fdc-8f86293f850e" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,844bcd3d-df43-4b3b-9fdc-8f86293f850e.aspx</comments>
      <category>.Net General</category>
      <category>.Net Windows Forms</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=a250691a-e8c5-4780-9b5f-2a1f5c1a31e2</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,a250691a-e8c5-4780-9b5f-2a1f5c1a31e2.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,a250691a-e8c5-4780-9b5f-2a1f5c1a31e2.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=a250691a-e8c5-4780-9b5f-2a1f5c1a31e2</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">wow, i never knew this existed: <a href="http://sqlprofiler.googlepages.com/">http://sqlprofiler.googlepages.com/</a><br />
thanks to <a href="http://code.google.com/u/nikolay.zhebrun/">nikolay.zhebrun</a><br />
it works great.<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=a250691a-e8c5-4780-9b5f-2a1f5c1a31e2" /></body>
      <title>Profiler For SQL 2005 Express</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,a250691a-e8c5-4780-9b5f-2a1f5c1a31e2.aspx</guid>
      <link>http://tim.mackey.ie/ProfilerForSQL2005Express.aspx</link>
      <pubDate>Tue, 18 Sep 2007 12:43:58 GMT</pubDate>
      <description>wow, i never knew this existed: &lt;a href="http://sqlprofiler.googlepages.com/"&gt;http://sqlprofiler.googlepages.com/&lt;/a&gt;
&lt;br&gt;
thanks to &lt;a href="http://code.google.com/u/nikolay.zhebrun/"&gt;nikolay.zhebrun&lt;/a&gt;
&lt;br&gt;
it works great.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=a250691a-e8c5-4780-9b5f-2a1f5c1a31e2" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,a250691a-e8c5-4780-9b5f-2a1f5c1a31e2.aspx</comments>
      <category>.Net General</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=dd18de04-8ed1-4640-975a-e120ed746b86</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,dd18de04-8ed1-4640-975a-e120ed746b86.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,dd18de04-8ed1-4640-975a-e120ed746b86.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=dd18de04-8ed1-4640-975a-e120ed746b86</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">Here is the sql that is generated by a
DataContext when you use Skip() and Take() to efficiently select records for the grid:<br /><pre>SELECT TOP 10 [t1].[Name], [t1].[Address], [t1].[Tel1], [t1].[Tel2], [t1].[Email], [t1].[DateCommenced], [t1].[Comments], [t1].[Active], [t1].[Fax]<br />
FROM (<br />
SELECT ROW_NUMBER() OVER (ORDER BY [t0].[Name], [t0].[Address], [t0].[Tel1], [t0].[Tel2],
[t0].[Email], [t0].[DateCommenced], [t0].[Comments], [t0].[Active], [t0].[Fax]) AS
[ROW_NUMBER], [t0].[Name], [t0].[Address], [t0].[Tel1], [t0].[Tel2], [t0].[Email],
[t0].[DateCommenced], [t0].[Comments], [t0].[Active], [t0].[Fax]<br />
FROM [dbo].[Table1] AS [t0]<br />
) AS [t1]<br />
WHERE [t1].[ROW_NUMBER] &gt; @p0<br />
-- @p0: Input Int32 (Size = 0; Prec = 0; Scale = 0) [50]<br />
-- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.20706.1<br /></pre><p>
it's not immediately obvious why they use the subquery like this, but i'm sure they
have been very thorough in optimising LINQ.  
<br /></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=dd18de04-8ed1-4640-975a-e120ed746b86" /></body>
      <title>LINQ Sql Using Skip And Take</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,dd18de04-8ed1-4640-975a-e120ed746b86.aspx</guid>
      <link>http://tim.mackey.ie/LINQSqlUsingSkipAndTake.aspx</link>
      <pubDate>Tue, 18 Sep 2007 12:22:32 GMT</pubDate>
      <description>Here is the sql that is generated by a DataContext when you use Skip() and Take() to efficiently select records for the grid:&lt;br&gt;
&lt;pre&gt;SELECT TOP 10 [t1].[Name], [t1].[Address], [t1].[Tel1], [t1].[Tel2], [t1].[Email], [t1].[DateCommenced], [t1].[Comments], [t1].[Active], [t1].[Fax]&lt;br&gt;
FROM (&lt;br&gt;
SELECT ROW_NUMBER() OVER (ORDER BY [t0].[Name], [t0].[Address], [t0].[Tel1], [t0].[Tel2],
[t0].[Email], [t0].[DateCommenced], [t0].[Comments], [t0].[Active], [t0].[Fax]) AS
[ROW_NUMBER], [t0].[Name], [t0].[Address], [t0].[Tel1], [t0].[Tel2], [t0].[Email],
[t0].[DateCommenced], [t0].[Comments], [t0].[Active], [t0].[Fax]&lt;br&gt;
FROM [dbo].[Table1] AS [t0]&lt;br&gt;
) AS [t1]&lt;br&gt;
WHERE [t1].[ROW_NUMBER] &amp;gt; @p0&lt;br&gt;
-- @p0: Input Int32 (Size = 0; Prec = 0; Scale = 0) [50]&lt;br&gt;
-- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.20706.1&lt;br&gt;
&lt;/pre&gt;
&lt;p&gt;
it's not immediately obvious why they use the subquery like this, but i'm sure they
have been very thorough in optimising LINQ.&amp;nbsp; 
&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=dd18de04-8ed1-4640-975a-e120ed746b86" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,dd18de04-8ed1-4640-975a-e120ed746b86.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=f7aa2ded-17e0-444d-b5e1-cde713a042b4</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,f7aa2ded-17e0-444d-b5e1-cde713a042b4.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,f7aa2ded-17e0-444d-b5e1-cde713a042b4.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=f7aa2ded-17e0-444d-b5e1-cde713a042b4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Today was the first time i used LINQ with
non-database data.  I always knew you could do it but didn't realise how satisfying
it would actually be to use LINQ to crunch out some results that i would otherwise
have to code up in some gnarly routine involving on-the-fly DataTables and DataView
filters etc.  Also, I'm mainly posting this because i can never remember the
LINQ group by syntax...<br /><br />
i have a plain list of reference numbers, e.g. 1.a, 2.b, 3.c, 4.a, 10.d, 11.c etc. 
they contain duplicates and i was asked to figure out the top 10 most popular references. 
A simple regex separates out the numbers, i could also have used string.split() but
regex is better in my case.  Copy each one into an array and then a simple LINQ
query on the array gives me the top 10 references:<br /><pre>List&lt;string&gt; lst = new List&lt;string&gt;();<br />
foreach(Match m in Regex.Matches(this.txtInput.Text, @"\w+\.\w+", RegexOptions.IgnoreCase))<br />
lst.Add(m.Groups[0].Captures[0].Value);<br />
var results = (from l in lst group l by l into g select new {Ref = g.Key, Total =
g.Count()}).OrderByDescending(z =&gt; z.Total).Take(10);<br />
foreach(var v in results)<br />
this.txtOutput.Text += v.Ref + "\t" + v.Total + "\r\n";<br /></pre><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=f7aa2ded-17e0-444d-b5e1-cde713a042b4" /></body>
      <title>LINQ with strings</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,f7aa2ded-17e0-444d-b5e1-cde713a042b4.aspx</guid>
      <link>http://tim.mackey.ie/LINQWithStrings.aspx</link>
      <pubDate>Mon, 17 Sep 2007 14:01:26 GMT</pubDate>
      <description>Today was the first time i used LINQ with non-database data.&amp;nbsp; I always knew you could do it but didn't realise how satisfying it would actually be to use LINQ to crunch out some results that i would otherwise have to code up in some gnarly routine involving on-the-fly DataTables and DataView filters etc.&amp;nbsp; Also, I'm mainly posting this because i can never remember the LINQ group by syntax...&lt;br&gt;
&lt;br&gt;
i have a plain list of reference numbers, e.g. 1.a, 2.b, 3.c, 4.a, 10.d, 11.c etc.&amp;nbsp;
they contain duplicates and i was asked to figure out the top 10 most popular references.&amp;nbsp;
A simple regex separates out the numbers, i could also have used string.split() but
regex is better in my case.&amp;nbsp; Copy each one into an array and then a simple LINQ
query on the array gives me the top 10 references:&lt;br&gt;
&lt;pre&gt;List&amp;lt;string&amp;gt; lst = new List&amp;lt;string&amp;gt;();&lt;br&gt;
foreach(Match m in Regex.Matches(this.txtInput.Text, @"\w+\.\w+", RegexOptions.IgnoreCase))&lt;br&gt;
lst.Add(m.Groups[0].Captures[0].Value);&lt;br&gt;
var results = (from l in lst group l by l into g select new {Ref = g.Key, Total =
g.Count()}).OrderByDescending(z =&amp;gt; z.Total).Take(10);&lt;br&gt;
foreach(var v in results)&lt;br&gt;
this.txtOutput.Text += v.Ref + "\t" + v.Total + "\r\n";&lt;br&gt;
&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=f7aa2ded-17e0-444d-b5e1-cde713a042b4" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,f7aa2ded-17e0-444d-b5e1-cde713a042b4.aspx</comments>
      <category>.Net General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=d0f314e7-59f3-467b-a0a5-2056ab257028</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,d0f314e7-59f3-467b-a0a5-2056ab257028.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,d0f314e7-59f3-467b-a0a5-2056ab257028.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=d0f314e7-59f3-467b-a0a5-2056ab257028</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">It's fair enough that SQL won't accept
a parameterised query like below, because it cannot verify that the parameter is referring
to a valid column.<br /><pre>select * from table order by @OrderBy</pre>the work around then is to use a case
statement like so:<br /><pre>select * from table order by case 
<br />
when @OrderBy = 'Column1' then Column1<br />
when @OrderBy = 'Column2' then Column2<br />
end<br /></pre>
but i ran into a problem with this approach, where sql raises an error if the datatypes
of the columns are not all the same, e.g. you may want to sort by an Int or NVarChar
column.  the datatype precedence rules applied to the case statement are well
explained in this <a href="http://groups.google.com/group/microsoft.public.sqlserver.programming/browse_thread/thread/48e8e244de8476ca/9df564f1d45e6a23?lnk=gst&amp;q=order+by+parameter+Conversion+failed&amp;rnum=1#9df564f1d45e6a23">post
on google groups</a>.  the solution posted by Erland Sommarskog is to have a
separate case statement for each clause.  so the more robust approach is like
so:<br /><pre>select * from table order by 
<br />
case when @OrderBy = 'Column1' then Column1 end,<br />
case when @OrderBy = 'Column2' then Column2 end<br /><br /></pre><br /><br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=d0f314e7-59f3-467b-a0a5-2056ab257028" /></body>
      <title>SQL: order by with parameters of different datatype</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,d0f314e7-59f3-467b-a0a5-2056ab257028.aspx</guid>
      <link>http://tim.mackey.ie/SQLOrderByWithParametersOfDifferentDatatype.aspx</link>
      <pubDate>Fri, 31 Aug 2007 11:36:35 GMT</pubDate>
      <description>It's fair enough that SQL won't accept a parameterised query like below, because it cannot verify that the parameter is referring to a valid column.&lt;br&gt;
&lt;pre&gt;select * from table order by @OrderBy&lt;/pre&gt;the work around then is to use a case
statement like so:&lt;br&gt;
&lt;pre&gt;select * from table order by case 
&lt;br&gt;
when @OrderBy = 'Column1' then Column1&lt;br&gt;
when @OrderBy = 'Column2' then Column2&lt;br&gt;
end&lt;br&gt;
&lt;/pre&gt;
but i ran into a problem with this approach, where sql raises an error if the datatypes
of the columns are not all the same, e.g. you may want to sort by an Int or NVarChar
column.&amp;nbsp; the datatype precedence rules applied to the case statement are well
explained in this &lt;a href="http://groups.google.com/group/microsoft.public.sqlserver.programming/browse_thread/thread/48e8e244de8476ca/9df564f1d45e6a23?lnk=gst&amp;amp;q=order+by+parameter+Conversion+failed&amp;amp;rnum=1#9df564f1d45e6a23"&gt;post
on google groups&lt;/a&gt;.&amp;nbsp; the solution posted by Erland Sommarskog is to have a
separate case statement for each clause.&amp;nbsp; so the more robust approach is like
so:&lt;br&gt;
&lt;pre&gt;select * from table order by 
&lt;br&gt;
case when @OrderBy = 'Column1' then Column1 end,&lt;br&gt;
case when @OrderBy = 'Column2' then Column2 end&lt;br&gt;
&lt;br&gt;
&lt;/pre&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=d0f314e7-59f3-467b-a0a5-2056ab257028" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,d0f314e7-59f3-467b-a0a5-2056ab257028.aspx</comments>
      <category>.Net General</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=f4d85eae-48dc-4298-9098-d7d365b48d8f</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,f4d85eae-48dc-4298-9098-d7d365b48d8f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,f4d85eae-48dc-4298-9098-d7d365b48d8f.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=f4d85eae-48dc-4298-9098-d7d365b48d8f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Just got up and running with VS 2008 Beta
2 and converted my Orcas Beta 1 projects over to VS 2008.  have a read of <a href="http://weblogs.asp.net/scottgu/archive/2007/07/26/vs-2008-and-net-3-5-beta-2-released.aspx">Scott
Gu's post</a> on downloading and installing.  whaddya know? VS 2008 hasn't crashed
yet :)  seriously though, this is a major relief to see good stability. 
as a developer it did my head in to have to keep nuking devenv.exe and losing a few
minutes work, driving me quietly insane.  hopefully those days are over now. 
Beta 1 was a thousand times better than VS 2005, but Beta 2 looks even better.  
<br /><br />
in terms of breaking changes with upgrading projects etc., here are some tidbits i
came across<br /><ul><li>
the namespace <font color="#008000" face="Courier New"><b>System.Data.Linq.Expressions</b></font> no
longer exists.  i just deleted this namespace and it worked fine, they must have
moved various classes back into the root Linq namespace or something.</li><li>
if you use SqlMetal, you will have to use the new version of this tool, which i found
at <b><font color="#008000" face="Courier New">C:\Program Files\Microsoft SDKs\Windows\V6.0A\Bin\SqlMetal.exe</font></b>.
The generated code from the new tool is very different to before so you will need
to regenerate in order to use the new LINQ libraries.<br /></li><li><font color="#008000" face="Courier New"><b>web.config</b></font> changes are also
introduced.  the best way to figure out the changes is to open up a blank web
application and compare the standard web.config in the empty project to your own web.config.</li><li>
Crystal Reports assembly version numbers are the same with this release of VS, 10.5.3700.0,
so no changes here since Beta1.</li></ul>
i'll post more next week when i have some real experience using VS 2008.  so
far so good.  great job Scott &amp; Co.<br /><p></p><h5>Update 30 July 2007 - Deployment Issues<br /></h5><ul><li>
To deploy a VS 2008 beta 2 web application to a Server 2003 with .net runtime 2.0,
you need to install 3.5 of the runtime.  i got all sorts of web.config errors
due to the new syntax with beta 2.  A web app compiled against v3.5 in Beta 1
had no trouble running on top of the 2.0 runtime with the various v3.5 DLLs deployed
to the /bin directory, however this doesn't seem to be possible anymore.  it
took me a while to find the correct download for the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=D2F74873-C796-4E60-91C8-F0EF809B09EE&amp;displaylang=en">3.5
beta 2 redistributable</a>, it installed in about 10 mins and required a reboot, and
did not affect any of the v1.1 and v2 web sites running on the server.  
<br /></li></ul><br /><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=f4d85eae-48dc-4298-9098-d7d365b48d8f" /></body>
      <title>VS 2008: First impressions</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,f4d85eae-48dc-4298-9098-d7d365b48d8f.aspx</guid>
      <link>http://tim.mackey.ie/VS2008FirstImpressions.aspx</link>
      <pubDate>Fri, 27 Jul 2007 16:49:16 GMT</pubDate>
      <description>Just got up and running with VS 2008 Beta 2 and converted my Orcas Beta 1 projects over to VS 2008.&amp;nbsp; have a read of &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/07/26/vs-2008-and-net-3-5-beta-2-released.aspx"&gt;Scott
Gu's post&lt;/a&gt; on downloading and installing.&amp;nbsp; whaddya know? VS 2008 hasn't crashed
yet :)&amp;nbsp; seriously though, this is a major relief to see good stability.&amp;nbsp;
as a developer it did my head in to have to keep nuking devenv.exe and losing a few
minutes work, driving me quietly insane.&amp;nbsp; hopefully those days are over now.&amp;nbsp;
Beta 1 was a thousand times better than VS 2005, but Beta 2 looks even better.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
in terms of breaking changes with upgrading projects etc., here are some tidbits i
came across&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
the namespace &lt;font color="#008000" face="Courier New"&gt;&lt;b&gt;System.Data.Linq.Expressions&lt;/b&gt;&lt;/font&gt; no
longer exists.&amp;nbsp; i just deleted this namespace and it worked fine, they must have
moved various classes back into the root Linq namespace or something.&lt;/li&gt;
&lt;li&gt;
if you use SqlMetal, you will have to use the new version of this tool, which i found
at &lt;b&gt;&lt;font color="#008000" face="Courier New"&gt;C:\Program Files\Microsoft SDKs\Windows\V6.0A\Bin\SqlMetal.exe&lt;/font&gt;&lt;/b&gt;.
The generated code from the new tool is very different to before so you will need
to regenerate in order to use the new LINQ libraries.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;font color="#008000" face="Courier New"&gt;&lt;b&gt;web.config&lt;/b&gt;&lt;/font&gt; changes are also
introduced.&amp;nbsp; the best way to figure out the changes is to open up a blank web
application and compare the standard web.config in the empty project to your own web.config.&lt;/li&gt;
&lt;li&gt;
Crystal Reports assembly version numbers are the same with this release of VS, 10.5.3700.0,
so no changes here since Beta1.&lt;/li&gt;
&lt;/ul&gt;
i'll post more next week when i have some real experience using VS 2008.&amp;nbsp; so
far so good.&amp;nbsp; great job Scott &amp;amp; Co.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;h5&gt;Update 30 July 2007 - Deployment Issues&lt;br&gt;
&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;
To deploy a VS 2008 beta 2 web application to a Server 2003 with .net runtime 2.0,
you need to install 3.5 of the runtime.&amp;nbsp; i got all sorts of web.config errors
due to the new syntax with beta 2.&amp;nbsp; A web app compiled against v3.5 in Beta 1
had no trouble running on top of the 2.0 runtime with the various v3.5 DLLs deployed
to the /bin directory, however this doesn't seem to be possible anymore.&amp;nbsp; it
took me a while to find the correct download for the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=D2F74873-C796-4E60-91C8-F0EF809B09EE&amp;amp;displaylang=en"&gt;3.5
beta 2 redistributable&lt;/a&gt;, it installed in about 10 mins and required a reboot, and
did not affect any of the v1.1 and v2 web sites running on the server.&amp;nbsp; 
&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=f4d85eae-48dc-4298-9098-d7d365b48d8f" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,f4d85eae-48dc-4298-9098-d7d365b48d8f.aspx</comments>
      <category>.Net General</category>
      <category>.Net Windows Forms</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=9106477d-0d56-4606-947d-733e6bf8f66b</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,9106477d-0d56-4606-947d-733e6bf8f66b.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,9106477d-0d56-4606-947d-733e6bf8f66b.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=9106477d-0d56-4606-947d-733e6bf8f66b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <pre>public static ImageCodecInfo GetEncoderInfo(String mimeType)<br />
{<br />
int j;<br />
ImageCodecInfo[] encoders;<br />
encoders = ImageCodecInfo.GetImageEncoders();<br />
for(j = 0; j &lt; encoders.Length; ++j)<br />
if(encoders[j].MimeType == mimeType)<br />
return encoders[j];<br />
return null;<br />
}<br /><br />
public static Bitmap resizeImage(Bitmap originalImage, int max)<br />
{<br />
// never increase the size of an image from this method because it loses resolution<br />
if(originalImage.Height &lt;= max &amp;&amp; originalImage.Width &lt;= max)<br />
return originalImage;<br /><br />
int height, width;<br />
if(originalImage.Width &gt; originalImage.Height)<br />
{<br />
width = max;<br />
height = (int)(max/((double)originalImage.Width / (double)originalImage.Height));<br />
}<br />
else<br />
{ 
<br />
height = max;<br />
width = (int)(max/((double)originalImage.Height / (double)originalImage.Width));<br />
}<br /><br />
Bitmap thumb = new Bitmap(originalImage as Image, width, height);<br /><font color="#ff0000"> Graphics resizer = Graphics.FromImage(thumb);<br />
resizer.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;<br />
resizer.DrawImage(originalImage, 0, 0, width, height);</font><br />
resizer.Dispose();<br />
return thumb;<br />
}<br /><br />
public static bool ThumbnailCallback()<br />
{<br />
return false;<br />
}<br /><br /></pre>this lovely code highlighted in red solved problems i was having with resizing
JPEGs using .net.   without the code in red, some images would appear very
grainy when reduced in size.  i got this tip from <a href="http://forums.asp.net/p/532033/532033.aspx">http://forums.asp.net/p/532033/532033.aspx</a>.<br /><br /><br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=9106477d-0d56-4606-947d-733e6bf8f66b" /></body>
      <title>JPEG Resizing Quality Problems .Net</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,9106477d-0d56-4606-947d-733e6bf8f66b.aspx</guid>
      <link>http://tim.mackey.ie/JPEGResizingQualityProblemsNet.aspx</link>
      <pubDate>Wed, 18 Jul 2007 16:41:41 GMT</pubDate>
      <description>&lt;pre&gt;public static ImageCodecInfo GetEncoderInfo(String mimeType)&lt;br&gt;
{&lt;br&gt;
int j;&lt;br&gt;
ImageCodecInfo[] encoders;&lt;br&gt;
encoders = ImageCodecInfo.GetImageEncoders();&lt;br&gt;
for(j = 0; j &amp;lt; encoders.Length; ++j)&lt;br&gt;
if(encoders[j].MimeType == mimeType)&lt;br&gt;
return encoders[j];&lt;br&gt;
return null;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
public static Bitmap resizeImage(Bitmap originalImage, int max)&lt;br&gt;
{&lt;br&gt;
// never increase the size of an image from this method because it loses resolution&lt;br&gt;
if(originalImage.Height &amp;lt;= max &amp;amp;&amp;amp; originalImage.Width &amp;lt;= max)&lt;br&gt;
return originalImage;&lt;br&gt;
&lt;br&gt;
int height, width;&lt;br&gt;
if(originalImage.Width &amp;gt; originalImage.Height)&lt;br&gt;
{&lt;br&gt;
width = max;&lt;br&gt;
height = (int)(max/((double)originalImage.Width / (double)originalImage.Height));&lt;br&gt;
}&lt;br&gt;
else&lt;br&gt;
{ 
&lt;br&gt;
height = max;&lt;br&gt;
width = (int)(max/((double)originalImage.Height / (double)originalImage.Width));&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
Bitmap thumb = new Bitmap(originalImage as Image, width, height);&lt;br&gt;
&lt;font color="#ff0000"&gt; Graphics resizer = Graphics.FromImage(thumb);&lt;br&gt;
resizer.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;&lt;br&gt;
resizer.DrawImage(originalImage, 0, 0, width, height);&lt;/font&gt;
&lt;br&gt;
resizer.Dispose();&lt;br&gt;
return thumb;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
public static bool ThumbnailCallback()&lt;br&gt;
{&lt;br&gt;
return false;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;/pre&gt;this lovely code highlighted in red solved problems i was having with resizing
JPEGs using .net.&amp;nbsp;&amp;nbsp; without the code in red, some images would appear very
grainy when reduced in size.&amp;nbsp; i got this tip from &lt;a href="http://forums.asp.net/p/532033/532033.aspx"&gt;http://forums.asp.net/p/532033/532033.aspx&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=9106477d-0d56-4606-947d-733e6bf8f66b" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,9106477d-0d56-4606-947d-733e6bf8f66b.aspx</comments>
      <category>.Net General</category>
      <category>.Net Windows Forms</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=3d302832-8ee9-4206-a760-7b3c0164cbad</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,3d302832-8ee9-4206-a760-7b3c0164cbad.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,3d302832-8ee9-4206-a760-7b3c0164cbad.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=3d302832-8ee9-4206-a760-7b3c0164cbad</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Just in case anyone was as stuck as i was
today trying to virtually load an ISO image.  the Virtual CD Control Panel thing
doesn't work in Vista, and for some reason VirtualCloneDrive wouldn't work for me
either. 
<br />
i eventually found a free tool called <a href="http://www.poweriso.com/">PowerISO</a> which
works great.  you can create several virtual drives and mount an ISO in each
one.  i'm currently installing Orcas Beta 1 from an ISO mounted across the network,
i wasn't sure if it could do that but it had no problems.<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=3d302832-8ee9-4206-a760-7b3c0164cbad" /></body>
      <title>Mounting ISO images in Vista</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,3d302832-8ee9-4206-a760-7b3c0164cbad.aspx</guid>
      <link>http://tim.mackey.ie/MountingISOImagesInVista.aspx</link>
      <pubDate>Tue, 26 Jun 2007 15:48:13 GMT</pubDate>
      <description>Just in case anyone was as stuck as i was today trying to virtually load an ISO image.&amp;nbsp; the Virtual CD Control Panel thing doesn't work in Vista, and for some reason VirtualCloneDrive wouldn't work for me either. &lt;br&gt;
i eventually found a free tool called &lt;a href="http://www.poweriso.com/"&gt;PowerISO&lt;/a&gt; which
works great.&amp;nbsp; you can create several virtual drives and mount an ISO in each
one.&amp;nbsp; i'm currently installing Orcas Beta 1 from an ISO mounted across the network,
i wasn't sure if it could do that but it had no problems.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=3d302832-8ee9-4206-a760-7b3c0164cbad" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,3d302832-8ee9-4206-a760-7b3c0164cbad.aspx</comments>
      <category>.Net General</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=37b1b4cb-dc2a-43ce-8385-6879e32ca368</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,37b1b4cb-dc2a-43ce-8385-6879e32ca368.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,37b1b4cb-dc2a-43ce-8385-6879e32ca368.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=37b1b4cb-dc2a-43ce-8385-6879e32ca368</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I know we're not supposed to be going live with .Net 3.5 / Orcas Beta 1 yet, but hey.  
<br /></p>
        <p>
I ran into a Crystal Reports deployment problem with an asp.net web application developed
in Orcas beta 1, using the bundled version of crystal reports.  The problem is
that the crystal report dlls used in a Beta 1 project are 10.5.3700.0 but there don't
appear to be any merge modules available to support this version number, so there
is no supported way to run the Orcas version of Crystal Reports on a server, without
installing Orcas itself.  I tried numerous options of digging out the 10.5.3700.0
dlls from <font color="#0000ff" face="Courier New">program files\common files\business
objects</font> etc and putting them in the web site <i>bin</i> directory on the server,
but that didn't work.  The obvious error message that comes up is as follows:
</p>
        <p>
          <span>
          </span>
        </p>
        <pre>
          <font color="#ff0000">
            <i>
              <i>Could not load file or assembly 'CrystalDecisions.CrystalReports.Engine, 
<br />
Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its
dependencies. 
<br />
The system cannot find the file specified.</i>
            </i>
          </font>
        </pre>
        <p>
what i ended up doing was instructing the web application to bind to the 10.2.3600.0
versions of the assemblies, which are already deployed using the normal CR server
install. 
<br /></p>
        <p>
here is what i added to the end of my web.config file to get it going:<br /></p>
        <pre>
          <i>
            <i>    ....<br />
&lt;runtime&gt;<br />
        &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;<br />
            &lt;dependentAssembly&gt;<br />
                &lt;assemblyIdentity
name="CrystalDecisions.CrystalReports.Engine" publicKeyToken="692fbea5521e1304"/&gt;<br />
                &lt;bindingRedirect
oldVersion="10.5.3700.0" newVersion="10.2.3600.0"/&gt;<br />
            &lt;/dependentAssembly&gt;<br />
            &lt;dependentAssembly&gt;<br />
                &lt;assemblyIdentity
name="CrystalDecisions.CrystalReports.Shared" publicKeyToken="692fbea5521e1304"/&gt;<br />
                &lt;bindingRedirect
oldVersion="10.5.3700.0" newVersion="10.2.3600.0"/&gt;<br />
            &lt;/dependentAssembly&gt;<br />
            &lt;dependentAssembly&gt;<br />
                &lt;assemblyIdentity
name="CrystalDecisions.Shared" publicKeyToken="692fbea5521e1304"/&gt;<br />
                &lt;bindingRedirect
oldVersion="10.5.3700.0" newVersion="10.2.3600.0"/&gt;<br />
            &lt;/dependentAssembly&gt;<br />
        &lt;/assemblyBinding&gt;<br />
    &lt;/runtime&gt;<br />
&lt;/configuration&gt;<br /></i>
          </i>
        </pre>
        <img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=37b1b4cb-dc2a-43ce-8385-6879e32ca368" />
      </body>
      <title>Deploying Crystal Reports for Orcas Beta 1</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,37b1b4cb-dc2a-43ce-8385-6879e32ca368.aspx</guid>
      <link>http://tim.mackey.ie/DeployingCrystalReportsForOrcasBeta1.aspx</link>
      <pubDate>Thu, 17 May 2007 16:36:06 GMT</pubDate>
      <description>&lt;p&gt;
I know we're not supposed to be going live with .Net 3.5 / Orcas Beta 1 yet, but hey.&amp;nbsp; 
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
I ran into a Crystal Reports deployment problem with an asp.net web application developed
in Orcas beta 1, using the bundled version of crystal reports.&amp;nbsp; The problem is
that the crystal report dlls used in a Beta 1 project are 10.5.3700.0 but there don't
appear to be any merge modules available to support this version number, so there
is no supported way to run the Orcas version of Crystal Reports on a server, without
installing Orcas itself.&amp;nbsp; I tried numerous options of digging out the 10.5.3700.0
dlls from &lt;font color="#0000ff" face="Courier New"&gt;program files\common files\business
objects&lt;/font&gt; etc and putting them in the web site &lt;i&gt;bin&lt;/i&gt; directory on the server,
but that didn't work.&amp;nbsp; The obvious error message that comes up is as follows:
&lt;/p&gt;
&lt;p&gt;
&lt;span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;pre&gt;&lt;font color="#ff0000"&gt;&lt;i&gt;&lt;i&gt;Could not load file or assembly 'CrystalDecisions.CrystalReports.Engine, 
&lt;br&gt;
Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its
dependencies. 
&lt;br&gt;
The system cannot find the file specified.&lt;/i&gt;&lt;/i&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
what i ended up doing was instructing the web application to bind to the 10.2.3600.0
versions of the assemblies, which are already deployed using the normal CR server
install. 
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
here is what i added to the end of my web.config file to get it going:&lt;br&gt;
&lt;/p&gt;
&lt;pre&gt;&lt;i&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....&lt;br&gt;
&amp;lt;runtime&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;dependentAssembly&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;assemblyIdentity
name="CrystalDecisions.CrystalReports.Engine" publicKeyToken="692fbea5521e1304"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bindingRedirect
oldVersion="10.5.3700.0" newVersion="10.2.3600.0"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/dependentAssembly&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;dependentAssembly&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;assemblyIdentity
name="CrystalDecisions.CrystalReports.Shared" publicKeyToken="692fbea5521e1304"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bindingRedirect
oldVersion="10.5.3700.0" newVersion="10.2.3600.0"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/dependentAssembly&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;dependentAssembly&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;assemblyIdentity
name="CrystalDecisions.Shared" publicKeyToken="692fbea5521e1304"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bindingRedirect
oldVersion="10.5.3700.0" newVersion="10.2.3600.0"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/dependentAssembly&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/assemblyBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/runtime&amp;gt;&lt;br&gt;
&amp;lt;/configuration&amp;gt;&lt;br&gt;
&lt;/i&gt;&lt;/i&gt;&lt;/pre&gt;&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=37b1b4cb-dc2a-43ce-8385-6879e32ca368" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,37b1b4cb-dc2a-43ce-8385-6879e32ca368.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=083acbb9-86f6-4ad6-a893-f3a7f31fe04e</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,083acbb9-86f6-4ad6-a893-f3a7f31fe04e.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,083acbb9-86f6-4ad6-a893-f3a7f31fe04e.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=083acbb9-86f6-4ad6-a893-f3a7f31fe04e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">i spent hours trying to troubleshoot this. 
obviously the error makes no sense because CR should not be logging on to anything
in a dataset scenario.<br />
anyway, a thousand thanks to Jason for his post on the <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=259341&amp;SiteID=1">MSDN
forums</a> with the simple answer: set the datasource to the DataTable, not the DataSet. 
<br /><br />
i can't wait to lose Crystal reports altogether and move to the microsoft reporting
thingy, i haven't had time to play about with it yet but at least it will be properly
programmed and it won't contain the 10 years of bugs that crystal reports have carried
through each release of their software.  &lt;/RANT&gt;<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=083acbb9-86f6-4ad6-a893-f3a7f31fe04e" /></body>
      <title>Crystal Reports: Incorrect Log on Parameters for Dataset source</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,083acbb9-86f6-4ad6-a893-f3a7f31fe04e.aspx</guid>
      <link>http://tim.mackey.ie/CrystalReportsIncorrectLogOnParametersForDatasetSource.aspx</link>
      <pubDate>Wed, 02 May 2007 17:43:46 GMT</pubDate>
      <description>i spent hours trying to troubleshoot this.&amp;nbsp; obviously the error makes no sense because CR should not be logging on to anything in a dataset scenario.&lt;br&gt;
anyway, a thousand thanks to Jason for his post on the &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=259341&amp;amp;SiteID=1"&gt;MSDN
forums&lt;/a&gt; with the simple answer: set the datasource to the DataTable, not the DataSet. 
&lt;br&gt;
&lt;br&gt;
i can't wait to lose Crystal reports altogether and move to the microsoft reporting
thingy, i haven't had time to play about with it yet but at least it will be properly
programmed and it won't contain the 10 years of bugs that crystal reports have carried
through each release of their software.&amp;nbsp; &amp;lt;/RANT&amp;gt;&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=083acbb9-86f6-4ad6-a893-f3a7f31fe04e" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,083acbb9-86f6-4ad6-a893-f3a7f31fe04e.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=0ffd4a23-6e4d-4553-a535-edb86081eb2f</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,0ffd4a23-6e4d-4553-a535-edb86081eb2f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,0ffd4a23-6e4d-4553-a535-edb86081eb2f.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=0ffd4a23-6e4d-4553-a535-edb86081eb2f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">here are a few of my main findings/hurdles
encountered when upgrading May CTP web projects to Orcas beta 1 Web Application Projects. 
I'm targeting version 3.5 of the framework for deployment on a Server 2003 with .Net
2.0 runtime installed, i will update this article if it doesn't work out.  
<br /><ul><li>
if you had any code in the "App_Code" folder, VS will probably have set the compile
action to "content", it should be changed to "compile".  otherwise you will get
errors like: <font color="#ff0000"><i>The type or namespace name 'xyz' could not be
found (are you missing a using directive or an assembly reference?)</i></font></li><li>
you'll have to remove any reference to the System.Query and System.Expressions, these
are not part of the new LINQ spec.</li><li>
Replace System.Data.DLinq with System.Data.Linq.</li><li>
if you want to use any LINQ expressions, like <i>"from x in db.Table select x" </i>then
you need to include the System.Linq namespace.  otherwise you will get errors
like '<font color="#ff0000"><i>System.Data.Linq.Table&lt;xyz&gt;' does not contain
a definition for 'Where' and no extension method 'Where' accepting a first argument
of type 'System.Data.Linq.Table&lt;xyz&gt;' could be found (are you missing a using
directive or an assembly reference?)<br /></i></font></li><li>
you will also need to include System.Linq.Expressions if you are using "language-level
code expressions to be represented as objects in the form of expression trees".</li></ul>
The old LINQ assemblies are versioned 1.0.2319.19044 (May CTP) but the new ones for
Beta 1 are versioned 2.0.0.0.  Have a check through the referenced assemblies
in your project to make sure you have the latest versions.  
<br /><br /><h3>Crystal reports
</h3>
look out for the new crystal report assemblies, 10.5.3700.0.  a web app referencing
the new versions in web.config will complain if these versions are not available on
the server.  i'll update soon when i have found out how to do this.<br /><br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=0ffd4a23-6e4d-4553-a535-edb86081eb2f" /></body>
      <title>LINQ: upgrading May CTP projects to Orcas Beta 1</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,0ffd4a23-6e4d-4553-a535-edb86081eb2f.aspx</guid>
      <link>http://tim.mackey.ie/LINQUpgradingMayCTPProjectsToOrcasBeta1.aspx</link>
      <pubDate>Mon, 30 Apr 2007 10:50:28 GMT</pubDate>
      <description>here are a few of my main findings/hurdles encountered when upgrading May CTP web projects to Orcas beta 1 Web Application Projects.&amp;nbsp; I'm targeting version 3.5 of the framework for deployment on a Server 2003 with .Net 2.0 runtime installed, i will update this article if it doesn't work out.&amp;nbsp; &lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
if you had any code in the "App_Code" folder, VS will probably have set the compile
action to "content", it should be changed to "compile".&amp;nbsp; otherwise you will get
errors like: &lt;font color="#ff0000"&gt;&lt;i&gt;The type or namespace name 'xyz' could not be
found (are you missing a using directive or an assembly reference?)&lt;/i&gt;&lt;/font&gt;
&lt;/li&gt;
&lt;li&gt;
you'll have to remove any reference to the System.Query and System.Expressions, these
are not part of the new LINQ spec.&lt;/li&gt;
&lt;li&gt;
Replace System.Data.DLinq with System.Data.Linq.&lt;/li&gt;
&lt;li&gt;
if you want to use any LINQ expressions, like &lt;i&gt;"from x in db.Table select x" &lt;/i&gt;then
you need to include the System.Linq namespace.&amp;nbsp; otherwise you will get errors
like '&lt;font color="#ff0000"&gt;&lt;i&gt;System.Data.Linq.Table&amp;lt;xyz&amp;gt;' does not contain
a definition for 'Where' and no extension method 'Where' accepting a first argument
of type 'System.Data.Linq.Table&amp;lt;xyz&amp;gt;' could be found (are you missing a using
directive or an assembly reference?)&lt;br&gt;
&lt;/i&gt;&lt;/font&gt;
&lt;/li&gt;
&lt;li&gt;
you will also need to include System.Linq.Expressions if you are using "language-level
code expressions to be represented as objects in the form of expression trees".&lt;/li&gt;
&lt;/ul&gt;
The old LINQ assemblies are versioned 1.0.2319.19044 (May CTP) but the new ones for
Beta 1 are versioned 2.0.0.0.&amp;nbsp; Have a check through the referenced assemblies
in your project to make sure you have the latest versions.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
&lt;h3&gt;Crystal reports
&lt;/h3&gt;
look out for the new crystal report assemblies, 10.5.3700.0.&amp;nbsp; a web app referencing
the new versions in web.config will complain if these versions are not available on
the server.&amp;nbsp; i'll update soon when i have found out how to do this.&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=0ffd4a23-6e4d-4553-a535-edb86081eb2f" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,0ffd4a23-6e4d-4553-a535-edb86081eb2f.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=0f204bf6-1aa4-4d91-94a8-440b69e390aa</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,0f204bf6-1aa4-4d91-94a8-440b69e390aa.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,0f204bf6-1aa4-4d91-94a8-440b69e390aa.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=0f204bf6-1aa4-4d91-94a8-440b69e390aa</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">If you run a web server, chances are you
have some form of automated monitoring system in place.  If you use MOM or another
enterprise level thing then this post won't be of much relevance.  If, like me,
you have simpler requirements, read on.<br /><br />
I have been caught out a few times with my web sites being down because Windows Server
2003 automatically installed an update and something went wrong and IIS got stopped,
or like this morning at 4am, SQL 2005 SP2 failed to install and left the SQL Service
offline.  i didn't find out till i got a phone call from a client.<br /><br />
My datacenter provide very good ping monitoring with SMS alerts etc., but this is
not a complete solution because the web site may have a configuration error, and it
will still respond to pings.  similarly, you can't just check for an OK HTTP
status code because your error ASPX page may not be configured to send an error HTTP
status code.<br /><br />
I have used various online web site monitoring services, with varying degrees of success
/ satisfaction.  My current provider are InternetVista.com and for €70 a year
i get a 10 minute check for a single HTTP site, with a keyword match on the contents
of the page, and an email/sms alert if the match is not found.  You can pay for
extra and more frequent checks, but €70 is as much as i think the service is worth. 
To have this level of checking done on 10 sites would cost a lot, so to save a few
quid i wrote a very simple aspx page that does a series of tests on all the resources
i want to verify on the server, e.g. SQL Server, MS Access, IIS web sites.  The
aspx code is listed below, i wrote it inline rather than compiled/dll because it is
easier to deploy in an existing web site without any risk of any side effects (dll
collisions), it should be straight forward to understand for a c# programmer. 
let me know if you have questions.  It runs in a few miliseconds on my server
so i'm not worried about polling all these resources every 10 mins.<br /><br /><br /><br />
Run_Server_Tests.aspx code:<br /><pre>&lt;%@ Page Language="C#" %&gt;<br />
&lt;%@ Import Namespace="System.Collections" %&gt;<br />
&lt;%@ Import Namespace="System.Collections.Generic" %&gt;<br />
&lt;%@ Import Namespace="System.Data" %&gt;<br />
&lt;%@ Import Namespace="System.Data.OleDb" %&gt;<br />
&lt;%@ Import Namespace="System.Data.SqlClient" %&gt;<br />
&lt;%@ Import Namespace="System.Net" %&gt;<br /><br />
&lt;script RunAt="server"&gt;<br /><br />
/* Server Monitoring Script:<br />
* - test SQL databases by running an sql string against an SQL connection string<br />
* - test Access databases by running an sql string against a JET connection string<br />
* - test web sites by Regex matching a search string against the contents of a HttpWebRequest<br />
*/<br /><br />
enum TestType {Sql_Server, Ms_Access, Http_Request } // different types of supported
requests<br /><br />
/// &lt;summary&gt;<br />
/// Container class to represent a 'test' object for a resource on the server.<br />
/// &lt;/summary&gt;<br />
class TestObject<br />
{<br />
public TestType Type; // e.g. Sql_Server.<br />
public string TestString; // e.g. connection string for a database. or URI for http
request.<br />
public string TestParam; // e.g. sql string for a database. or search string for a
http request.<br /><br />
public TestObject(TestType type, string testString, string testParam)<br />
{<br />
this.Type = type; 
<br />
this.TestString = testString;<br />
this.TestParam = testParam;<br />
}<br />
}<br /><br />
void Page_Load(object sender, EventArgs e)<br />
{<br />
List&lt;TestObject&gt; tests = new List&lt;TestObject&gt;();<br /><br />
tests.Add(new TestObject(TestType.Sql_Server, @"Data Source=.\SQLEXPRESS;Initial Catalog=DB1;Integrated
Security=True", "select top 10 * from Table1"));<br />
tests.Add(new TestObject(TestType.Sql_Server, @"Data Source=.\SQLEXPRESS;Initial Catalog=DB2;Integrated
Security=True", "select top 10 * from Table1"));<br />
tests.Add(new TestObject(TestType.Sql_Server, @"Data Source=.\SQLEXPRESS;Initial Catalog=DB3;Integrated
Security=True", "select top 10 * from Table1"));<br />
tests.Add(new TestObject(TestType.Sql_Server, @"Data Source=.\SQLEXPRESS;Initial Catalog=DB4;Integrated
Security=True", "select top 10 * from Table1"));<br /><br />
tests.Add(new TestObject(TestType.Ms_Access, @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\Inetpub\Database\DB5.mdb;Persist Security Info=True", "select top 10 * from
Table1"));<br />
tests.Add(new TestObject(TestType.Ms_Access, @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\Inetpub\Database\DB6.mdb;Persist Security Info=True", "select top 10 * from
Table1"));<br /><br />
tests.Add(new TestObject(TestType.Http_Request, "http://mysite1.ie/", "Site 1"));<br />
tests.Add(new TestObject(TestType.Http_Request, "http://mysite2.ie/", "Site 2"));<br />
tests.Add(new TestObject(TestType.Http_Request, "https://mysite3.ie/", "Site 3"));<br />
tests.Add(new TestObject(TestType.Http_Request, "https://mysite4.ie/", "Site 4"));<br />
tests.Add(new TestObject(TestType.Http_Request, "https://mysite5.ie/", "Site 5"));<br /><br />
int numCompleted = 0;<br />
int numFailed = 0;<br /><br />
// write the HTML header. (a result is flushed to the client after each test finishes.)<br />
Flush(@" 
<br />
&lt;!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Server Test&lt;/title&gt;<br />
&lt;meta name='ROBOTS' content='NOINDEX,NOFOLLOW'&gt;<br />
&lt;link rel='stylesheet' type='text/css' href='ServerTestStyles.css' /&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;");<br /><br />
foreach(TestObject test in tests)<br />
{ 
<br />
try<br />
{<br />
switch(test.Type)<br />
{ 
<br />
case TestType.Sql_Server:<br />
runQuerySql(test.TestParam, test.TestString);<br />
break;<br />
case TestType.Ms_Access:<br />
runQueryOleDb(test.TestParam, test.TestString);<br />
break;<br />
case TestType.Http_Request:<br />
string pageContents = new WebClient().DownloadString(test.TestString);<br />
if(!Regex.IsMatch(pageContents, test.TestParam, RegexOptions.IgnoreCase))<br />
throw new Exception("Search string not found: " + test.TestParam);<br />
break;<br />
default:<br />
throw new Exception("Test type not handled " + test.Type);<br />
}<br />
Flush(String.Format("&lt;span class='pass'&gt;Pass&lt;/span&gt; &amp;nbsp; &lt;span
class='type'&gt;{0}&lt;/span&gt; &amp;nbsp; {1} &lt;hr /&gt;", test.Type, test.TestString));<br />
numCompleted++;<br />
}<br />
catch(Exception ex)<br />
{<br />
Flush(String.Format("&lt;span class='fail'&gt;Fail&lt;/span&gt; &amp;nbsp; {1} &lt;span
class='type'&gt;{0}&lt;/span&gt;&lt;BR&gt;&lt;span class='error'&gt;{2}&lt;/span&gt;&lt;hr
/&gt;", test.Type, test.TestString, ex.Message));<br />
numFailed++;<br />
}<br />
}<br />
if(numFailed &gt; 0)<br />
Flush(String.Format("&lt;h1&gt;{0} errors occured&lt;/h1&gt;", numFailed));<br />
else<br />
Flush(String.Format("&lt;h1&gt;All Good!&lt;/h1&gt;", numFailed)); // if you use this
page with an automated monitoring service, look for "All Good" in the page contents.
otherwise an error occured<br />
Flush("&lt;/body&gt;&lt;/html&gt;");<br />
}<br /><br />
/// &lt;summary&gt;<br />
/// Method to run an sql string against an sql database<br />
/// &lt;/summary&gt;<br />
public static DataSet runQuerySql(string sql, string connString)<br />
{<br />
SqlConnection conn = new SqlConnection(connString);<br />
DataSet ds = new DataSet();<br />
SqlDataAdapter dba = new SqlDataAdapter();<br />
SqlCommand cmd = new SqlCommand(sql, conn);<br /><br />
try<br />
{<br />
dba.SelectCommand = cmd;<br />
dba.Fill(ds, "Table");<br />
return (ds);<br />
}<br />
catch(Exception e)<br />
{<br />
throw e;<br />
}<br />
finally<br />
{<br />
cmd.Connection.Close();<br />
conn.Close();<br />
}<br />
}<br /><br />
/// &lt;summary&gt;<br />
/// Method to run an sql string against an Access database<br />
/// &lt;/summary&gt;<br />
public static DataSet runQueryOleDb(string sql, string connString)<br />
{<br />
OleDbConnection conn = new OleDbConnection(connString);<br />
DataSet ds = new DataSet();<br />
OleDbDataAdapter dba = new OleDbDataAdapter();<br />
OleDbCommand cmd = new OleDbCommand(sql, conn);<br /><br />
try<br />
{<br />
dba.SelectCommand = cmd;<br />
dba.Fill(ds, "Table");<br />
return (ds);<br />
}<br />
catch(Exception e)<br />
{<br />
throw e;<br />
}<br />
finally<br />
{<br />
cmd.Connection.Close();<br />
conn.Close();<br />
}<br />
}<br /><br />
/// &lt;summary&gt;<br />
/// Flush output to the browser (useful to indicate which tests are causing any delay)<br />
/// &lt;/summary&gt;<br />
/// &lt;param name="output"&gt;&lt;/param&gt;<br />
private void Flush(string output)<br />
{<br />
Response.Write(output);<br />
Response.Flush();<br />
}<br /><br />
&lt;/script&gt;<br /></pre><p>
ServerTestStyles.css:  (just to make the output more legible)
</p><pre>body<br />
{<br />
font-size: 90%;<br />
font-family: Calibri, Helvetica, Sans-Serif;<br />
padding: .5em;<br />
}<br /><br />
hr<br />
{<br />
color: #87ceeb;<br />
background-color: #87ceeb;<br />
margin: .3em 0 .3em 0;<br />
padding: 0;<br />
height: 1px;<br />
}<br /><br />
.pass<br />
{<br />
color: Blue;<br />
font-weight: bold;<br />
}<br />
.fail<br />
{<br />
color: Red;<br />
font-weight: bold;<br />
}<br />
.type<br />
{<br />
color: purple;<br />
font-weight: bold;<br />
}<br />
.error<br />
{<br />
color: Red;<br />
font-size: small;<br />
}<br /></pre><p>
I have configured the test in InternetVista to search for "All Good" in the url for
the test page.  If this isn't present, i'll get an SMS/email alert and i can
go and see what exactly is wrong.  It should be fairly easy to add other test
types if you have different resources you need to check on.<br />
Enjoy.<br /></p><img src="http://tim.mackey.ie/content/binary/server_test.jpg" border="0" /><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=0f204bf6-1aa4-4d91-94a8-440b69e390aa" /></body>
      <title>Really simple and affordable web server monitoring </title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,0f204bf6-1aa4-4d91-94a8-440b69e390aa.aspx</guid>
      <link>http://tim.mackey.ie/ReallySimpleAndAffordableWebServerMonitoring.aspx</link>
      <pubDate>Fri, 09 Mar 2007 17:43:24 GMT</pubDate>
      <description>If you run a web server, chances are you have some form of automated monitoring system in place.&amp;nbsp; If you use MOM or another enterprise level thing then this post won't be of much relevance.&amp;nbsp; If, like me, you have simpler requirements, read on.&lt;br&gt;
&lt;br&gt;
I have been caught out a few times with my web sites being down because Windows Server
2003 automatically installed an update and something went wrong and IIS got stopped,
or like this morning at 4am, SQL 2005 SP2 failed to install and left the SQL Service
offline.&amp;nbsp; i didn't find out till i got a phone call from a client.&lt;br&gt;
&lt;br&gt;
My datacenter provide very good ping monitoring with SMS alerts etc., but this is
not a complete solution because the web site may have a configuration error, and it
will still respond to pings.&amp;nbsp; similarly, you can't just check for an OK HTTP
status code because your error ASPX page may not be configured to send an error HTTP
status code.&lt;br&gt;
&lt;br&gt;
I have used various online web site monitoring services, with varying degrees of success
/ satisfaction.&amp;nbsp; My current provider are InternetVista.com and for €70 a year
i get a 10 minute check for a single HTTP site, with a keyword match on the contents
of the page, and an email/sms alert if the match is not found.&amp;nbsp; You can pay for
extra and more frequent checks, but €70 is as much as i think the service is worth.&amp;nbsp;
To have this level of checking done on 10 sites would cost a lot, so to save a few
quid i wrote a very simple aspx page that does a series of tests on all the resources
i want to verify on the server, e.g. SQL Server, MS Access, IIS web sites.&amp;nbsp; The
aspx code is listed below, i wrote it inline rather than compiled/dll because it is
easier to deploy in an existing web site without any risk of any side effects (dll
collisions), it should be straight forward to understand for a c# programmer.&amp;nbsp;
let me know if you have questions.&amp;nbsp; It runs in a few miliseconds on my server
so i'm not worried about polling all these resources every 10 mins.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Run_Server_Tests.aspx code:&lt;br&gt;
&lt;pre&gt;&amp;lt;%@ Page Language="C#" %&amp;gt;&lt;br&gt;
&amp;lt;%@ Import Namespace="System.Collections" %&amp;gt;&lt;br&gt;
&amp;lt;%@ Import Namespace="System.Collections.Generic" %&amp;gt;&lt;br&gt;
&amp;lt;%@ Import Namespace="System.Data" %&amp;gt;&lt;br&gt;
&amp;lt;%@ Import Namespace="System.Data.OleDb" %&amp;gt;&lt;br&gt;
&amp;lt;%@ Import Namespace="System.Data.SqlClient" %&amp;gt;&lt;br&gt;
&amp;lt;%@ Import Namespace="System.Net" %&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;script RunAt="server"&amp;gt;&lt;br&gt;
&lt;br&gt;
/* Server Monitoring Script:&lt;br&gt;
* - test SQL databases by running an sql string against an SQL connection string&lt;br&gt;
* - test Access databases by running an sql string against a JET connection string&lt;br&gt;
* - test web sites by Regex matching a search string against the contents of a HttpWebRequest&lt;br&gt;
*/&lt;br&gt;
&lt;br&gt;
enum TestType {Sql_Server, Ms_Access, Http_Request } // different types of supported
requests&lt;br&gt;
&lt;br&gt;
/// &amp;lt;summary&amp;gt;&lt;br&gt;
/// Container class to represent a 'test' object for a resource on the server.&lt;br&gt;
/// &amp;lt;/summary&amp;gt;&lt;br&gt;
class TestObject&lt;br&gt;
{&lt;br&gt;
public TestType Type; // e.g. Sql_Server.&lt;br&gt;
public string TestString; // e.g. connection string for a database. or URI for http
request.&lt;br&gt;
public string TestParam; // e.g. sql string for a database. or search string for a
http request.&lt;br&gt;
&lt;br&gt;
public TestObject(TestType type, string testString, string testParam)&lt;br&gt;
{&lt;br&gt;
this.Type = type; 
&lt;br&gt;
this.TestString = testString;&lt;br&gt;
this.TestParam = testParam;&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
void Page_Load(object sender, EventArgs e)&lt;br&gt;
{&lt;br&gt;
List&amp;lt;TestObject&amp;gt; tests = new List&amp;lt;TestObject&amp;gt;();&lt;br&gt;
&lt;br&gt;
tests.Add(new TestObject(TestType.Sql_Server, @"Data Source=.\SQLEXPRESS;Initial Catalog=DB1;Integrated
Security=True", "select top 10 * from Table1"));&lt;br&gt;
tests.Add(new TestObject(TestType.Sql_Server, @"Data Source=.\SQLEXPRESS;Initial Catalog=DB2;Integrated
Security=True", "select top 10 * from Table1"));&lt;br&gt;
tests.Add(new TestObject(TestType.Sql_Server, @"Data Source=.\SQLEXPRESS;Initial Catalog=DB3;Integrated
Security=True", "select top 10 * from Table1"));&lt;br&gt;
tests.Add(new TestObject(TestType.Sql_Server, @"Data Source=.\SQLEXPRESS;Initial Catalog=DB4;Integrated
Security=True", "select top 10 * from Table1"));&lt;br&gt;
&lt;br&gt;
tests.Add(new TestObject(TestType.Ms_Access, @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\Inetpub\Database\DB5.mdb;Persist Security Info=True", "select top 10 * from
Table1"));&lt;br&gt;
tests.Add(new TestObject(TestType.Ms_Access, @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\Inetpub\Database\DB6.mdb;Persist Security Info=True", "select top 10 * from
Table1"));&lt;br&gt;
&lt;br&gt;
tests.Add(new TestObject(TestType.Http_Request, "http://mysite1.ie/", "Site 1"));&lt;br&gt;
tests.Add(new TestObject(TestType.Http_Request, "http://mysite2.ie/", "Site 2"));&lt;br&gt;
tests.Add(new TestObject(TestType.Http_Request, "https://mysite3.ie/", "Site 3"));&lt;br&gt;
tests.Add(new TestObject(TestType.Http_Request, "https://mysite4.ie/", "Site 4"));&lt;br&gt;
tests.Add(new TestObject(TestType.Http_Request, "https://mysite5.ie/", "Site 5"));&lt;br&gt;
&lt;br&gt;
int numCompleted = 0;&lt;br&gt;
int numFailed = 0;&lt;br&gt;
&lt;br&gt;
// write the HTML header. (a result is flushed to the client after each test finishes.)&lt;br&gt;
Flush(@" 
&lt;br&gt;
&amp;lt;!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'&amp;gt;&lt;br&gt;
&amp;lt;html&amp;gt;&lt;br&gt;
&amp;lt;head&amp;gt;&lt;br&gt;
&amp;lt;title&amp;gt;Server Test&amp;lt;/title&amp;gt;&lt;br&gt;
&amp;lt;meta name='ROBOTS' content='NOINDEX,NOFOLLOW'&amp;gt;&lt;br&gt;
&amp;lt;link rel='stylesheet' type='text/css' href='ServerTestStyles.css' /&amp;gt;&lt;br&gt;
&amp;lt;/head&amp;gt;&lt;br&gt;
&amp;lt;body&amp;gt;");&lt;br&gt;
&lt;br&gt;
foreach(TestObject test in tests)&lt;br&gt;
{ 
&lt;br&gt;
try&lt;br&gt;
{&lt;br&gt;
switch(test.Type)&lt;br&gt;
{ 
&lt;br&gt;
case TestType.Sql_Server:&lt;br&gt;
runQuerySql(test.TestParam, test.TestString);&lt;br&gt;
break;&lt;br&gt;
case TestType.Ms_Access:&lt;br&gt;
runQueryOleDb(test.TestParam, test.TestString);&lt;br&gt;
break;&lt;br&gt;
case TestType.Http_Request:&lt;br&gt;
string pageContents = new WebClient().DownloadString(test.TestString);&lt;br&gt;
if(!Regex.IsMatch(pageContents, test.TestParam, RegexOptions.IgnoreCase))&lt;br&gt;
throw new Exception("Search string not found: " + test.TestParam);&lt;br&gt;
break;&lt;br&gt;
default:&lt;br&gt;
throw new Exception("Test type not handled " + test.Type);&lt;br&gt;
}&lt;br&gt;
Flush(String.Format("&amp;lt;span class='pass'&amp;gt;Pass&amp;lt;/span&amp;gt; &amp;amp;nbsp; &amp;lt;span
class='type'&amp;gt;{0}&amp;lt;/span&amp;gt; &amp;amp;nbsp; {1} &amp;lt;hr /&amp;gt;", test.Type, test.TestString));&lt;br&gt;
numCompleted++;&lt;br&gt;
}&lt;br&gt;
catch(Exception ex)&lt;br&gt;
{&lt;br&gt;
Flush(String.Format("&amp;lt;span class='fail'&amp;gt;Fail&amp;lt;/span&amp;gt; &amp;amp;nbsp; {1} &amp;lt;span
class='type'&amp;gt;{0}&amp;lt;/span&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;span class='error'&amp;gt;{2}&amp;lt;/span&amp;gt;&amp;lt;hr
/&amp;gt;", test.Type, test.TestString, ex.Message));&lt;br&gt;
numFailed++;&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
if(numFailed &amp;gt; 0)&lt;br&gt;
Flush(String.Format("&amp;lt;h1&amp;gt;{0} errors occured&amp;lt;/h1&amp;gt;", numFailed));&lt;br&gt;
else&lt;br&gt;
Flush(String.Format("&amp;lt;h1&amp;gt;All Good!&amp;lt;/h1&amp;gt;", numFailed)); // if you use this
page with an automated monitoring service, look for "All Good" in the page contents.
otherwise an error occured&lt;br&gt;
Flush("&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;");&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
/// &amp;lt;summary&amp;gt;&lt;br&gt;
/// Method to run an sql string against an sql database&lt;br&gt;
/// &amp;lt;/summary&amp;gt;&lt;br&gt;
public static DataSet runQuerySql(string sql, string connString)&lt;br&gt;
{&lt;br&gt;
SqlConnection conn = new SqlConnection(connString);&lt;br&gt;
DataSet ds = new DataSet();&lt;br&gt;
SqlDataAdapter dba = new SqlDataAdapter();&lt;br&gt;
SqlCommand cmd = new SqlCommand(sql, conn);&lt;br&gt;
&lt;br&gt;
try&lt;br&gt;
{&lt;br&gt;
dba.SelectCommand = cmd;&lt;br&gt;
dba.Fill(ds, "Table");&lt;br&gt;
return (ds);&lt;br&gt;
}&lt;br&gt;
catch(Exception e)&lt;br&gt;
{&lt;br&gt;
throw e;&lt;br&gt;
}&lt;br&gt;
finally&lt;br&gt;
{&lt;br&gt;
cmd.Connection.Close();&lt;br&gt;
conn.Close();&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
/// &amp;lt;summary&amp;gt;&lt;br&gt;
/// Method to run an sql string against an Access database&lt;br&gt;
/// &amp;lt;/summary&amp;gt;&lt;br&gt;
public static DataSet runQueryOleDb(string sql, string connString)&lt;br&gt;
{&lt;br&gt;
OleDbConnection conn = new OleDbConnection(connString);&lt;br&gt;
DataSet ds = new DataSet();&lt;br&gt;
OleDbDataAdapter dba = new OleDbDataAdapter();&lt;br&gt;
OleDbCommand cmd = new OleDbCommand(sql, conn);&lt;br&gt;
&lt;br&gt;
try&lt;br&gt;
{&lt;br&gt;
dba.SelectCommand = cmd;&lt;br&gt;
dba.Fill(ds, "Table");&lt;br&gt;
return (ds);&lt;br&gt;
}&lt;br&gt;
catch(Exception e)&lt;br&gt;
{&lt;br&gt;
throw e;&lt;br&gt;
}&lt;br&gt;
finally&lt;br&gt;
{&lt;br&gt;
cmd.Connection.Close();&lt;br&gt;
conn.Close();&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
/// &amp;lt;summary&amp;gt;&lt;br&gt;
/// Flush output to the browser (useful to indicate which tests are causing any delay)&lt;br&gt;
/// &amp;lt;/summary&amp;gt;&lt;br&gt;
/// &amp;lt;param name="output"&amp;gt;&amp;lt;/param&amp;gt;&lt;br&gt;
private void Flush(string output)&lt;br&gt;
{&lt;br&gt;
Response.Write(output);&lt;br&gt;
Response.Flush();&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&amp;lt;/script&amp;gt;&lt;br&gt;
&lt;/pre&gt;
&lt;p&gt;
ServerTestStyles.css:&amp;nbsp; (just to make the output more legible)
&lt;/p&gt;
&lt;pre&gt;body&lt;br&gt;
{&lt;br&gt;
font-size: 90%;&lt;br&gt;
font-family: Calibri, Helvetica, Sans-Serif;&lt;br&gt;
padding: .5em;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
hr&lt;br&gt;
{&lt;br&gt;
color: #87ceeb;&lt;br&gt;
background-color: #87ceeb;&lt;br&gt;
margin: .3em 0 .3em 0;&lt;br&gt;
padding: 0;&lt;br&gt;
height: 1px;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
.pass&lt;br&gt;
{&lt;br&gt;
color: Blue;&lt;br&gt;
font-weight: bold;&lt;br&gt;
}&lt;br&gt;
.fail&lt;br&gt;
{&lt;br&gt;
color: Red;&lt;br&gt;
font-weight: bold;&lt;br&gt;
}&lt;br&gt;
.type&lt;br&gt;
{&lt;br&gt;
color: purple;&lt;br&gt;
font-weight: bold;&lt;br&gt;
}&lt;br&gt;
.error&lt;br&gt;
{&lt;br&gt;
color: Red;&lt;br&gt;
font-size: small;&lt;br&gt;
}&lt;br&gt;
&lt;/pre&gt;
&lt;p&gt;
I have configured the test in InternetVista to search for "All Good" in the url for
the test page.&amp;nbsp; If this isn't present, i'll get an SMS/email alert and i can
go and see what exactly is wrong.&amp;nbsp; It should be fairly easy to add other test
types if you have different resources you need to check on.&lt;br&gt;
Enjoy.&lt;br&gt;
&lt;/p&gt;
&lt;img src="http://tim.mackey.ie/content/binary/server_test.jpg" border="0"&gt;&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=0f204bf6-1aa4-4d91-94a8-440b69e390aa" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,0f204bf6-1aa4-4d91-94a8-440b69e390aa.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
      <category>Database</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=47c6d892-b64b-4349-9cf0-de0697e2b7f2</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,47c6d892-b64b-4349-9cf0-de0697e2b7f2.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,47c6d892-b64b-4349-9cf0-de0697e2b7f2.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=47c6d892-b64b-4349-9cf0-de0697e2b7f2</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">Here is the event log crash entry:<br /><p><font color="#ff0000">Faulting application devenv.exe, version 8.0.50727.762, time
stamp 0x45716759, faulting module craxddrt.dll_unloaded, version 0.0.0.0,<br />
time stamp 0x43068582, exception code 0xc0000005, fault offset 0x0d26e30f, process
id 0x1180, application start time 0x01c75cae13960a41.</font></p>
it would crash completely randomly, even if i had closed all crystal reports and was
working in a style sheet or other such harmless file. As i later found out, it was
because the solution opened by default with the last crystal report i was working
on, and this seemed to start some crystal report ActiveX thing that craps out on Vista. 
sometimes it would take 2 minutes and sometimes 5 minutes, but it would always crash,
even if i closed the report straight away.  The only way to get rid of it was
to load up VS, close the report immediately and safely close VS before it got a chance
to crash!  then next time it opens, there is no crystal report and the ActiveX
control never loads.  it works ok now, although this is just one of a long list
of complaints i have with VS 2005.  i think i'm allergic to crystal reports.<br /><br /><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=47c6d892-b64b-4349-9cf0-de0697e2b7f2" /></body>
      <title>FIX: VS 2005 crashes randomly when using Crystal Reports</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,47c6d892-b64b-4349-9cf0-de0697e2b7f2.aspx</guid>
      <link>http://tim.mackey.ie/FIXVS2005CrashesRandomlyWhenUsingCrystalReports.aspx</link>
      <pubDate>Fri, 02 Mar 2007 09:58:51 GMT</pubDate>
      <description>Here is the event log crash entry:&lt;br&gt;
&lt;p&gt;
&lt;font color="#ff0000"&gt;Faulting application devenv.exe, version 8.0.50727.762, time
stamp 0x45716759, faulting module craxddrt.dll_unloaded, version 0.0.0.0,&lt;br&gt;
time stamp 0x43068582, exception code 0xc0000005, fault offset 0x0d26e30f, process
id 0x1180, application start time 0x01c75cae13960a41.&lt;/font&gt;
&lt;/p&gt;
it would crash completely randomly, even if i had closed all crystal reports and was
working in a style sheet or other such harmless file. As i later found out, it was
because the solution opened by default with the last crystal report i was working
on, and this seemed to start some crystal report ActiveX thing that craps out on Vista.&amp;nbsp;
sometimes it would take 2 minutes and sometimes 5 minutes, but it would always crash,
even if i closed the report straight away.&amp;nbsp; The only way to get rid of it was
to load up VS, close the report immediately and safely close VS before it got a chance
to crash!&amp;nbsp; then next time it opens, there is no crystal report and the ActiveX
control never loads.&amp;nbsp; it works ok now, although this is just one of a long list
of complaints i have with VS 2005.&amp;nbsp; i think i'm allergic to crystal reports.&lt;br&gt;
&lt;br&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=47c6d892-b64b-4349-9cf0-de0697e2b7f2" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,47c6d892-b64b-4349-9cf0-de0697e2b7f2.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=be13ff65-9d01-4ae3-b974-961cdd7ce180</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,be13ff65-9d01-4ae3-b974-961cdd7ce180.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,be13ff65-9d01-4ae3-b974-961cdd7ce180.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=be13ff65-9d01-4ae3-b974-961cdd7ce180</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">The full error i got was below:<br /><pre>Error    35    The type 'CrystalDecisions.Shared.ExportFormatType' exists in both 
<br />
'c:\Windows\assembly\GAC\CrystalDecisions.Shared\9.1.5000.0__692fbea5521e1304\CrystalDecisions.Shared.dll'
and 
<br />
'c:\Windows\assembly\GAC_MSIL\CrystalDecisions.Shared\10.2.3600.0__692fbea5521e1304\CrystalDecisions.Shared.dll'   
<br /></pre>The reason is because version 9 and 10 of crystal reports are installed on my
dev box and VS needed help deciding which one to use.  the fix was to specify
the exact assembly binding to use in web.config, as follows:<br /><pre>	&lt;runtime&gt;<br />
&lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;<br />
&lt;dependentAssembly&gt;<br />
&lt;assemblyIdentity name="CrystalDecisions.CrystalReports.Engine" publicKeyToken="692fbea5521e1304"
/&gt;<br />
&lt;bindingRedirect oldVersion="9.1.5000.0" newVersion="10.2.3600.0"/&gt;<br />
&lt;/dependentAssembly&gt;<br />
&lt;dependentAssembly&gt;<br />
&lt;assemblyIdentity name="CrystalDecisions.CrystalReports.Shared" publicKeyToken="692fbea5521e1304"
/&gt;<br />
&lt;bindingRedirect oldVersion="9.1.5000.0" newVersion="10.2.3600.0"/&gt;<br />
&lt;/dependentAssembly&gt;<br />
&lt;dependentAssembly&gt;<br />
&lt;assemblyIdentity name="CrystalDecisions.Shared" publicKeyToken="692fbea5521e1304"
/&gt;<br />
&lt;bindingRedirect oldVersion="9.1.5000.0" newVersion="10.2.3600.0"/&gt;<br />
&lt;/dependentAssembly&gt;<br />
&lt;/assemblyBinding&gt;<br />
&lt;/runtime&gt;<br /></pre>thanks to <a href="http://blogs.gotdotnet.com/richarde/archive/2005/09/02/468187.aspx">rick
ersek</a> for the solution.<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=be13ff65-9d01-4ae3-b974-961cdd7ce180" /></body>
      <title>Fix: VS 2005 compile error: The type 'xyz' exists in both X and Y</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,be13ff65-9d01-4ae3-b974-961cdd7ce180.aspx</guid>
      <link>http://tim.mackey.ie/FixVS2005CompileErrorTheTypeXyzExistsInBothXAndY.aspx</link>
      <pubDate>Fri, 23 Feb 2007 17:51:46 GMT</pubDate>
      <description>The full error i got was below:&lt;br&gt;
&lt;pre&gt;Error&amp;nbsp;&amp;nbsp; &amp;nbsp;35&amp;nbsp;&amp;nbsp; &amp;nbsp;The type 'CrystalDecisions.Shared.ExportFormatType' exists in both 
&lt;br&gt;
'c:\Windows\assembly\GAC\CrystalDecisions.Shared\9.1.5000.0__692fbea5521e1304\CrystalDecisions.Shared.dll'
and 
&lt;br&gt;
'c:\Windows\assembly\GAC_MSIL\CrystalDecisions.Shared\10.2.3600.0__692fbea5521e1304\CrystalDecisions.Shared.dll'&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&lt;/pre&gt;The reason is because version 9 and 10 of crystal reports are installed on my
dev box and VS needed help deciding which one to use.&amp;nbsp; the fix was to specify
the exact assembly binding to use in web.config, as follows:&lt;br&gt;
&lt;pre&gt;	&amp;lt;runtime&amp;gt;&lt;br&gt;
&amp;lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&amp;gt;&lt;br&gt;
&amp;lt;dependentAssembly&amp;gt;&lt;br&gt;
&amp;lt;assemblyIdentity name="CrystalDecisions.CrystalReports.Engine" publicKeyToken="692fbea5521e1304"
/&amp;gt;&lt;br&gt;
&amp;lt;bindingRedirect oldVersion="9.1.5000.0" newVersion="10.2.3600.0"/&amp;gt;&lt;br&gt;
&amp;lt;/dependentAssembly&amp;gt;&lt;br&gt;
&amp;lt;dependentAssembly&amp;gt;&lt;br&gt;
&amp;lt;assemblyIdentity name="CrystalDecisions.CrystalReports.Shared" publicKeyToken="692fbea5521e1304"
/&amp;gt;&lt;br&gt;
&amp;lt;bindingRedirect oldVersion="9.1.5000.0" newVersion="10.2.3600.0"/&amp;gt;&lt;br&gt;
&amp;lt;/dependentAssembly&amp;gt;&lt;br&gt;
&amp;lt;dependentAssembly&amp;gt;&lt;br&gt;
&amp;lt;assemblyIdentity name="CrystalDecisions.Shared" publicKeyToken="692fbea5521e1304"
/&amp;gt;&lt;br&gt;
&amp;lt;bindingRedirect oldVersion="9.1.5000.0" newVersion="10.2.3600.0"/&amp;gt;&lt;br&gt;
&amp;lt;/dependentAssembly&amp;gt;&lt;br&gt;
&amp;lt;/assemblyBinding&amp;gt;&lt;br&gt;
&amp;lt;/runtime&amp;gt;&lt;br&gt;
&lt;/pre&gt;thanks to &lt;a href="http://blogs.gotdotnet.com/richarde/archive/2005/09/02/468187.aspx"&gt;rick
ersek&lt;/a&gt; for the solution.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=be13ff65-9d01-4ae3-b974-961cdd7ce180" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,be13ff65-9d01-4ae3-b974-961cdd7ce180.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=daaea48c-b4ae-4800-9de0-fc1ad182d207</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,daaea48c-b4ae-4800-9de0-fc1ad182d207.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,daaea48c-b4ae-4800-9de0-fc1ad182d207.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=daaea48c-b4ae-4800-9de0-fc1ad182d207</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">my Visual Source Safe database had grown
very large and i couldn't see why.  digging around in the aaaaaaamb.a files revealed
an episode of robin-hood that had accidentally been checked in to VSS.  the thing
was i had deleted it through VS but it hadn't been purged from VSS.  with the
VSS graphical interface, you can right-click any folder and it will tell you in the
deleted items tab if there are any deleted (but not yet purged) items.  however
this is very time-consuming.<br />
thanks to a post on a newsgroup, i discovered the command line interface, which has
an option to list deleted files, and you can then purge them. you still have to scan
through the output, which is presented in a very crude way to say the least. 
if there are deleted files, you would think it should just list them.  but no,
it lists every directory and says 'no items found under ...' after it, which makes
for a lot of noise when you are trying to scan for directories that actually contain
deleted files.  
<br />
anway, here's the commands:<br /><br /><pre>set SSDIR=C:\Data\VSS                                        ** the folder containing of your srcsafe.ini file **<br />
cd "C:\Program Files\Microsoft Visual SourceSafe\"<br />
ss dir -R -D $/*.*</pre><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=daaea48c-b4ae-4800-9de0-fc1ad182d207" /></body>
      <title>VSS: listing deleted files</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,daaea48c-b4ae-4800-9de0-fc1ad182d207.aspx</guid>
      <link>http://tim.mackey.ie/VSSListingDeletedFiles.aspx</link>
      <pubDate>Sun, 18 Feb 2007 11:42:07 GMT</pubDate>
      <description>my Visual Source Safe database had grown very large and i couldn't see why.&amp;nbsp; digging around in the aaaaaaamb.a files revealed an episode of robin-hood that had accidentally been checked in to VSS.&amp;nbsp; the thing was i had deleted it through VS but it hadn't been purged from VSS.&amp;nbsp; with the VSS graphical interface, you can right-click any folder and it will tell you in the deleted items tab if there are any deleted (but not yet purged) items.&amp;nbsp; however this is very time-consuming.&lt;br&gt;
thanks to a post on a newsgroup, i discovered the command line interface, which has
an option to list deleted files, and you can then purge them. you still have to scan
through the output, which is presented in a very crude way to say the least.&amp;nbsp;
if there are deleted files, you would think it should just list them.&amp;nbsp; but no,
it lists every directory and says 'no items found under ...' after it, which makes
for a lot of noise when you are trying to scan for directories that actually contain
deleted files.&amp;nbsp; 
&lt;br&gt;
anway, here's the commands:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;set SSDIR=C:\Data\VSS&amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  ** the folder containing of your srcsafe.ini file **&lt;br&gt;
cd "C:\Program Files\Microsoft Visual SourceSafe\"&lt;br&gt;
ss dir -R -D $/*.*&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=daaea48c-b4ae-4800-9de0-fc1ad182d207" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,daaea48c-b4ae-4800-9de0-fc1ad182d207.aspx</comments>
      <category>.Net General</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=0b94a149-0fa5-4dbb-95e3-8a3e4859760c</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,0b94a149-0fa5-4dbb-95e3-8a3e4859760c.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,0b94a149-0fa5-4dbb-95e3-8a3e4859760c.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=0b94a149-0fa5-4dbb-95e3-8a3e4859760c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">if you're querying an MS access database
from within access, you can use ? and # as wildcard single character/digit placeholders. 
<br />
however, if you're querying via OleDb, then you have to use _<br />
this took me ages to figure out. thanks to this <a href="http://msdn2.microsoft.com/en-us/library/aa140104%28office.10%29.aspx">useful
entry in msdn2</a>.<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=0b94a149-0fa5-4dbb-95e3-8a3e4859760c" /></body>
      <title>LIKE problems with oledb query</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,0b94a149-0fa5-4dbb-95e3-8a3e4859760c.aspx</guid>
      <link>http://tim.mackey.ie/LIKEProblemsWithOledbQuery.aspx</link>
      <pubDate>Mon, 15 Jan 2007 12:33:47 GMT</pubDate>
      <description>if you're querying an MS access database from within access, you can use ? and # as wildcard single character/digit placeholders. &lt;br&gt;
however, if you're querying via OleDb, then you have to use _&lt;br&gt;
this took me ages to figure out. thanks to this &lt;a href="http://msdn2.microsoft.com/en-us/library/aa140104%28office.10%29.aspx"&gt;useful
entry in msdn2&lt;/a&gt;.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=0b94a149-0fa5-4dbb-95e3-8a3e4859760c" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,0b94a149-0fa5-4dbb-95e3-8a3e4859760c.aspx</comments>
      <category>.Net General</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=b35fe3e2-f54e-4276-9c51-e3ba65f2c8c5</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,b35fe3e2-f54e-4276-9c51-e3ba65f2c8c5.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,b35fe3e2-f54e-4276-9c51-e3ba65f2c8c5.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=b35fe3e2-f54e-4276-9c51-e3ba65f2c8c5</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">if i ever forget how to write this function
then... well, let's hope i never do.  i was really surprised not to be able to
find it in the SDK.  i'm posting it here for reference anyway.  note: this
can only be used in .Net 2.0 which supports generics.<br /><pre>/// &lt;summary&gt;<br />
/// Swap 2 objects<br />
/// &lt;/summary&gt;<br />
public static void Swap&lt;T&gt;(ref T first, ref T second)<br />
{<br />
T tmp = first;<br />
first = second;<br />
second = tmp;<br />
}<br /></pre><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=b35fe3e2-f54e-4276-9c51-e3ba65f2c8c5" /></body>
      <title>A generic Swap function</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,b35fe3e2-f54e-4276-9c51-e3ba65f2c8c5.aspx</guid>
      <link>http://tim.mackey.ie/AGenericSwapFunction.aspx</link>
      <pubDate>Tue, 10 Oct 2006 15:55:31 GMT</pubDate>
      <description>if i ever forget how to write this function then... well, let's hope i never do.&amp;nbsp; i was really surprised not to be able to find it in the SDK.&amp;nbsp; i'm posting it here for reference anyway.&amp;nbsp; note: this can only be used in .Net 2.0 which supports generics.&lt;br&gt;
&lt;pre&gt;/// &amp;lt;summary&amp;gt;&lt;br&gt;
/// Swap 2 objects&lt;br&gt;
/// &amp;lt;/summary&amp;gt;&lt;br&gt;
public static void Swap&amp;lt;T&amp;gt;(ref T first, ref T second)&lt;br&gt;
{&lt;br&gt;
T tmp = first;&lt;br&gt;
first = second;&lt;br&gt;
second = tmp;&lt;br&gt;
}&lt;br&gt;
&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=b35fe3e2-f54e-4276-9c51-e3ba65f2c8c5" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,b35fe3e2-f54e-4276-9c51-e3ba65f2c8c5.aspx</comments>
      <category>.Net General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=91e8b8f0-e88f-4194-817a-90d5d9a5b869</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,91e8b8f0-e88f-4194-817a-90d5d9a5b869.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,91e8b8f0-e88f-4194-817a-90d5d9a5b869.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=91e8b8f0-e88f-4194-817a-90d5d9a5b869</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">i found this insanely difficult because
none of the supposedly normal options worked.  merge modules didn't seem suitable
because i just wanted to install the CR dlls once and for all on the server. 
according to an <a href="http://msdn2.microsoft.com/en-us/library/ms225241.aspx">MSDN2
article</a> i should be able to perform a windows installer deployment, but of course
when i copy the key code from the VS2005 &gt; Help &gt; About dialog, and use it in
the installer on the server, the error message is that the key code has expired or
is invalid.  'business objects' appear to be forcing users into an upgrade path
for their new product, by claiming that a 'compatibility upgrade' is required for
VS 2005, which of course you have to fork out for.  such a load of crap.  
<br />
anyway, what eventually worked for me was to go back into my VS 2005 dev machine and
create a web set up project. go into the project properties and click the prerequisites
button, select CR for .Net 2.0 and then just build the empty setup project. if you
look in your output folder, there is an installation file called CRRedist2005_x86.msi. 
Just whack this onto the server and your crystal reports should run fine, i didn't
need to reboot or restart IIS.  Note there is no also need to copy any of the
CR dlls to your web site bin folder.  
<br /><br />
yet another miserable failure for crystal reports!<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=91e8b8f0-e88f-4194-817a-90d5d9a5b869" /></body>
      <title>HowTo: Deploy Crystal Reports for VS 2005</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,91e8b8f0-e88f-4194-817a-90d5d9a5b869.aspx</guid>
      <link>http://tim.mackey.ie/HowToDeployCrystalReportsForVS2005.aspx</link>
      <pubDate>Sat, 07 Oct 2006 00:32:30 GMT</pubDate>
      <description>i found this insanely difficult because none of the supposedly normal options worked.&amp;nbsp; merge modules didn't seem suitable because i just wanted to install the CR dlls once and for all on the server.&amp;nbsp; according to an &lt;a href="http://msdn2.microsoft.com/en-us/library/ms225241.aspx"&gt;MSDN2
article&lt;/a&gt; i should be able to perform a windows installer deployment, but of course
when i copy the key code from the VS2005 &amp;gt; Help &amp;gt; About dialog, and use it in
the installer on the server, the error message is that the key code has expired or
is invalid.&amp;nbsp; 'business objects' appear to be forcing users into an upgrade path
for their new product, by claiming that a 'compatibility upgrade' is required for
VS 2005, which of course you have to fork out for.&amp;nbsp; such a load of crap.&amp;nbsp; 
&lt;br&gt;
anyway, what eventually worked for me was to go back into my VS 2005 dev machine and
create a web set up project. go into the project properties and click the prerequisites
button, select CR for .Net 2.0 and then just build the empty setup project. if you
look in your output folder, there is an installation file called CRRedist2005_x86.msi.&amp;nbsp;
Just whack this onto the server and your crystal reports should run fine, i didn't
need to reboot or restart IIS.&amp;nbsp; Note there is no also need to copy any of the
CR dlls to your web site bin folder.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
yet another miserable failure for crystal reports!&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=91e8b8f0-e88f-4194-817a-90d5d9a5b869" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,91e8b8f0-e88f-4194-817a-90d5d9a5b869.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
      <category>Windows Server 2003</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=2ce605fe-2f10-4308-9798-81b00faf108d</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,2ce605fe-2f10-4308-9798-81b00faf108d.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,2ce605fe-2f10-4308-9798-81b00faf108d.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=2ce605fe-2f10-4308-9798-81b00faf108d</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">i took this off <a href="http://en.wikipedia.org/wiki/List_of_countries">Wikipedia</a> and
trimmed it down to plain text for a database.  just posting it here for reference:<br /><br />
You may be more interested in the <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO
official list of countries</a> and their 2-digit codes.<br /><br />
Abkhazia<br />
Afghanistan<br />
SBA Akrotiri and Dhekelia<br />
Åland<br />
Albania<br />
Algeria<br />
American Samoa<br />
Andorra<br />
Angola<br />
Anguilla<br />
Antigua and Barbuda<br />
Argentina<br />
Armenia<br />
Aruba 
<br />
Saint Helena Ascension Island<br />
Australia 
<br />
Austria 
<br />
Azerbaijan 
<br />
The Bahamas 
<br />
Bahrain 
<br />
Bangladesh 
<br />
Barbados 
<br />
Belarus 
<br />
Belgium 
<br />
Belize 
<br />
Benin 
<br />
Bermuda 
<br />
Bhutan 
<br />
Bolivia 
<br />
Bosnia and Herzegovina<br />
Botswana 
<br />
Brazil 
<br />
Brunei 
<br />
Bulgaria 
<br />
Burkina Faso<br />
Burundi<br />
Cambodia 
<br />
Cameroon<br />
Canada<br />
Cape Verde<br />
Cayman Islands<br />
Central African Republic<br />
Chad<br />
Chile<br />
China<br />
Christmas Island 
<br />
Cocos (Keeling) Islands<br />
Colombia<br />
Comoros<br />
Congo<br />
Cook Islands<br />
Costa Rica 
<br />
Côte d'Ivoire<br />
Croatia 
<br />
Cuba 
<br />
Cyprus 
<br />
Czech Republic<br />
Denmark<br />
Djibouti<br />
Dominica<br />
Dominican<br />
Ecuador<br />
Egypt 
<br />
El Salvador 
<br />
Equatorial 
<br />
Eritrea<br />
Estonia 
<br />
Ethiopia<br />
Falkland<br />
Faroe Islands<br />
Fiji 
<br />
Finland 
<br />
France 
<br />
French Polynesia 
<br />
Gabon<br />
Gambia<br />
Georgia<br />
Germany<br />
Ghana 
<br />
Gibraltar 
<br />
Greece 
<br />
Greenland 
<br />
Grenada 
<br />
Guam 
<br />
Guatemala 
<br />
Guernsey 
<br />
Guinea 
<br />
Guinea-Bissau<br />
Guyana 
<br />
Haiti 
<br />
Honduras 
<br />
Hong Kong 
<br />
Hungary 
<br />
Iceland 
<br />
India 
<br />
Indonesia 
<br />
Iran 
<br />
Iraq 
<br />
Ireland<br />
Isle of Man<br />
Israel 
<br />
Italy 
<br />
Jamaica 
<br />
Japan 
<br />
Jersey<br />
Jordan<br />
Kazakhstan 
<br />
Kenya 
<br />
Kiribati 
<br />
North Korea 
<br />
South Korea 
<br />
Kosovo<br />
Kuwait 
<br />
Kyrgyzstan 
<br />
Laos 
<br />
Latvia 
<br />
Lebanon 
<br />
Lesotho 
<br />
Liberia 
<br />
Libya 
<br />
Liechtenstein 
<br />
Lithuania 
<br />
Luxembourg<br />
Macau 
<br />
Macedonia<br />
Madagascar<br />
Malawi 
<br />
Malaysia 
<br />
Maldives 
<br />
Mali 
<br />
Malta<br />
Marshall Islands 
<br />
Mauritania 
<br />
Mauritius 
<br />
Mayotte<br />
Mexico 
<br />
Micronesia 
<br />
Moldova 
<br />
Monaco 
<br />
Mongolia<br />
Montenegro 
<br />
Montserrat 
<br />
Morocco 
<br />
Mozambique<br />
Myanmar 
<br />
Nagorno-Karabakh 
<br />
Namibia 
<br />
Nauru 
<br />
Nepal 
<br />
Netherlands 
<br />
Netherlands Antilles 
<br />
New Caledonia 
<br />
New Zealand 
<br />
Nicaragua 
<br />
Niger 
<br />
Nigeria 
<br />
Niue 
<br />
Norfolk Island 
<br />
Northern Cyprus<br />
Northern Mariana Islands<br />
Norway 
<br />
Oman 
<br />
Pakistan 
<br />
Palau 
<br />
Palestinian 
<br />
Panama 
<br />
Papua New Guinea 
<br />
Paraguay 
<br />
Peru 
<br />
Philippines 
<br />
Pitcairn Islands 
<br />
Poland 
<br />
Portugal 
<br />
Pridnestrovian Moldavian Republic<br />
Puerto Rico<br />
Qatar<br />
Romania 
<br />
Russia 
<br />
Rwanda 
<br />
Saint Helena 
<br />
Saint Kitts and Nevis 
<br />
Saint Lucia 
<br />
Saint Pierre and Miquelon 
<br />
Saint Vincent and the Grenadines<br />
Samoa 
<br />
San Marino 
<br />
São Tomé and Príncipe 
<br />
Saudi Arabia 
<br />
Senegal 
<br />
Serbia 
<br />
Seychelles 
<br />
Sierra Leone 
<br />
Singapore 
<br />
Slovakia 
<br />
Slovenia 
<br />
Solomon Islands 
<br />
Somalia 
<br />
Somaliland<br />
South Africa 
<br />
South Ossetia 
<br />
Spain 
<br />
Sri Lanka 
<br />
Sudan 
<br />
Suriname 
<br />
Svalbard 
<br />
Swaziland 
<br />
Sweden 
<br />
Switzerland 
<br />
Syria 
<br />
Tajikistan 
<br />
Tanzania 
<br />
Thailand 
<br />
East Timor<br />
Togo 
<br />
Tokelau 
<br />
Tonga 
<br />
Trinidad and Tobago<br />
Tristan da Cunha 
<br />
Tunisia 
<br />
Turkey 
<br />
Turkmenistan 
<br />
Turks and Caicos Islands<br />
Tuvalu 
<br />
Uganda 
<br />
Ukraine<br />
United Arab Emirates 
<br />
United Kingdom 
<br />
United States 
<br />
Uruguay 
<br />
Uzbekistan 
<br />
Vanuatu 
<br />
Vatican City 
<br />
Venezuela 
<br />
Vietnam 
<br />
Virgin Islands (British)<br />
Virgin Islands (United States)<br />
Wallis and Futuna<br />
Western Sahara 
<br />
Yemen 
<br />
Zambia 
<br />
Zimbabwe<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=2ce605fe-2f10-4308-9798-81b00faf108d" /></body>
      <title>Global country list</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,2ce605fe-2f10-4308-9798-81b00faf108d.aspx</guid>
      <link>http://tim.mackey.ie/GlobalCountryList.aspx</link>
      <pubDate>Wed, 16 Aug 2006 15:39:04 GMT</pubDate>
      <description>i took this off &lt;a href="http://en.wikipedia.org/wiki/List_of_countries"&gt;Wikipedia&lt;/a&gt; and
trimmed it down to plain text for a database.&amp;nbsp; just posting it here for reference:&lt;br&gt;
&lt;br&gt;
You may be more interested in the &lt;a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html"&gt;ISO
official list of countries&lt;/a&gt; and their 2-digit codes.&lt;br&gt;
&lt;br&gt;
Abkhazia&lt;br&gt;
Afghanistan&lt;br&gt;
SBA Akrotiri and Dhekelia&lt;br&gt;
Åland&lt;br&gt;
Albania&lt;br&gt;
Algeria&lt;br&gt;
American Samoa&lt;br&gt;
Andorra&lt;br&gt;
Angola&lt;br&gt;
Anguilla&lt;br&gt;
Antigua and Barbuda&lt;br&gt;
Argentina&lt;br&gt;
Armenia&lt;br&gt;
Aruba 
&lt;br&gt;
Saint Helena Ascension Island&lt;br&gt;
Australia 
&lt;br&gt;
Austria 
&lt;br&gt;
Azerbaijan 
&lt;br&gt;
The Bahamas 
&lt;br&gt;
Bahrain 
&lt;br&gt;
Bangladesh 
&lt;br&gt;
Barbados 
&lt;br&gt;
Belarus 
&lt;br&gt;
Belgium 
&lt;br&gt;
Belize 
&lt;br&gt;
Benin 
&lt;br&gt;
Bermuda 
&lt;br&gt;
Bhutan 
&lt;br&gt;
Bolivia 
&lt;br&gt;
Bosnia and Herzegovina&lt;br&gt;
Botswana 
&lt;br&gt;
Brazil 
&lt;br&gt;
Brunei 
&lt;br&gt;
Bulgaria 
&lt;br&gt;
Burkina Faso&lt;br&gt;
Burundi&lt;br&gt;
Cambodia 
&lt;br&gt;
Cameroon&lt;br&gt;
Canada&lt;br&gt;
Cape Verde&lt;br&gt;
Cayman Islands&lt;br&gt;
Central African Republic&lt;br&gt;
Chad&lt;br&gt;
Chile&lt;br&gt;
China&lt;br&gt;
Christmas Island 
&lt;br&gt;
Cocos (Keeling) Islands&lt;br&gt;
Colombia&lt;br&gt;
Comoros&lt;br&gt;
Congo&lt;br&gt;
Cook Islands&lt;br&gt;
Costa Rica 
&lt;br&gt;
Côte d'Ivoire&lt;br&gt;
Croatia 
&lt;br&gt;
Cuba 
&lt;br&gt;
Cyprus 
&lt;br&gt;
Czech Republic&lt;br&gt;
Denmark&lt;br&gt;
Djibouti&lt;br&gt;
Dominica&lt;br&gt;
Dominican&lt;br&gt;
Ecuador&lt;br&gt;
Egypt 
&lt;br&gt;
El Salvador 
&lt;br&gt;
Equatorial 
&lt;br&gt;
Eritrea&lt;br&gt;
Estonia 
&lt;br&gt;
Ethiopia&lt;br&gt;
Falkland&lt;br&gt;
Faroe Islands&lt;br&gt;
Fiji 
&lt;br&gt;
Finland 
&lt;br&gt;
France 
&lt;br&gt;
French Polynesia 
&lt;br&gt;
Gabon&lt;br&gt;
Gambia&lt;br&gt;
Georgia&lt;br&gt;
Germany&lt;br&gt;
Ghana 
&lt;br&gt;
Gibraltar 
&lt;br&gt;
Greece 
&lt;br&gt;
Greenland 
&lt;br&gt;
Grenada 
&lt;br&gt;
Guam 
&lt;br&gt;
Guatemala 
&lt;br&gt;
Guernsey 
&lt;br&gt;
Guinea 
&lt;br&gt;
Guinea-Bissau&lt;br&gt;
Guyana 
&lt;br&gt;
Haiti 
&lt;br&gt;
Honduras 
&lt;br&gt;
Hong Kong 
&lt;br&gt;
Hungary 
&lt;br&gt;
Iceland 
&lt;br&gt;
India 
&lt;br&gt;
Indonesia 
&lt;br&gt;
Iran 
&lt;br&gt;
Iraq 
&lt;br&gt;
Ireland&lt;br&gt;
Isle of Man&lt;br&gt;
Israel 
&lt;br&gt;
Italy 
&lt;br&gt;
Jamaica 
&lt;br&gt;
Japan 
&lt;br&gt;
Jersey&lt;br&gt;
Jordan&lt;br&gt;
Kazakhstan 
&lt;br&gt;
Kenya 
&lt;br&gt;
Kiribati 
&lt;br&gt;
North Korea 
&lt;br&gt;
South Korea 
&lt;br&gt;
Kosovo&lt;br&gt;
Kuwait 
&lt;br&gt;
Kyrgyzstan 
&lt;br&gt;
Laos 
&lt;br&gt;
Latvia 
&lt;br&gt;
Lebanon 
&lt;br&gt;
Lesotho 
&lt;br&gt;
Liberia 
&lt;br&gt;
Libya 
&lt;br&gt;
Liechtenstein 
&lt;br&gt;
Lithuania 
&lt;br&gt;
Luxembourg&lt;br&gt;
Macau 
&lt;br&gt;
Macedonia&lt;br&gt;
Madagascar&lt;br&gt;
Malawi 
&lt;br&gt;
Malaysia 
&lt;br&gt;
Maldives 
&lt;br&gt;
Mali 
&lt;br&gt;
Malta&lt;br&gt;
Marshall Islands 
&lt;br&gt;
Mauritania 
&lt;br&gt;
Mauritius 
&lt;br&gt;
Mayotte&lt;br&gt;
Mexico 
&lt;br&gt;
Micronesia 
&lt;br&gt;
Moldova 
&lt;br&gt;
Monaco 
&lt;br&gt;
Mongolia&lt;br&gt;
Montenegro 
&lt;br&gt;
Montserrat 
&lt;br&gt;
Morocco 
&lt;br&gt;
Mozambique&lt;br&gt;
Myanmar 
&lt;br&gt;
Nagorno-Karabakh 
&lt;br&gt;
Namibia 
&lt;br&gt;
Nauru 
&lt;br&gt;
Nepal 
&lt;br&gt;
Netherlands 
&lt;br&gt;
Netherlands Antilles 
&lt;br&gt;
New Caledonia 
&lt;br&gt;
New Zealand 
&lt;br&gt;
Nicaragua 
&lt;br&gt;
Niger 
&lt;br&gt;
Nigeria 
&lt;br&gt;
Niue 
&lt;br&gt;
Norfolk Island 
&lt;br&gt;
Northern Cyprus&lt;br&gt;
Northern Mariana Islands&lt;br&gt;
Norway 
&lt;br&gt;
Oman 
&lt;br&gt;
Pakistan 
&lt;br&gt;
Palau 
&lt;br&gt;
Palestinian 
&lt;br&gt;
Panama 
&lt;br&gt;
Papua New Guinea 
&lt;br&gt;
Paraguay 
&lt;br&gt;
Peru 
&lt;br&gt;
Philippines 
&lt;br&gt;
Pitcairn Islands 
&lt;br&gt;
Poland 
&lt;br&gt;
Portugal 
&lt;br&gt;
Pridnestrovian Moldavian Republic&lt;br&gt;
Puerto Rico&lt;br&gt;
Qatar&lt;br&gt;
Romania 
&lt;br&gt;
Russia 
&lt;br&gt;
Rwanda 
&lt;br&gt;
Saint Helena 
&lt;br&gt;
Saint Kitts and Nevis 
&lt;br&gt;
Saint Lucia 
&lt;br&gt;
Saint Pierre and Miquelon 
&lt;br&gt;
Saint Vincent and the Grenadines&lt;br&gt;
Samoa 
&lt;br&gt;
San Marino 
&lt;br&gt;
São Tomé and Príncipe 
&lt;br&gt;
Saudi Arabia 
&lt;br&gt;
Senegal 
&lt;br&gt;
Serbia 
&lt;br&gt;
Seychelles 
&lt;br&gt;
Sierra Leone 
&lt;br&gt;
Singapore 
&lt;br&gt;
Slovakia 
&lt;br&gt;
Slovenia 
&lt;br&gt;
Solomon Islands 
&lt;br&gt;
Somalia 
&lt;br&gt;
Somaliland&lt;br&gt;
South Africa 
&lt;br&gt;
South Ossetia 
&lt;br&gt;
Spain 
&lt;br&gt;
Sri Lanka 
&lt;br&gt;
Sudan 
&lt;br&gt;
Suriname 
&lt;br&gt;
Svalbard 
&lt;br&gt;
Swaziland 
&lt;br&gt;
Sweden 
&lt;br&gt;
Switzerland 
&lt;br&gt;
Syria 
&lt;br&gt;
Tajikistan 
&lt;br&gt;
Tanzania 
&lt;br&gt;
Thailand 
&lt;br&gt;
East Timor&lt;br&gt;
Togo 
&lt;br&gt;
Tokelau 
&lt;br&gt;
Tonga 
&lt;br&gt;
Trinidad and Tobago&lt;br&gt;
Tristan da Cunha 
&lt;br&gt;
Tunisia 
&lt;br&gt;
Turkey 
&lt;br&gt;
Turkmenistan 
&lt;br&gt;
Turks and Caicos Islands&lt;br&gt;
Tuvalu 
&lt;br&gt;
Uganda 
&lt;br&gt;
Ukraine&lt;br&gt;
United Arab Emirates 
&lt;br&gt;
United Kingdom 
&lt;br&gt;
United States 
&lt;br&gt;
Uruguay 
&lt;br&gt;
Uzbekistan 
&lt;br&gt;
Vanuatu 
&lt;br&gt;
Vatican City 
&lt;br&gt;
Venezuela 
&lt;br&gt;
Vietnam 
&lt;br&gt;
Virgin Islands (British)&lt;br&gt;
Virgin Islands (United States)&lt;br&gt;
Wallis and Futuna&lt;br&gt;
Western Sahara 
&lt;br&gt;
Yemen 
&lt;br&gt;
Zambia 
&lt;br&gt;
Zimbabwe&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=2ce605fe-2f10-4308-9798-81b00faf108d" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,2ce605fe-2f10-4308-9798-81b00faf108d.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=56c0211a-9d04-494d-b5ed-3e963011e14f</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,56c0211a-9d04-494d-b5ed-3e963011e14f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,56c0211a-9d04-494d-b5ed-3e963011e14f.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=56c0211a-9d04-494d-b5ed-3e963011e14f</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">I have a few reports in my web application
that i export in PDF format only.  You would think this would remove any printer
driver complications but apparently not. 
<br />
Crystal Reports have a <a href="http://support.businessobjects.com/communityCS/TechnicalPapers/cr_printer_driver_options.pdf?ref=devzone_reporting_main">surprisingly
good article</a> to help troubleshoot issues with printing or exporting a report. 
<br /><br />
The problem i was finding was that in a Text object or Unbound field, the text would
be truncated at the edge of the box boundary.  Some users have reported strange
mid-word wrapping, but mine was a different problem, actually hacking off the end
of each line.  This didn't happen on my dev machine, but it did happen on the
server (2003).  When i compared them side by side, the Times New Roman font on
the server was stretched by about 5% compared to my dev machine. 
<br />
with the help of the CR article, i tracked it down to the lack of any printer installed
on the server, i had also disabled the Print Spooler service which was preventing
even the Microsoft Office Document Imaging Printer from being available.  So
i started the print spooler service and made sure that the Office Imaging Printer
was marked as the default printer.  Then i went back to Visual Studio and set
all the reports to use the Office Imaging printer.  This solved the problem.  
<br /><br />
You could of course install a PDF only printer such as PrimoPDF if you didn't have
MS office installed on the server. As long as the server has the same printer installed
as the one set in the report design, everything turns out fine.<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=56c0211a-9d04-494d-b5ed-3e963011e14f" /></body>
      <title>Crystal Reports: Export PDF irregularities between server and dev machine</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,56c0211a-9d04-494d-b5ed-3e963011e14f.aspx</guid>
      <link>http://tim.mackey.ie/CrystalReportsExportPDFIrregularitiesBetweenServerAndDevMachine.aspx</link>
      <pubDate>Fri, 11 Aug 2006 12:20:57 GMT</pubDate>
      <description>I have a few reports in my web application that i export in PDF format only.&amp;nbsp; You would think this would remove any printer driver complications but apparently not. &lt;br&gt;
Crystal Reports have a &lt;a href="http://support.businessobjects.com/communityCS/TechnicalPapers/cr_printer_driver_options.pdf?ref=devzone_reporting_main"&gt;surprisingly
good article&lt;/a&gt; to help troubleshoot issues with printing or exporting a report. 
&lt;br&gt;
&lt;br&gt;
The problem i was finding was that in a Text object or Unbound field, the text would
be truncated at the edge of the box boundary.&amp;nbsp; Some users have reported strange
mid-word wrapping, but mine was a different problem, actually hacking off the end
of each line.&amp;nbsp; This didn't happen on my dev machine, but it did happen on the
server (2003).&amp;nbsp; When i compared them side by side, the Times New Roman font on
the server was stretched by about 5% compared to my dev machine. 
&lt;br&gt;
with the help of the CR article, i tracked it down to the lack of any printer installed
on the server, i had also disabled the Print Spooler service which was preventing
even the Microsoft Office Document Imaging Printer from being available.&amp;nbsp; So
i started the print spooler service and made sure that the Office Imaging Printer
was marked as the default printer.&amp;nbsp; Then i went back to Visual Studio and set
all the reports to use the Office Imaging printer.&amp;nbsp; This solved the problem.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
You could of course install a PDF only printer such as PrimoPDF if you didn't have
MS office installed on the server. As long as the server has the same printer installed
as the one set in the report design, everything turns out fine.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=56c0211a-9d04-494d-b5ed-3e963011e14f" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,56c0211a-9d04-494d-b5ed-3e963011e14f.aspx</comments>
      <category>.Net General</category>
      <category>.Net Windows Forms</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=922f2ec5-bf8a-4517-95a3-1cc8fbd8f2eb</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,922f2ec5-bf8a-4517-95a3-1cc8fbd8f2eb.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,922f2ec5-bf8a-4517-95a3-1cc8fbd8f2eb.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=922f2ec5-bf8a-4517-95a3-1cc8fbd8f2eb</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">I was getting blank fields in my crystal
report if one of the values in the formula was null. 
<br />
Thanks to <a href="http://groups.google.com/group/microsoft.public.vb.crystal/browse_frm/thread/a3dbce66126297ac/e872132608e048a0?lnk=st&amp;q=&amp;rnum=8#e872132608e048a0">this
post</a> i know better than to trust Crystal's crummy concatenation rules.  Here
is what <span class="msghv"><b><font class="inheritcolor" color="#790619"> Gundula
Wangerin</font></b></span> had to say:<br /><blockquote>A string concatenated with null always gives null. 
<br />
You have to check if the first name is null with 
<br /><pre>     if not IsNull(firstname) then 
<br />
        lastname + " " + firstname 
<br />
    else 
<br />
        lastname </pre></blockquote><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=922f2ec5-bf8a-4517-95a3-1cc8fbd8f2eb" /></body>
      <title>Crystal Reports: join / concatenate null strings</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,922f2ec5-bf8a-4517-95a3-1cc8fbd8f2eb.aspx</guid>
      <link>http://tim.mackey.ie/CrystalReportsJoinConcatenateNullStrings.aspx</link>
      <pubDate>Thu, 10 Aug 2006 16:31:20 GMT</pubDate>
      <description>I was getting blank fields in my crystal report if one of the values in the formula was null. &lt;br&gt;
Thanks to &lt;a href="http://groups.google.com/group/microsoft.public.vb.crystal/browse_frm/thread/a3dbce66126297ac/e872132608e048a0?lnk=st&amp;amp;q=&amp;amp;rnum=8#e872132608e048a0"&gt;this
post&lt;/a&gt; i know better than to trust Crystal's crummy concatenation rules.&amp;nbsp; Here
is what &lt;span class="msghv"&gt;&lt;b&gt;&lt;font class="inheritcolor" color="#790619"&gt; Gundula
Wangerin&lt;/font&gt;&lt;/b&gt;&lt;/span&gt; had to say:&lt;br&gt;
&lt;blockquote&gt;A string concatenated with null always gives null. 
&lt;br&gt;
You have to check if the first name is null with 
&lt;br&gt;
&lt;pre&gt; &amp;nbsp; &amp;nbsp; if not IsNull(firstname) then 
&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lastname + " " + firstname 
&lt;br&gt;
&amp;nbsp; &amp;nbsp; else 
&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lastname &lt;/pre&gt;&lt;/blockquote&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=922f2ec5-bf8a-4517-95a3-1cc8fbd8f2eb" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,922f2ec5-bf8a-4517-95a3-1cc8fbd8f2eb.aspx</comments>
      <category>.Net General</category>
      <category>.Net Windows Forms</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=69ff0d0c-1179-447a-8270-2d3968bb2839</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,69ff0d0c-1179-447a-8270-2d3968bb2839.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,69ff0d0c-1179-447a-8270-2d3968bb2839.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=69ff0d0c-1179-447a-8270-2d3968bb2839</wfw:commentRss>
      <slash:comments>9</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">I picked up a tip on the Internet to display
a "No records" message if the report contains no records, rather than leaving the
user with an empty screen.  Simply Format the text field and enter a formula
next to 'Suppress' with something like 
<br /><pre>Count({Table.Field}) &gt; 0</pre>This will suppress (hide) the message if there
are records in the report.<br /><br /><p></p>
I tried using a similar approach to hide a text field when there are no records, so
it is essentially the same thing in reverse.  You would think a simple formula
on the 'suppress' property this would achieve the desired effect:<br /><pre>Count({Table.Field}) = 0<br /></pre><p>
But apparently the value returned by Count can be null if there are no records. 
so you have to use: 
<br /></p><pre>IsNull(Count({Table.Field})) OR Count({Table.Field}) = 0</pre><p>
This is just another crystal reports annoyance, of which there are many.<br /></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=69ff0d0c-1179-447a-8270-2d3968bb2839" /></body>
      <title>Crystal Reports: Suppress doesn't work for Count(x) = 0</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,69ff0d0c-1179-447a-8270-2d3968bb2839.aspx</guid>
      <link>http://tim.mackey.ie/CrystalReportsSuppressDoesntWorkForCountx0.aspx</link>
      <pubDate>Fri, 04 Aug 2006 10:26:38 GMT</pubDate>
      <description>I picked up a tip on the Internet to display a "No records" message if the report contains no records, rather than leaving the user with an empty screen.&amp;nbsp; Simply Format the text field and enter a formula next to 'Suppress' with something like &lt;br&gt;
&lt;pre&gt;Count({Table.Field}) &amp;gt; 0&lt;/pre&gt;This will suppress (hide) the message if there
are records in the report.&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
I tried using a similar approach to hide a text field when there are no records, so
it is essentially the same thing in reverse.&amp;nbsp; You would think a simple formula
on the 'suppress' property this would achieve the desired effect:&lt;br&gt;
&lt;pre&gt;Count({Table.Field}) = 0&lt;br&gt;
&lt;/pre&gt;
&lt;p&gt;
But apparently the value returned by Count can be null if there are no records.&amp;nbsp;
so you have to use: 
&lt;br&gt;
&lt;/p&gt;
&lt;pre&gt;IsNull(Count({Table.Field})) OR Count({Table.Field}) = 0&lt;/pre&gt;
&lt;p&gt;
This is just another crystal reports annoyance, of which there are many.&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=69ff0d0c-1179-447a-8270-2d3968bb2839" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,69ff0d0c-1179-447a-8270-2d3968bb2839.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
      <category>Windows Server 2003</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=e2022f27-3251-4169-a2e1-571f61b97cd2</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,e2022f27-3251-4169-a2e1-571f61b97cd2.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,e2022f27-3251-4169-a2e1-571f61b97cd2.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=e2022f27-3251-4169-a2e1-571f61b97cd2</wfw:commentRss>
      <slash:comments>12</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">i'm part of the dd/MM/yyyy world, and that
often means running into problems when using software developed with MM/dd/yyyy defaults,
such as crystal reports.  
<br />
i have all the report options set to use the system defaults, which are regionally
set to ireland in windows, but that isn't enough, the dates still come out in MM/dd/yyyy
format.  i have the date + date/time fields customised within crystal reports
to dd/MM/yyyy but that isn't enough either.  with lots of hours googling and
no answers that worked, i resorted to searching the registry and found that some of
the user accounts were still using US regional settings.  If you look in HKEY_USERS
&gt; you see a list of all the account IDs on the computer.  My guess is that
crystal reports must use the SYSTEM account or another non-interactive account, and
it takes the regional settings from there.  So if you search for sShortDate in
the registry, you will find all the appropriate settings and can replace the MM/dd/yyyy
values with your preferred format. 
<br />
i had to reboot to get it to take effect.  
<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=e2022f27-3251-4169-a2e1-571f61b97cd2" /></body>
      <title>Crystal Reports: not picking up correct date format</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,e2022f27-3251-4169-a2e1-571f61b97cd2.aspx</guid>
      <link>http://tim.mackey.ie/CrystalReportsNotPickingUpCorrectDateFormat.aspx</link>
      <pubDate>Wed, 02 Aug 2006 19:45:07 GMT</pubDate>
      <description>i'm part of the dd/MM/yyyy world, and that often means running into problems when using software developed with MM/dd/yyyy defaults, such as crystal reports.&amp;nbsp; &lt;br&gt;
i have all the report options set to use the system defaults, which are regionally
set to ireland in windows, but that isn't enough, the dates still come out in MM/dd/yyyy
format.&amp;nbsp; i have the date + date/time fields customised within crystal reports
to dd/MM/yyyy but that isn't enough either.&amp;nbsp; with lots of hours googling and
no answers that worked, i resorted to searching the registry and found that some of
the user accounts were still using US regional settings.&amp;nbsp; If you look in HKEY_USERS
&amp;gt; you see a list of all the account IDs on the computer.&amp;nbsp; My guess is that
crystal reports must use the SYSTEM account or another non-interactive account, and
it takes the regional settings from there.&amp;nbsp; So if you search for sShortDate in
the registry, you will find all the appropriate settings and can replace the MM/dd/yyyy
values with your preferred format. 
&lt;br&gt;
i had to reboot to get it to take effect.&amp;nbsp; 
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=e2022f27-3251-4169-a2e1-571f61b97cd2" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,e2022f27-3251-4169-a2e1-571f61b97cd2.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
      <category>Windows Server 2003</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=501a1c0a-bee8-48b0-8926-ee165bd0644b</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,501a1c0a-bee8-48b0-8926-ee165bd0644b.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,501a1c0a-bee8-48b0-8926-ee165bd0644b.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=501a1c0a-bee8-48b0-8926-ee165bd0644b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">I wanted to install my web application
assembly into the GAC, but this is made more complicated by the multitude of assemblies
produced by VS when i publish the web site.  On the newsgroups, i found some
talk of a tool called Merge_Aspnet.exe but i couldn't find it anywhere.  Eventually
i found it as a download on MSDN, it is bundled as part of the <a href="http://msdn.microsoft.com/asp.net/reference/infrastructure/wdp/default.aspx">Web
Deployment Projects</a>.  You install it, and then right-click your project in
VS and you should see a new menu item "Add Web Deployment Project".  I am baffled
as to why they didn't just add a new project type in the list of projects under "Deployment". 
There is a link to "Search online templates" so i think it should really be available
there.  but it looks like MS did a hack just to add in a new item to the project
context menu.  but it works... so i'll stop complaining.  
<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=501a1c0a-bee8-48b0-8926-ee165bd0644b" /></body>
      <title>Compiling Asp.Net 2.0 to a single assembly</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,501a1c0a-bee8-48b0-8926-ee165bd0644b.aspx</guid>
      <link>http://tim.mackey.ie/CompilingAspNet20ToASingleAssembly.aspx</link>
      <pubDate>Fri, 03 Mar 2006 15:43:20 GMT</pubDate>
      <description>I wanted to install my web application assembly into the GAC, but this is made more complicated by the multitude of assemblies produced by VS when i publish the web site.&amp;nbsp; On the newsgroups, i found some talk of a tool called Merge_Aspnet.exe but i couldn't find it anywhere.&amp;nbsp; Eventually i found it as a download on MSDN, it is bundled as part of the &lt;a href="http://msdn.microsoft.com/asp.net/reference/infrastructure/wdp/default.aspx"&gt;Web
Deployment Projects&lt;/a&gt;.&amp;nbsp; You install it, and then right-click your project in
VS and you should see a new menu item "Add Web Deployment Project".&amp;nbsp; I am baffled
as to why they didn't just add a new project type in the list of projects under "Deployment".&amp;nbsp;
There is a link to "Search online templates" so i think it should really be available
there.&amp;nbsp; but it looks like MS did a hack just to add in a new item to the project
context menu.&amp;nbsp; but it works... so i'll stop complaining.&amp;nbsp; 
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=501a1c0a-bee8-48b0-8926-ee165bd0644b" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,501a1c0a-bee8-48b0-8926-ee165bd0644b.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=c0ac2cfa-3af5-4012-a72b-fd2b411471a4</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,c0ac2cfa-3af5-4012-a72b-fd2b411471a4.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,c0ac2cfa-3af5-4012-a72b-fd2b411471a4.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=c0ac2cfa-3af5-4012-a72b-fd2b411471a4</wfw:commentRss>
      <slash:comments>29</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <img alt="Screenshot of upload operation" src="content/binary/FTP_upload.jpg" align="right" border="0" hspace="10" vspace="10" />hi, 
<br />
i was delighted to see .Net 2.0 has an excellent class for working with FTP. 
looking back i can't believe it wasn't part of 1.1.  
<br /><br />
i noticed there was no built-in support for reporting the progress of an FTP operation
to a user interface.  I needed this functionality in an app i'm working on so
i built a class and i'm posting it here in case anyone is interested. 
<br /><br />
The class FtpProgress inherits from BackgroundWorker, so you just drag an FtpProgress
component onto your form, hook up events for Completed and ProgressChanged, and your
laughing.  There is a mini class called FtpSettings which stores all the connect
info etc to pass in as a paramter to the RunWorkerAsync() method. 
<br /><br />
I have a variable called 'ChunkSize' which determines the size of each buffer written
to the FtpWebRequest output stream.  It is set to 4k by default, and you can
increase this if you want for very fast networks but i don't think it will make much
difference.  I think the overhead is negligible.<br /><br />
Download the <a href="content/binary/FTP_ProgressBar.zip">source code and demo application</a> [30
k].<br /><br />
It only does upload, so if you want download functionality, you can do the mirror-image
of the upload code, i.e. instead of writing buffers to the output stream, read it
from the input stream, or however that would work :)  
<br /><br />
here is all the code you need to start an Upload, and report progress:<br /><pre>private void btnUpload_Click(object sender, EventArgs e)<br />
{<br />
// create a new FtpSettings class to store all the paramaters for the FtpProgress
thread<br />
FtpSettings f = new FtpSettings();<br />
f.Host = this.txtHost.Text;<br />
f.Username = this.txtUsername.Text;<br />
f.Password = this.txtPassword.Text;<br />
f.TargetFolder = this.txtDir.Text;<br />
f.SourceFile = this.txtUploadFile.Text;<br />
f.Passive = this.chkPassive.Checked;<br />
f.Port = Int32.Parse(this.txtPort.Text); 
<br />
this.ftpProgress1.RunWorkerAsync(f);<br />
}<br /><br />
private void ftpProgress1_ProgressChanged(object sender, ProgressChangedEventArgs
e)<br />
{<br />
this.toolStripStatusLabel1.Text = e.UserState.ToString(); // the message will be something
like: 45 Kb / 102.12 Mb<br />
this.toolStripProgressBar1.Value = Math.Min(this.toolStripProgressBar1.Maximum, e.ProgressPercentage); 
<br />
}<br /></pre><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=c0ac2cfa-3af5-4012-a72b-fd2b411471a4" /></body>
      <title>FtpWebRequest with ProgressBar [C# Ftp]</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,c0ac2cfa-3af5-4012-a72b-fd2b411471a4.aspx</guid>
      <link>http://tim.mackey.ie/FtpWebRequestWithProgressBarCFtp.aspx</link>
      <pubDate>Fri, 17 Feb 2006 18:09:05 GMT</pubDate>
      <description>&lt;img alt="Screenshot of upload operation" src="content/binary/FTP_upload.jpg" align="right" border="0" hspace="10" vspace="10"&gt;hi, 
&lt;br&gt;
i was delighted to see .Net 2.0 has an excellent class for working with FTP.&amp;nbsp;
looking back i can't believe it wasn't part of 1.1.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
i noticed there was no built-in support for reporting the progress of an FTP operation
to a user interface.&amp;nbsp; I needed this functionality in an app i'm working on so
i built a class and i'm posting it here in case anyone is interested. 
&lt;br&gt;
&lt;br&gt;
The class FtpProgress inherits from BackgroundWorker, so you just drag an FtpProgress
component onto your form, hook up events for Completed and ProgressChanged, and your
laughing.&amp;nbsp; There is a mini class called FtpSettings which stores all the connect
info etc to pass in as a paramter to the RunWorkerAsync() method. 
&lt;br&gt;
&lt;br&gt;
I have a variable called 'ChunkSize' which determines the size of each buffer written
to the FtpWebRequest output stream.&amp;nbsp; It is set to 4k by default, and you can
increase this if you want for very fast networks but i don't think it will make much
difference.&amp;nbsp; I think the overhead is negligible.&lt;br&gt;
&lt;br&gt;
Download the &lt;a href="content/binary/FTP_ProgressBar.zip"&gt;source code and demo application&lt;/a&gt; [30
k].&lt;br&gt;
&lt;br&gt;
It only does upload, so if you want download functionality, you can do the mirror-image
of the upload code, i.e. instead of writing buffers to the output stream, read it
from the input stream, or however that would work :)&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
here is all the code you need to start an Upload, and report progress:&lt;br&gt;
&lt;pre&gt;private void btnUpload_Click(object sender, EventArgs e)&lt;br&gt;
{&lt;br&gt;
// create a new FtpSettings class to store all the paramaters for the FtpProgress
thread&lt;br&gt;
FtpSettings f = new FtpSettings();&lt;br&gt;
f.Host = this.txtHost.Text;&lt;br&gt;
f.Username = this.txtUsername.Text;&lt;br&gt;
f.Password = this.txtPassword.Text;&lt;br&gt;
f.TargetFolder = this.txtDir.Text;&lt;br&gt;
f.SourceFile = this.txtUploadFile.Text;&lt;br&gt;
f.Passive = this.chkPassive.Checked;&lt;br&gt;
f.Port = Int32.Parse(this.txtPort.Text); 
&lt;br&gt;
this.ftpProgress1.RunWorkerAsync(f);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
private void ftpProgress1_ProgressChanged(object sender, ProgressChangedEventArgs
e)&lt;br&gt;
{&lt;br&gt;
this.toolStripStatusLabel1.Text = e.UserState.ToString(); // the message will be something
like: 45 Kb / 102.12 Mb&lt;br&gt;
this.toolStripProgressBar1.Value = Math.Min(this.toolStripProgressBar1.Maximum, e.ProgressPercentage); 
&lt;br&gt;
}&lt;br&gt;
&lt;/pre&gt;&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=c0ac2cfa-3af5-4012-a72b-fd2b411471a4" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,c0ac2cfa-3af5-4012-a72b-fd2b411471a4.aspx</comments>
      <category>.Net General</category>
      <category>.Net Windows Forms</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=ef06b347-51a0-4824-b2d7-a831c8620588</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,ef06b347-51a0-4824-b2d7-a831c8620588.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,ef06b347-51a0-4824-b2d7-a831c8620588.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=ef06b347-51a0-4824-b2d7-a831c8620588</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">For some reason i can't get SelectNodes
to work with the IIS 6 MetaBase.xml file.  It just doesn't return any matches. 
I think the structure may be non-standard or too complex, or else i'm not using it
right.  but in any case, I worked around the problem by opening the file with
File.OpenText and using Regex to parse out the nodes i'm interested in, namely the
IISWebServer nodes.<br /><br /><pre>string MetaBase = "";<br />
using(StreamReader sr = File.OpenText(ConfigurationManager.AppSettings["MetaBasePath"].ToString()))<br />
MetaBase = sr.ReadToEnd();<br /><br />
foreach(Match m in new Regex(@"(?x:)&lt;IIsWebServer[^&gt;]*&gt;.*?&lt;/IIsWebServer&gt;",
RegexOptions.IgnoreCase).Matches(MetaBase))<br />
{<br />
XmlDocument doc = new XmlDocument();<br />
string IisCode = "", ServerBindings = "", ServerComment = "";<br />
doc.LoadXml(m.Groups[0].Value);<br />
XmlElement node = doc.DocumentElement;<br />
// now you can access the node attributes<br />
...<br /></pre><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=ef06b347-51a0-4824-b2d7-a831c8620588" /></body>
      <title>Using Xml DOM with MetaBase.xml</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,ef06b347-51a0-4824-b2d7-a831c8620588.aspx</guid>
      <link>http://tim.mackey.ie/UsingXmlDOMWithMetaBasexml.aspx</link>
      <pubDate>Thu, 02 Feb 2006 13:38:34 GMT</pubDate>
      <description>For some reason i can't get SelectNodes to work with the IIS 6 MetaBase.xml file.&amp;nbsp; It just doesn't return any matches.&amp;nbsp; I think the structure may be non-standard or too complex, or else i'm not using it right.&amp;nbsp; but in any case, I worked around the problem by opening the file with File.OpenText and using Regex to parse out the nodes i'm interested in, namely the IISWebServer nodes.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;string MetaBase = "";&lt;br&gt;
using(StreamReader sr = File.OpenText(ConfigurationManager.AppSettings["MetaBasePath"].ToString()))&lt;br&gt;
MetaBase = sr.ReadToEnd();&lt;br&gt;
&lt;br&gt;
foreach(Match m in new Regex(@"(?x:)&amp;lt;IIsWebServer[^&amp;gt;]*&amp;gt;.*?&amp;lt;/IIsWebServer&amp;gt;",
RegexOptions.IgnoreCase).Matches(MetaBase))&lt;br&gt;
{&lt;br&gt;
XmlDocument doc = new XmlDocument();&lt;br&gt;
string IisCode = "", ServerBindings = "", ServerComment = "";&lt;br&gt;
doc.LoadXml(m.Groups[0].Value);&lt;br&gt;
XmlElement node = doc.DocumentElement;&lt;br&gt;
// now you can access the node attributes&lt;br&gt;
...&lt;br&gt;
&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=ef06b347-51a0-4824-b2d7-a831c8620588" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,ef06b347-51a0-4824-b2d7-a831c8620588.aspx</comments>
      <category>.Net General</category>
      <category>.Net Windows Forms</category>
      <category>Asp.Net</category>
      <category>Windows Server 2003</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=07553b32-4444-49a2-a4b2-3b84b1283e21</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,07553b32-4444-49a2-a4b2-3b84b1283e21.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,07553b32-4444-49a2-a4b2-3b84b1283e21.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=07553b32-4444-49a2-a4b2-3b84b1283e21</wfw:commentRss>
      <slash:comments>13</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">i kept getting these sporadic error messages
on my web applications and i could never figure out why.  
<br /><pre>Unable to validate data at<br />
System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier, Int32
start, Int32 length, Int32&amp; dataLength) at 
<br />
System.Web.UI.LosFormatter.Deserialize(String input)</pre>searching the net just reveals
a troop of similarly frustrated users without solutions.  but today i found the
actual reason why, and the work-around. 
<br />
this excellent <a href="http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21321364.html">post
on experts-exchange</a> has the answer.  apparently it happens when users leave
a page open for a long time, and then cause a post back.  something to do with
the machine key being automatically generated and it changes before the user causes
the postback, and it can't validate it then.  
<br />
the fix is to set a static machine key.  
<br />
There is a <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312906">kb
article</a> with some code to generate a key for you, + instructions.   
<br /><br />
Sorted.<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=07553b32-4444-49a2-a4b2-3b84b1283e21" /></body>
      <title>Fix: Unable to validate data, MachineKey.GetDecodedData</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,07553b32-4444-49a2-a4b2-3b84b1283e21.aspx</guid>
      <link>http://tim.mackey.ie/FixUnableToValidateDataMachineKeyGetDecodedData.aspx</link>
      <pubDate>Mon, 30 Jan 2006 22:53:44 GMT</pubDate>
      <description>i kept getting these sporadic error messages on my web applications and i could never figure out why.&amp;nbsp; &lt;br&gt;
&lt;pre&gt;Unable to validate data at&lt;br&gt;
System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier, Int32
start, Int32 length, Int32&amp;amp; dataLength) at 
&lt;br&gt;
System.Web.UI.LosFormatter.Deserialize(String input)&lt;/pre&gt;searching the net just reveals
a troop of similarly frustrated users without solutions.&amp;nbsp; but today i found the
actual reason why, and the work-around. 
&lt;br&gt;
this excellent &lt;a href="http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21321364.html"&gt;post
on experts-exchange&lt;/a&gt; has the answer.&amp;nbsp; apparently it happens when users leave
a page open for a long time, and then cause a post back.&amp;nbsp; something to do with
the machine key being automatically generated and it changes before the user causes
the postback, and it can't validate it then.&amp;nbsp; 
&lt;br&gt;
the fix is to set a static machine key.&amp;nbsp; 
&lt;br&gt;
There is a &lt;a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312906"&gt;kb
article&lt;/a&gt; with some code to generate a key for you, + instructions.&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
Sorted.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=07553b32-4444-49a2-a4b2-3b84b1283e21" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,07553b32-4444-49a2-a4b2-3b84b1283e21.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=b95d1f18-e472-410b-b128-c8cb0e5516ba</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,b95d1f18-e472-410b-b128-c8cb0e5516ba.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,b95d1f18-e472-410b-b128-c8cb0e5516ba.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=b95d1f18-e472-410b-b128-c8cb0e5516ba</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">a web site i'm working on imports excel
documents, and does some processing on them for importing into a database.  I
use the code from <a href="http://tim.mackey.ie/AFewUsefulFunctionsForImportingAndExportingDataInAspnetExcelPDFDatasetsDataGridsEtc.aspx">this
post</a> to do the importing, and it works nicely.  I recently came across a
problem where i was encountering duplicate records, and it took me ages to figure
out why.  Apparently a 'named range' of cells in a worksheet is treated as a
Table by ADOX.  so you get more than you bargain for when you iterate through
the tables in the resulting DataSet.  
<br />
I was able to work around the problem by discarding any tables that do NOT end in
the dollar $ character. 
<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=b95d1f18-e472-410b-b128-c8cb0e5516ba" /></body>
      <title>ADOX + Excel: bogus worksheets</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,b95d1f18-e472-410b-b128-c8cb0e5516ba.aspx</guid>
      <link>http://tim.mackey.ie/ADOXExcelBogusWorksheets.aspx</link>
      <pubDate>Mon, 30 Jan 2006 15:30:12 GMT</pubDate>
      <description>a web site i'm working on imports excel documents, and does some processing on them for importing into a database.&amp;nbsp; I use the code from &lt;a href="http://tim.mackey.ie/AFewUsefulFunctionsForImportingAndExportingDataInAspnetExcelPDFDatasetsDataGridsEtc.aspx"&gt;this
post&lt;/a&gt; to do the importing, and it works nicely.&amp;nbsp; I recently came across a
problem where i was encountering duplicate records, and it took me ages to figure
out why.&amp;nbsp; Apparently a 'named range' of cells in a worksheet is treated as a
Table by ADOX.&amp;nbsp; so you get more than you bargain for when you iterate through
the tables in the resulting DataSet.&amp;nbsp; 
&lt;br&gt;
I was able to work around the problem by discarding any tables that do NOT end in
the dollar $ character. 
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=b95d1f18-e472-410b-b128-c8cb0e5516ba" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,b95d1f18-e472-410b-b128-c8cb0e5516ba.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=8a4b7e76-e10d-4063-bbab-ca339701f6a9</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,8a4b7e76-e10d-4063-bbab-ca339701f6a9.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,8a4b7e76-e10d-4063-bbab-ca339701f6a9.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=8a4b7e76-e10d-4063-bbab-ca339701f6a9</wfw:commentRss>
      <slash:comments>16</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">I have a text object in my crystal report,
and i set the value programatically for it, using something like this:<br /><pre>(rpt.Section3.ReportObjects["txtDate"] as TextObject).Text = DateTime.Now.ToShortDateString();</pre>this
works fine, until you put a string with line breaks inside it, specifically \r\n or
the carriage return character.  This is a bug in CR for .Net, you can <a href="http://support.businessobjects.com/library/kbase/articles/c2015089.asp">read
the official blurb here</a>.  the work-around code they post is in VB, and it
made no sense to me when i read it. 
<br />
what they actually do is make you change the TextObject into a FormulaField (you have
to view the 'Field Explorer' tab next to the toolbox, and drag on a Formula Field). 
Then you set 'CanGrow' to true, and then you go back to your code, and do the most
arcane work-around i've ever seen.  you set the formula to your text string,
but you must surround it in single quote characters, and replace \r\n with some inline
managed code as follows: ' + chr(10) + '<br />
when i first read this, i thought they had made a syntax error, but this is the way
to do it, and it works.  the new format for setting the formula field is:<br /><pre>rpt.DataDefinition.FormulaFields[0].Text = "'" + YourString.Replace("\r\n", "' + chr(10) + '") + "'";</pre><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=8a4b7e76-e10d-4063-bbab-ca339701f6a9" /></body>
      <title>Crystal Reports TextObject ignores newline, carriage return, \r\n</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,8a4b7e76-e10d-4063-bbab-ca339701f6a9.aspx</guid>
      <link>http://tim.mackey.ie/CrystalReportsTextObjectIgnoresNewlineCarriageReturnRn.aspx</link>
      <pubDate>Wed, 25 Jan 2006 13:52:05 GMT</pubDate>
      <description>I have a text object in my crystal report, and i set the value programatically for it, using something like this:&lt;br&gt;
&lt;pre&gt;(rpt.Section3.ReportObjects["txtDate"] as TextObject).Text = DateTime.Now.ToShortDateString();&lt;/pre&gt;this
works fine, until you put a string with line breaks inside it, specifically \r\n or
the carriage return character.&amp;nbsp; This is a bug in CR for .Net, you can &lt;a href="http://support.businessobjects.com/library/kbase/articles/c2015089.asp"&gt;read
the official blurb here&lt;/a&gt;.&amp;nbsp; the work-around code they post is in VB, and it
made no sense to me when i read it. 
&lt;br&gt;
what they actually do is make you change the TextObject into a FormulaField (you have
to view the 'Field Explorer' tab next to the toolbox, and drag on a Formula Field).&amp;nbsp;
Then you set 'CanGrow' to true, and then you go back to your code, and do the most
arcane work-around i've ever seen.&amp;nbsp; you set the formula to your text string,
but you must surround it in single quote characters, and replace \r\n with some inline
managed code as follows: ' + chr(10) + '&lt;br&gt;
when i first read this, i thought they had made a syntax error, but this is the way
to do it, and it works.&amp;nbsp; the new format for setting the formula field is:&lt;br&gt;
&lt;pre&gt;rpt.DataDefinition.FormulaFields[0].Text = "'" + YourString.Replace("\r\n", "' + chr(10) + '") + "'";&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=8a4b7e76-e10d-4063-bbab-ca339701f6a9" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,8a4b7e76-e10d-4063-bbab-ca339701f6a9.aspx</comments>
      <category>.Net General</category>
      <category>.Net Windows Forms</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=4796b7f6-d1c8-4f4d-a472-03a482b0de15</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,4796b7f6-d1c8-4f4d-a472-03a482b0de15.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,4796b7f6-d1c8-4f4d-a472-03a482b0de15.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=4796b7f6-d1c8-4f4d-a472-03a482b0de15</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">I ran into a frustrating problem today
where some properties of my objects weren't getting serialized.  I noticed it
was the ones without 'set' accessors.  I didn't want to put set accessors in
because the properties should be read-only, but apparently the xml serializer needs
the set accessor to de-serialize.  
<br />
there is a good discussion on it on <a href="http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/36456d10b2bf53df/">this
thread.</a><br />
Luckily we can use the ReadOnlyAttribute setting on the property to prevent it being
modified by a programmer at design time.<br />
or you can use the Soap serializer instead of xml, whatever that is.<br /><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=4796b7f6-d1c8-4f4d-a472-03a482b0de15" /></body>
      <title>Xml Serialization: Properties left out without 'set' accessor</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,4796b7f6-d1c8-4f4d-a472-03a482b0de15.aspx</guid>
      <link>http://tim.mackey.ie/XmlSerializationPropertiesLeftOutWithoutSetAccessor.aspx</link>
      <pubDate>Mon, 09 Jan 2006 17:57:34 GMT</pubDate>
      <description>I ran into a frustrating problem today where some properties of my objects weren't getting serialized.&amp;nbsp; I noticed it was the ones without 'set' accessors.&amp;nbsp; I didn't want to put set accessors in because the properties should be read-only, but apparently the xml serializer needs the set accessor to de-serialize.&amp;nbsp; &lt;br&gt;
there is a good discussion on it on &lt;a href="http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/36456d10b2bf53df/"&gt;this
thread.&lt;/a&gt;
&lt;br&gt;
Luckily we can use the ReadOnlyAttribute setting on the property to prevent it being
modified by a programmer at design time.&lt;br&gt;
or you can use the Soap serializer instead of xml, whatever that is.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=4796b7f6-d1c8-4f4d-a472-03a482b0de15" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,4796b7f6-d1c8-4f4d-a472-03a482b0de15.aspx</comments>
      <category>.Net General</category>
      <category>.Net Windows Forms</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=9603c0e9-a99e-4d6e-bfef-d4abb7ae9501</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,9603c0e9-a99e-4d6e-bfef-d4abb7ae9501.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,9603c0e9-a99e-4d6e-bfef-d4abb7ae9501.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=9603c0e9-a99e-4d6e-bfef-d4abb7ae9501</wfw:commentRss>
      <slash:comments>24</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">just posting my code-project <a href="http://www.codeproject.com/soap/MTOMWebServices.asp">article
on http chunking web services with MTOM</a> here for reference.  by the way it
has been updated on codeproject...<br /><br /><ul class="download"><li><a href="http://www.codeproject.com/soap/MTOMWebServices/Article_source.zip">Download
source for web service + Windows client - 52.1 Kb</a></li></ul><p><img alt="Screenshot of windows forms client, uploading a file" src="http://www.codeproject.com/soap/MTOMWebServices/Article.jpg" /></p><h2>Introduction
</h2><p>
In trying to keep up to speed with .NET 2.0, I decided to do a .NET 2.0 version of
my CodeProject article <a href="http://www.codeproject.com/cs/webservices/DimeBufferedUpload.asp">"DIME
Buffered Upload"</a> which used the DIME standard to transfer binary data over web
services. The DIME approach was reasonably efficient but the code is quite complex
and I was keen to explore what .NET 2.0 has to offer. In this article, I use version
3.0 of the WSE (<a href="http://msdn.microsoft.com/webservices/webservices/building/wse/" target="_blank">Web
Service Enhancements</a>) which is available for .NET 2.0 as an add-in, to provide
a simpler and faster method of sending binary data in small chunks over HTTP web services.
</p><h2>Background
</h2><p>
Just a recap on why you may need to send data in small chunks at all: if you have
a large file and you want to send it across a web service, you must understand the
way it all fits together between IIS, .NET, and the web service call. You send your
file as an array of bytes, as a parameter to a web service call, which is all sent
to the IIS web server as a single request. This is bad if the size of the file is
beyond the configured <code>MaxRequestLength</code> of your application, or if the
request causes an IIS timeout. It is also bad from the point of view of providing
feedback of the file transfer to the user interface because you have no indication
how the transfer is going, until it is either completed or failed. The solution outlined
here is to send chunks of the file one by one, and append them to the file on the
server.
</p><p>
There is an MD5 file hash done on the client and the server to verify that the file
received is identical to the file sent.
</p><p>
Also, there is an upload and download code included in this article.
</p><h2>Adventures with MTOM
</h2><p>
MTOM stands for SOAP "Message Transmission Optimization Mechanism" and it is a <a href="http://www.w3.org/TR/2005/REC-soap12-mtom-20050125/" target="_blank">W3C
standard</a>. To use it (and to run this application), you must download and install <a href="http://msdn.microsoft.com/webservices/webservices/building/wse/" target="_blank">WSE
3.0</a>, which includes MTOM support for the first time. If you look in the <i>app.config</i> and <i>web.config</i> files
in the source code, you will see sections referring to the WSE 3 assembly, and a messaging <code>clientMode</code> or <code>serverMode</code> setting.
These are necessary to run MTOM in the application.
</p><p>
The problem with DIME was that the binary content of the message was sent outside
the <code>SoapEnvelope</code> of the XML message. This meant that although your message
was secure, the Dime Attachment may not be secure. MTOM fully complies with the other
WS-* specifications (like WS-Security) so the entire message is secure.
</p><p>
It took me a while to realise that when MTOM is turned on for the client and the server,
WSE automatically handles the binary encoding of the data in the web service message.
With DIME and WSE 2.0, you had to configure your app for DIME and then use DimeAttachments
in your code. This is no longer necessary, you just send your byte[] as a parameter
or return value, and WSE makes sure that it is sent as binary, and not padded by XML
serialization as it would be in the absence of DIME or MTOM.
</p><h2>How it works
</h2><p>
The web service has two main methods, <code>AppendChunk</code> is for uploading a
file to the server, <code>DownloadChunk</code> is for downloading from the server.
These methods receive parameters for the file name, the offset of the chunk, and the
size of the buffer being sent/received.
</p><p>
The Windows Forms client application can upload a file by sending all the chunks one
after the other using <code>AppendChunk</code>, until the file has been completely
sent. It can do an MD5 hash on the local file, and compare it with the hash on the
file on the server, to make sure the contents of the files are identical. The download
code is very similar, the main difference is that the client must know from the server
how big the file is, so that it can know when to stop requesting chunks.
</p><p>
A simplified version of the <b>upload code is shown below</b> (from the WinForms client).
Have a look in the code for <i>Form1.cs</i> to see the inline comments + the explanation
of the code. Essentially, a file stream is opened on the client for the duration of
the transfer. Then the first chunk is read into the <code>Buffer</code> byte array.
The <code lang="cs"><span class="cs-keyword">while</span></code> loop keeps running
until the <code>FileStream.Read()</code> method returns 0, i.e. the end of the file
has been reached. For each iteration, the buffer is sent directly to the web service
as a <code lang="cs"><span class="cs-keyword">byte</span>[]</code>. The '<code>SentBytes</code>'
variable is used to report progress to the form.
</p><pre>using(FileStream fs = new FileStream(LocalFilePath, FileMode.Open, FileAccess.Read))<br />
{<br />
int BytesRead = fs.Read(Buffer, 0, ChunkSize);<br />
while(BytesRead &gt; 0 &amp;&amp; !worker.CancellationPending)<br />
{<br />
ws.AppendChunk(FileName, Buffer, SentBytes, BytesRead);<br />
SentBytes += BytesRead;<br />
BytesRead = fs.Read(Buffer, 0, ChunkSize); 
<br />
}<br />
}</pre><h2>Example of the BackgroundWorker class in .NET 2.0
</h2><p>
.NET 2.0 has a great new class called '<code>BackgroundWorker</code>' to simplify
running tasks asynchronously. Although this application sends the file in small chunks,
even these small chunks would delay the WinForms application and make it look crashed
during the transfer. So the web service calls still need to be done asynchronously.
The <code>BackgroundWorker</code> class works using an event model, where you have
code sections to run for <code>DoWork</code> (when you start), <code>ProgressChanged</code> (to
update your progress bar / status bar), and <code>Completed</code> (or failed). You
can pass parameters to the <code>DoWork</code> method, which you could not do with
the <code>Thread</code> class in .NET 1.1 (I know you could with delegates, but delegates
aren't great for thread control). You can also access the return value of <code>DoWork</code> in
the <code>Completed</code> event handler. So for once, MS has thought of everything
and made a very clean threading model. Exceptions are handled internally and you can
access them in the <code>Completed</code> method via the <code>RunWorkerCompletedEventArgs.Error</code> property.
</p><p>
The code shown below is an example of the <code>ProgressChanged</code> event handler:
</p><pre>private void workerUpload_ProgressChanged(object sender, ProgressChangedEventArgs e)<br />
{<br />
// update the progress bar and status bar text<br />
this.toolStripProgressBar1.Value = e.ProgressPercentage;<br />
this.statusText.Text = e.UserState.ToString();<br />
// summary text is sent in the UserState parameter<br />
}<br /></pre><p>
I have used four <code>BackgroundWorker</code> objects in the application:
</p><ul><li>
one to manage the upload process, 
</li><li>
one to manage the download process, 
</li><li>
another to calculate the local MD5 file hash in parallel while waiting for the server
result, 
</li><li>
and another to download the list of files in the <i>Upload</i> server folder to allow
the user to select a file to download. 
</li></ul><p>
The reason I use a <code>BackgroundWorker</code> object for each task is because the
code for each task is tied in to the events for that object.
</p><h2>A good example of Thread.Join()
</h2><p>
When the upload or download is complete, the client asks for an MD5 hash of the file
on the server, so it can compare it with the local file to make sure they are identical.
I originally did these in sequence. But it can take a few seconds to calculate the
result for a large file (anything over a few hundred MB), so the application was waiting
five seconds for the server to calculate the hash, and then five more seconds for
the client to calculate its own hash. This made no sense, so I decided to implement
a multi-threaded approach to allow them to run in parallel. While the client is waiting
on the server, it should be calculating its own file hash. This is done with the <code>Thread</code> class,
and the use of the <code>Join()</code> method which blocks execution until the thread
is complete.
</p><p>
The code below shows how this is accomplished:
</p><pre>// start calculating the local hash (stored in class variable)<br />
this.hashThread = new Thread(new ThreadStart(this.CheckFileHash));<br />
this.hashThread.Start();<br /><br />
// request the server hash<br />
string ServerFileHash = ws.CheckFileHash(FileName);<br /><br />
// wait for the local hash to complete<br />
this.hashThread.Join();<br /><br />
if(this.LocalFileHash == ServerFileHash)<br />
e.Result = "Hashes match exactly";<br />
else 
<br />
e.Result = "Hashes do not match";<br /></pre><p>
There is a good chance that the two operations will finish at approximately the same
time, so very little waiting around will actually happen.
</p><h2>Performance compared with DIME
</h2><p>
I found that MTOM was about 10% faster than DIME in my limited testing. This is probably
to do with the need to package up each chunk into a DIME attachment, which is no longer
necessary with MTOM. I was able to upload files of several gigabytes in size without
problems.
</p><p>
Obviously, there is an overhead with all this business of reading file chunks and
appending them, so the larger the chunk size, the more efficient your application
will be. It should be customised based on the network and the expected size of files.
For very small files, it is no harm to use small chunk sizes (e.g., 32 Kb) because
this will give accurate and regular feedback to the user interface. For very large
files on a fast network, consider using 4000 Kb to make good use of the bandwidth
and reduce the File Input/Output overhead. If you want to send chunks larger than
4 MB, you must increase the .NET 2.0 Max Request Size limit in your <i>web.config</i>.
</p><h2>Conclusions
</h2><p>
Feel free to use this code and modify it as you please. Please post a comment for
any bugs, suggestions, or improvements. Enjoy!
</p><p></p><img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=9603c0e9-a99e-4d6e-bfef-d4abb7ae9501" /></body>
      <title>Sending files in chunks with MTOM Web Services and .NET 2.0</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,9603c0e9-a99e-4d6e-bfef-d4abb7ae9501.aspx</guid>
      <link>http://tim.mackey.ie/SendingFilesInChunksWithMTOMWebServicesAndNET20.aspx</link>
      <pubDate>Thu, 29 Dec 2005 20:34:15 GMT</pubDate>
      <description>just posting my code-project &lt;a href="http://www.codeproject.com/soap/MTOMWebServices.asp"&gt;article
on http chunking web services with MTOM&lt;/a&gt; here for reference.&amp;nbsp; by the way it
has been updated on codeproject...&lt;br&gt;
&lt;br&gt;
&lt;ul class="download"&gt;
&lt;li&gt;
&lt;a href="http://www.codeproject.com/soap/MTOMWebServices/Article_source.zip"&gt;Download
source for web service + Windows client - 52.1 Kb&lt;/a&gt; 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;img alt="Screenshot of windows forms client, uploading a file" src="http://www.codeproject.com/soap/MTOMWebServices/Article.jpg"&gt;
&lt;/p&gt;
&lt;h2&gt;Introduction
&lt;/h2&gt;
&lt;p&gt;
In trying to keep up to speed with .NET 2.0, I decided to do a .NET 2.0 version of
my CodeProject article &lt;a href="http://www.codeproject.com/cs/webservices/DimeBufferedUpload.asp"&gt;"DIME
Buffered Upload"&lt;/a&gt; which used the DIME standard to transfer binary data over web
services. The DIME approach was reasonably efficient but the code is quite complex
and I was keen to explore what .NET 2.0 has to offer. In this article, I use version
3.0 of the WSE (&lt;a href="http://msdn.microsoft.com/webservices/webservices/building/wse/" target="_blank"&gt;Web
Service Enhancements&lt;/a&gt;) which is available for .NET 2.0 as an add-in, to provide
a simpler and faster method of sending binary data in small chunks over HTTP web services.
&lt;/p&gt;
&lt;h2&gt;Background
&lt;/h2&gt;
&lt;p&gt;
Just a recap on why you may need to send data in small chunks at all: if you have
a large file and you want to send it across a web service, you must understand the
way it all fits together between IIS, .NET, and the web service call. You send your
file as an array of bytes, as a parameter to a web service call, which is all sent
to the IIS web server as a single request. This is bad if the size of the file is
beyond the configured &lt;code&gt;MaxRequestLength&lt;/code&gt; of your application, or if the
request causes an IIS timeout. It is also bad from the point of view of providing
feedback of the file transfer to the user interface because you have no indication
how the transfer is going, until it is either completed or failed. The solution outlined
here is to send chunks of the file one by one, and append them to the file on the
server.
&lt;/p&gt;
&lt;p&gt;
There is an MD5 file hash done on the client and the server to verify that the file
received is identical to the file sent.
&lt;/p&gt;
&lt;p&gt;
Also, there is an upload and download code included in this article.
&lt;/p&gt;
&lt;h2&gt;Adventures with MTOM
&lt;/h2&gt;
&lt;p&gt;
MTOM stands for SOAP "Message Transmission Optimization Mechanism" and it is a &lt;a href="http://www.w3.org/TR/2005/REC-soap12-mtom-20050125/" target="_blank"&gt;W3C
standard&lt;/a&gt;. To use it (and to run this application), you must download and install &lt;a href="http://msdn.microsoft.com/webservices/webservices/building/wse/" target="_blank"&gt;WSE
3.0&lt;/a&gt;, which includes MTOM support for the first time. If you look in the &lt;i&gt;app.config&lt;/i&gt; and &lt;i&gt;web.config&lt;/i&gt; files
in the source code, you will see sections referring to the WSE 3 assembly, and a messaging &lt;code&gt;clientMode&lt;/code&gt; or &lt;code&gt;serverMode&lt;/code&gt; setting.
These are necessary to run MTOM in the application.
&lt;/p&gt;
&lt;p&gt;
The problem with DIME was that the binary content of the message was sent outside
the &lt;code&gt;SoapEnvelope&lt;/code&gt; of the XML message. This meant that although your message
was secure, the Dime Attachment may not be secure. MTOM fully complies with the other
WS-* specifications (like WS-Security) so the entire message is secure.
&lt;/p&gt;
&lt;p&gt;
It took me a while to realise that when MTOM is turned on for the client and the server,
WSE automatically handles the binary encoding of the data in the web service message.
With DIME and WSE 2.0, you had to configure your app for DIME and then use DimeAttachments
in your code. This is no longer necessary, you just send your byte[] as a parameter
or return value, and WSE makes sure that it is sent as binary, and not padded by XML
serialization as it would be in the absence of DIME or MTOM.
&lt;/p&gt;
&lt;h2&gt;How it works
&lt;/h2&gt;
&lt;p&gt;
The web service has two main methods, &lt;code&gt;AppendChunk&lt;/code&gt; is for uploading a
file to the server, &lt;code&gt;DownloadChunk&lt;/code&gt; is for downloading from the server.
These methods receive parameters for the file name, the offset of the chunk, and the
size of the buffer being sent/received.
&lt;/p&gt;
&lt;p&gt;
The Windows Forms client application can upload a file by sending all the chunks one
after the other using &lt;code&gt;AppendChunk&lt;/code&gt;, until the file has been completely
sent. It can do an MD5 hash on the local file, and compare it with the hash on the
file on the server, to make sure the contents of the files are identical. The download
code is very similar, the main difference is that the client must know from the server
how big the file is, so that it can know when to stop requesting chunks.
&lt;/p&gt;
&lt;p&gt;
A simplified version of the &lt;b&gt;upload code is shown below&lt;/b&gt; (from the WinForms client).
Have a look in the code for &lt;i&gt;Form1.cs&lt;/i&gt; to see the inline comments + the explanation
of the code. Essentially, a file stream is opened on the client for the duration of
the transfer. Then the first chunk is read into the &lt;code&gt;Buffer&lt;/code&gt; byte array.
The &lt;code lang="cs"&gt;&lt;span class="cs-keyword"&gt;while&lt;/span&gt;&lt;/code&gt; loop keeps running
until the &lt;code&gt;FileStream.Read()&lt;/code&gt; method returns 0, i.e. the end of the file
has been reached. For each iteration, the buffer is sent directly to the web service
as a &lt;code lang="cs"&gt;&lt;span class="cs-keyword"&gt;byte&lt;/span&gt;[]&lt;/code&gt;. The '&lt;code&gt;SentBytes&lt;/code&gt;'
variable is used to report progress to the form.
&lt;/p&gt;
&lt;pre&gt;using(FileStream fs = new FileStream(LocalFilePath, FileMode.Open, FileAccess.Read))&lt;br&gt;
{&lt;br&gt;
int BytesRead = fs.Read(Buffer, 0, ChunkSize);&lt;br&gt;
while(BytesRead &amp;gt; 0 &amp;amp;&amp;amp; !worker.CancellationPending)&lt;br&gt;
{&lt;br&gt;
ws.AppendChunk(FileName, Buffer, SentBytes, BytesRead);&lt;br&gt;
SentBytes += BytesRead;&lt;br&gt;
BytesRead = fs.Read(Buffer, 0, ChunkSize); 
&lt;br&gt;
}&lt;br&gt;
}&lt;/pre&gt;
&lt;h2&gt;Example of the BackgroundWorker class in .NET 2.0
&lt;/h2&gt;
&lt;p&gt;
.NET 2.0 has a great new class called '&lt;code&gt;BackgroundWorker&lt;/code&gt;' to simplify
running tasks asynchronously. Although this application sends the file in small chunks,
even these small chunks would delay the WinForms application and make it look crashed
during the transfer. So the web service calls still need to be done asynchronously.
The &lt;code&gt;BackgroundWorker&lt;/code&gt; class works using an event model, where you have
code sections to run for &lt;code&gt;DoWork&lt;/code&gt; (when you start), &lt;code&gt;ProgressChanged&lt;/code&gt; (to
update your progress bar / status bar), and &lt;code&gt;Completed&lt;/code&gt; (or failed). You
can pass parameters to the &lt;code&gt;DoWork&lt;/code&gt; method, which you could not do with
the &lt;code&gt;Thread&lt;/code&gt; class in .NET 1.1 (I know you could with delegates, but delegates
aren't great for thread control). You can also access the return value of &lt;code&gt;DoWork&lt;/code&gt; in
the &lt;code&gt;Completed&lt;/code&gt; event handler. So for once, MS has thought of everything
and made a very clean threading model. Exceptions are handled internally and you can
access them in the &lt;code&gt;Completed&lt;/code&gt; method via the &lt;code&gt;RunWorkerCompletedEventArgs.Error&lt;/code&gt; property.
&lt;/p&gt;
&lt;p&gt;
The code shown below is an example of the &lt;code&gt;ProgressChanged&lt;/code&gt; event handler:
&lt;/p&gt;
&lt;pre&gt;private void workerUpload_ProgressChanged(object sender, ProgressChangedEventArgs e)&lt;br&gt;
{&lt;br&gt;
// update the progress bar and status bar text&lt;br&gt;
this.toolStripProgressBar1.Value = e.ProgressPercentage;&lt;br&gt;
this.statusText.Text = e.UserState.ToString();&lt;br&gt;
// summary text is sent in the UserState parameter&lt;br&gt;
}&lt;br&gt;
&lt;/pre&gt;
&lt;p&gt;
I have used four &lt;code&gt;BackgroundWorker&lt;/code&gt; objects in the application:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
one to manage the upload process, 
&lt;/li&gt;
&lt;li&gt;
one to manage the download process, 
&lt;/li&gt;
&lt;li&gt;
another to calculate the local MD5 file hash in parallel while waiting for the server
result, 
&lt;/li&gt;
&lt;li&gt;
and another to download the list of files in the &lt;i&gt;Upload&lt;/i&gt; server folder to allow
the user to select a file to download. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The reason I use a &lt;code&gt;BackgroundWorker&lt;/code&gt; object for each task is because the
code for each task is tied in to the events for that object.
&lt;/p&gt;
&lt;h2&gt;A good example of Thread.Join()
&lt;/h2&gt;
&lt;p&gt;
When the upload or download is complete, the client asks for an MD5 hash of the file
on the server, so it can compare it with the local file to make sure they are identical.
I originally did these in sequence. But it can take a few seconds to calculate the
result for a large file (anything over a few hundred MB), so the application was waiting
five seconds for the server to calculate the hash, and then five more seconds for
the client to calculate its own hash. This made no sense, so I decided to implement
a multi-threaded approach to allow them to run in parallel. While the client is waiting
on the server, it should be calculating its own file hash. This is done with the &lt;code&gt;Thread&lt;/code&gt; class,
and the use of the &lt;code&gt;Join()&lt;/code&gt; method which blocks execution until the thread
is complete.
&lt;/p&gt;
&lt;p&gt;
The code below shows how this is accomplished:
&lt;/p&gt;
&lt;pre&gt;// start calculating the local hash (stored in class variable)&lt;br&gt;
this.hashThread = new Thread(new ThreadStart(this.CheckFileHash));&lt;br&gt;
this.hashThread.Start();&lt;br&gt;
&lt;br&gt;
// request the server hash&lt;br&gt;
string ServerFileHash = ws.CheckFileHash(FileName);&lt;br&gt;
&lt;br&gt;
// wait for the local hash to complete&lt;br&gt;
this.hashThread.Join();&lt;br&gt;
&lt;br&gt;
if(this.LocalFileHash == ServerFileHash)&lt;br&gt;
e.Result = "Hashes match exactly";&lt;br&gt;
else 
&lt;br&gt;
e.Result = "Hashes do not match";&lt;br&gt;
&lt;/pre&gt;
&lt;p&gt;
There is a good chance that the two operations will finish at approximately the same
time, so very little waiting around will actually happen.
&lt;/p&gt;
&lt;h2&gt;Performance compared with DIME
&lt;/h2&gt;
&lt;p&gt;
I found that MTOM was about 10% faster than DIME in my limited testing. This is probably
to do with the need to package up each chunk into a DIME attachment, which is no longer
necessary with MTOM. I was able to upload files of several gigabytes in size without
problems.
&lt;/p&gt;
&lt;p&gt;
Obviously, there is an overhead with all this business of reading file chunks and
appending them, so the larger the chunk size, the more efficient your application
will be. It should be customised based on the network and the expected size of files.
For very small files, it is no harm to use small chunk sizes (e.g., 32 Kb) because
this will give accurate and regular feedback to the user interface. For very large
files on a fast network, consider using 4000 Kb to make good use of the bandwidth
and reduce the File Input/Output overhead. If you want to send chunks larger than
4 MB, you must increase the .NET 2.0 Max Request Size limit in your &lt;i&gt;web.config&lt;/i&gt;.
&lt;/p&gt;
&lt;h2&gt;Conclusions
&lt;/h2&gt;
&lt;p&gt;
Feel free to use this code and modify it as you please. Please post a comment for
any bugs, suggestions, or improvements. Enjoy!
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=9603c0e9-a99e-4d6e-bfef-d4abb7ae9501" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,9603c0e9-a99e-4d6e-bfef-d4abb7ae9501.aspx</comments>
      <category>.Net General</category>
      <category>.Net Windows Forms</category>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=616d66f9-7659-4292-8c30-54bc7910126a</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,616d66f9-7659-4292-8c30-54bc7910126a.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,616d66f9-7659-4292-8c30-54bc7910126a.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=616d66f9-7659-4292-8c30-54bc7910126a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">i was experimenting with how .Net 2.0 does
xml serialization of objects, and i got it serializing nicely with the following code.  
<br /><pre>XmlSerializer xs = new XmlSerializer(typeof(PageCollection));
xs.Serialize(fs, pages); // 'fs' is a FileStream to my xml file, and 'pages' is a collection class of objects</pre><br />
the problem was when i tried to deserialize it, like so:<br /><pre>XmlSerializer xs = new XmlSerializer(typeof(PageCollection));
pages = xs.Deserialize(fs) as PageCollection;</pre><br />
i got this error:<br /><blockquote><h3>xmlns=''&gt; was not expected
</h3></blockquote>i found <a href="http://groups.google.com/group/microsoft.public.dotnet.xml/browse_thread/thread/9195d8f5a339ce89/9a619c313a02bf5c">this
post</a> on google which described the same errors, and a workaround (by adding an
empty namespace) but it didn't work for me.  perhaps it is a difference in the
serialization process with with .Net 2.0.  what fixed it for me was setting an
XmlRootAttribute for the class i was serializing. like so: <pre>[XmlRootAttribute("CmsPages", Namespace = "http://www.whatever.com/Cms", IsNullable = false)]</pre>hope
this helps someone else out there with the same problem.<img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=616d66f9-7659-4292-8c30-54bc7910126a" /></body>
      <title>Serializing an object in Xml, with .Net 2.0</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,616d66f9-7659-4292-8c30-54bc7910126a.aspx</guid>
      <link>http://tim.mackey.ie/SerializingAnObjectInXmlWithNet20.aspx</link>
      <pubDate>Thu, 15 Dec 2005 13:28:01 GMT</pubDate>
      <description>i was experimenting with how .Net 2.0 does xml serialization of objects, and i got it serializing nicely with the following code.&amp;nbsp; &lt;br&gt;
&lt;pre&gt;XmlSerializer xs = new XmlSerializer(typeof(PageCollection));
xs.Serialize(fs, pages); // 'fs' is a FileStream to my xml file, and 'pages' is a collection class of objects&lt;/pre&gt;
&lt;br&gt;
the problem was when i tried to deserialize it, like so:&lt;br&gt;
&lt;pre&gt;XmlSerializer xs = new XmlSerializer(typeof(PageCollection));
pages = xs.Deserialize(fs) as PageCollection;&lt;/pre&gt;
&lt;br&gt;
i got this error:&lt;br&gt;
&lt;blockquote&gt;
&lt;h3&gt;xmlns=''&amp;gt; was not expected
&lt;/h3&gt;
&lt;/blockquote&gt;i found &lt;a href="http://groups.google.com/group/microsoft.public.dotnet.xml/browse_thread/thread/9195d8f5a339ce89/9a619c313a02bf5c"&gt;this
post&lt;/a&gt; on google which described the same errors, and a workaround (by adding an
empty namespace) but it didn't work for me.&amp;nbsp; perhaps it is a difference in the
serialization process with with .Net 2.0.&amp;nbsp; what fixed it for me was setting an
XmlRootAttribute for the class i was serializing. like so: &lt;pre&gt;[XmlRootAttribute("CmsPages", Namespace = "http://www.whatever.com/Cms", IsNullable = false)]&lt;/pre&gt;hope
this helps someone else out there with the same problem.&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=616d66f9-7659-4292-8c30-54bc7910126a" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,616d66f9-7659-4292-8c30-54bc7910126a.aspx</comments>
      <category>.Net General</category>
      <category>Asp.Net</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=38544dae-c5b0-487d-a22f-7781459b2416</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,38544dae-c5b0-487d-a22f-7781459b2416.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,38544dae-c5b0-487d-a22f-7781459b2416.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=38544dae-c5b0-487d-a22f-7781459b2416</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I had a transaction comprised of about 5 commands, and in the middle of it, i needed
to do a SELECT on a table to know what values to insert for one of the commands. 
I encountered a timeout just after i called Fill on the DataAdapter.  it took
me a while to figure out that it was because the transaction had already taken out
a lock on the table i was selecting from.  makes sense now, but i spent ages
on it!  just posting it here in case anyone else runs into the same problem. 
</p>
        <img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=38544dae-c5b0-487d-a22f-7781459b2416" />
      </body>
      <title>ADO.NET timeouts when filling a DataAdapter in the middle of a transaction</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,38544dae-c5b0-487d-a22f-7781459b2416.aspx</guid>
      <link>http://tim.mackey.ie/ADONETTimeoutsWhenFillingADataAdapterInTheMiddleOfATransaction.aspx</link>
      <pubDate>Fri, 02 Dec 2005 12:26:22 GMT</pubDate>
      <description>&lt;p&gt;
I had a transaction comprised of about 5 commands, and in the middle of it, i needed
to do a SELECT on a table to know what values to insert for one of the commands.&amp;nbsp;
I encountered a timeout just after i called Fill on the DataAdapter.&amp;nbsp; it took
me a while to figure out that it was because the transaction had already taken out
a lock on the table i was selecting from.&amp;nbsp; makes sense now, but i spent ages
on it!&amp;nbsp; just posting it here in case anyone else runs into the same problem. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=38544dae-c5b0-487d-a22f-7781459b2416" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,38544dae-c5b0-487d-a22f-7781459b2416.aspx</comments>
      <category>.Net General</category>
      <category>.Net Windows Forms</category>
      <category>Asp.Net</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=2ece42de-a334-4fd0-8f94-53c6602d5718</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,2ece42de-a334-4fd0-8f94-53c6602d5718.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,2ece42de-a334-4fd0-8f94-53c6602d5718.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=2ece42de-a334-4fd0-8f94-53c6602d5718</wfw:commentRss>
      <slash:comments>27</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h3>Introduction
</h3>
        <p>
I've spent a long time trying many different approaches at getting rid of MS
Word HTML, when importing or pasting text into my content management system, with
very mixed success.  Previous efforts involved using the MSHTML Element Dom but
this was slow and difficult to implement.  i think i've finally found a satisfactory
and fast solution using only regular expressions.  Please feel free to use it
in your applications, and post any improvements you may find. 
</p>
        <h3>The Code
</h3>
        <pre>/// &lt;summary&gt;<br />
/// Removes all FONT and SPAN tags, and all Class and Style attributes.<br />
/// Designed to get rid of non-standard Microsoft Word HTML tags.<br />
/// &lt;/summary&gt;<br />
private string CleanHtml(string html)<br />
{ 
<br />
// start by completely removing all unwanted tags 
<br />
html = Regex.Replace(html, @"<font size="2">&lt;[/]?(font|span|xml|del|ins|[ovwxp]:\w+)[^&gt;]*?&gt;</font>",
"", RegexOptions.IgnoreCase); 
<br />
// then run another pass over the html (twice), removing unwanted attributes 
<br />
html = Regex.Replace(html, @"&lt;([^&gt;]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s&gt;]+)([^&gt;]*)&gt;","&lt;$1$2&gt;",
RegexOptions.IgnoreCase); 
<br />
html = Regex.Replace(html, @"&lt;([^&gt;]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s&gt;]+)([^&gt;]*)&gt;","&lt;$1$2&gt;",
RegexOptions.IgnoreCase); 
<br />
return html;<br />
}</pre>
        <h3>Samples of non-standard Microsoft Word HTML
</h3>
        <pre>&lt;SPAN lang=EN-IE style="mso-ansi-language: EN-IE"&gt;<br />
&lt;p class="MSO Normal"&gt;<br />
&lt;UL style="MARGIN-TOP: 0cm" type=circle&gt;<br />
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;<br />
&lt;li class=MsoNormal style='mso-list:l3 level1 lfo3;tab-stops:list 36.0pt'&gt;</pre>
        <h3>Explanation of Regular Expressions
</h3>
        <p>
I've spent a good deal of time examining the problematic tags that MS Word inserts
in its HTML, some examples are shown above.  The above code is based on a few
requirements for my CMS: 
</p>
        <ul>
          <li>
remove all FONT and SPAN tags, because all the content in my CMS is done through style-sheets. 
</li>
          <li>
remove all CLASS and STYLE tags because they mean nothing outside of the original
word document 
</li>
          <li>
remove all namespace tags and attributes like &lt;o:p&gt; and &lt; ... v:shape ...
&gt;</li>
        </ul>
        <p>
The first regular expression removes unwanted tags, and is broken down as follows:
</p>
        <pre>&lt;[/]?(font|span|xml|del|ins|[ovwxp]:\w+)[^&gt;]*?&gt;</pre>
        <ul>
          <li>
match an open tag character &lt; 
</li>
          <li>
and optionally match a close tag sequence &lt;/  (because we also want to
remove the closing tags) 
</li>
          <li>
match any of the list of unwanted tags: font,span,xml,del,ins 
</li>
          <li>
a pattern is given to match any of the namespace tags, anything beginning with o,v,w,x,p,
followed by a : followed by another word 
</li>
          <li>
match any attributes as far as the closing tag character &gt; 
</li>
          <li>
the replace string for this regex is "", which will completely remove the instances
of any matching tags. 
</li>
          <li>
note that we are not removing anything between the tags, just the tags themselves</li>
        </ul>
        <p>
The second regular expression removes unwanted attributes, and is broken down as follows:
</p>
        <pre>&lt;([^&gt;]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s&gt;]+)([^&gt;]*)&gt;</pre>
        <ul>
          <li>
match an open tag character &lt; 
</li>
          <li>
capture any text before the unwanted attribute (This is $1 in the replace expression) 
</li>
          <li>
match (but don't capture) any of the unwanted attributes: class, lang, style, size,
face, o:p, v:shape etc. 
</li>
          <li>
there should always be an = character after the attribute name 
</li>
          <li>
match the value of the attribute by identifying the delimiters. these can be single
quotes, or double quotes, or no quotes at all. 
</li>
          <li>
for single quotes, the pattern is: ' followed by anything but a ' followed by a ' 
</li>
          <li>
similarly for double quotes.  
</li>
          <li>
for a non-delimited attribute value, i specify the pattern as anything except the
closing tag character &gt; 
</li>
          <li>
lastly, capture whatever comes after the unwanted attribute in ([^&gt;]*) 
</li>
          <li>
the replacement string &lt;$1$2&gt; reconstructs the tag without the unwanted attribute
found in the middle. 
</li>
          <li>
note: this only removes one occurence of an unwanted attribute, this is why i run
the same regex twice.  For example, take the html fragment: &lt;p class="MSO
Normal" style="Margin-TOP:3em"&gt;  
<br />
the regex will only remove one of these attributes.  Running the regex twice
will remove the second one.  I can't think of any reasonable cases where it would
need to be run more than that. 
</li>
        </ul>
        <h3>Suggestions!
</h3>
        <p>
If you have any suggestions or improvments, please post them here as comments. 
<br />
Thanks :)
</p>
p.s. thanks to BinBin for the fix to preserve attributes like 'align=center'.<img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=2ece42de-a334-4fd0-8f94-53c6602d5718" /></body>
      <title>Clean Word HTML using Regular Expressions</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,2ece42de-a334-4fd0-8f94-53c6602d5718.aspx</guid>
      <link>http://tim.mackey.ie/CleanWordHTMLUsingRegularExpressions.aspx</link>
      <pubDate>Wed, 23 Nov 2005 15:40:36 GMT</pubDate>
      <description>&lt;h3&gt;Introduction
&lt;/h3&gt;
&lt;p&gt;
I've spent a long time trying many different approaches at&amp;nbsp;getting rid of&amp;nbsp;MS
Word HTML, when importing or pasting text into my content management system, with
very mixed success.&amp;nbsp; Previous efforts involved using the MSHTML Element Dom but
this was slow and difficult to implement.&amp;nbsp; i think i've finally found a satisfactory
and fast solution using only regular expressions.&amp;nbsp; Please feel free to use it
in your applications, and post any improvements you may find. 
&lt;/p&gt;
&lt;h3&gt;The Code
&lt;/h3&gt;
&lt;pre&gt;/// &amp;lt;summary&amp;gt;&lt;br&gt;
/// Removes all FONT and SPAN tags, and all Class and Style attributes.&lt;br&gt;
/// Designed to get rid of non-standard Microsoft Word HTML tags.&lt;br&gt;
/// &amp;lt;/summary&amp;gt;&lt;br&gt;
private string CleanHtml(string html)&lt;br&gt;
{ 
&lt;br&gt;
// start by completely removing all unwanted tags 
&lt;br&gt;
html = Regex.Replace(html, @"&lt;font size="2"&gt;&amp;lt;[/]?(font|span|xml|del|ins|[ovwxp]:\w+)[^&amp;gt;]*?&amp;gt;&lt;/font&gt;",
"", RegexOptions.IgnoreCase); 
&lt;br&gt;
// then run another pass over the html (twice), removing unwanted attributes 
&lt;br&gt;
html = Regex.Replace(html, @"&amp;lt;([^&amp;gt;]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s&amp;gt;]+)([^&amp;gt;]*)&amp;gt;","&amp;lt;$1$2&amp;gt;",
RegexOptions.IgnoreCase); 
&lt;br&gt;
html = Regex.Replace(html, @"&amp;lt;([^&amp;gt;]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s&amp;gt;]+)([^&amp;gt;]*)&amp;gt;","&amp;lt;$1$2&amp;gt;",
RegexOptions.IgnoreCase); 
&lt;br&gt;
return html;&lt;br&gt;
}&lt;/pre&gt;
&lt;h3&gt;Samples of non-standard Microsoft Word&amp;nbsp;HTML
&lt;/h3&gt;
&lt;pre&gt;&amp;lt;SPAN lang=EN-IE style="mso-ansi-language: EN-IE"&amp;gt;&lt;br&gt;
&amp;lt;p class="MSO Normal"&amp;gt;&lt;br&gt;
&amp;lt;UL style="MARGIN-TOP: 0cm" type=circle&amp;gt;&lt;br&gt;
&amp;lt;o:p&amp;gt;&amp;amp;nbsp;&amp;lt;/o:p&amp;gt;&lt;br&gt;
&amp;lt;li class=MsoNormal style='mso-list:l3 level1 lfo3;tab-stops:list 36.0pt'&amp;gt;&lt;/pre&gt;
&lt;h3&gt;Explanation of Regular Expressions
&lt;/h3&gt;
&lt;p&gt;
I've spent a good deal of time examining the problematic tags that MS Word inserts
in its HTML, some examples are shown above.&amp;nbsp; The above code is based on a few
requirements for my CMS: 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
remove all FONT and SPAN tags, because all the content in my CMS is done through style-sheets. 
&lt;/li&gt;
&lt;li&gt;
remove all CLASS and STYLE tags because they mean nothing outside of the original
word document 
&lt;/li&gt;
&lt;li&gt;
remove all namespace tags and attributes like &amp;lt;o:p&amp;gt; and &amp;lt; ... v:shape ...
&amp;gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The first regular expression removes unwanted tags, and is broken down as follows:
&lt;/p&gt;
&lt;pre&gt;&amp;lt;[/]?(font|span|xml|del|ins|[ovwxp]:\w+)[^&amp;gt;]*?&amp;gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;
match&amp;nbsp;an open tag&amp;nbsp;character &amp;lt; 
&lt;/li&gt;
&lt;li&gt;
and optionally match a close tag&amp;nbsp;sequence &amp;lt;/&amp;nbsp; (because we also want to
remove the closing tags) 
&lt;/li&gt;
&lt;li&gt;
match any of the list of unwanted tags: font,span,xml,del,ins 
&lt;/li&gt;
&lt;li&gt;
a pattern is given to match any of the namespace tags, anything beginning with o,v,w,x,p,
followed by a : followed by another word 
&lt;/li&gt;
&lt;li&gt;
match any attributes as far as the closing tag character &amp;gt; 
&lt;/li&gt;
&lt;li&gt;
the replace string for this regex is "", which will completely remove the instances
of any matching tags. 
&lt;/li&gt;
&lt;li&gt;
note that we are not&amp;nbsp;removing anything between the tags, just the tags themselves&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The second regular expression removes unwanted attributes, and is broken down as follows:
&lt;/p&gt;
&lt;pre&gt;&amp;lt;([^&amp;gt;]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s&amp;gt;]+)([^&amp;gt;]*)&amp;gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;
match&amp;nbsp;an open tag&amp;nbsp;character &amp;lt; 
&lt;/li&gt;
&lt;li&gt;
capture any text before the unwanted attribute (This is $1 in the replace expression) 
&lt;/li&gt;
&lt;li&gt;
match (but don't capture) any of the unwanted attributes: class, lang, style, size,
face, o:p, v:shape etc. 
&lt;/li&gt;
&lt;li&gt;
there should always be an = character after the attribute name 
&lt;/li&gt;
&lt;li&gt;
match the value of the attribute by identifying the delimiters. these can be single
quotes, or double quotes, or no quotes at all. 
&lt;/li&gt;
&lt;li&gt;
for single quotes, the pattern is: ' followed by anything but a ' followed by a ' 
&lt;/li&gt;
&lt;li&gt;
similarly for double quotes.&amp;nbsp; 
&lt;/li&gt;
&lt;li&gt;
for a non-delimited attribute value, i specify the pattern as anything except the
closing tag character &amp;gt; 
&lt;/li&gt;
&lt;li&gt;
lastly, capture whatever comes after the unwanted attribute in ([^&amp;gt;]*) 
&lt;/li&gt;
&lt;li&gt;
the replacement string &amp;lt;$1$2&amp;gt; reconstructs the tag without the unwanted attribute
found in the middle. 
&lt;/li&gt;
&lt;li&gt;
note: this only removes one occurence of an unwanted attribute, this is why i run
the same regex twice.&amp;nbsp; For example, take the html fragment: &amp;lt;p class="MSO
Normal" style="Margin-TOP:3em"&amp;gt;&amp;nbsp; 
&lt;br&gt;
the regex will only remove one of these attributes.&amp;nbsp; Running the regex twice
will remove the second one.&amp;nbsp; I can't think of any reasonable cases where it would
need to be run more than that. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Suggestions!
&lt;/h3&gt;
&lt;p&gt;
If you have any suggestions or improvments, please post them here as comments. 
&lt;br&gt;
Thanks :)
&lt;/p&gt;
p.s. thanks to BinBin for the fix to preserve attributes like 'align=center'.&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=2ece42de-a334-4fd0-8f94-53c6602d5718" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,2ece42de-a334-4fd0-8f94-53c6602d5718.aspx</comments>
      <category>.Net General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=94434ffa-247f-44ec-80da-f74529e2b569</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,94434ffa-247f-44ec-80da-f74529e2b569.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,94434ffa-247f-44ec-80da-f74529e2b569.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=94434ffa-247f-44ec-80da-f74529e2b569</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This might sound really obvious, but i couldn't find a better way.  Normally
i would use TOP in the SQL query to limit the number of records i want to retrieve,
but in my case, this value is parameterised and Access won't allow me to parameterise
that value.  I tried using a DataView but TOP isn't one of it's supported functions. 
So i just loop through the dataset and keep removing rows until the right number of
records is reached.
</p>
        <pre>int maxItems = 5;
while(ds.Tables[0].Rows.Count &gt; MaxItems)
    ds.Tables[0].Rows.RemoveAt(MaxItems);</pre>
        <img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=94434ffa-247f-44ec-80da-f74529e2b569" />
      </body>
      <title>Removing rows from a dataset (i.e. achieving TOP functionality when you can't use SQL)</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,94434ffa-247f-44ec-80da-f74529e2b569.aspx</guid>
      <link>http://tim.mackey.ie/RemovingRowsFromADatasetIeAchievingTOPFunctionalityWhenYouCantUseSQL.aspx</link>
      <pubDate>Wed, 28 Sep 2005 10:01:17 GMT</pubDate>
      <description>
&lt;p&gt;
This might sound really obvious, but i couldn't find a better way.&amp;nbsp; Normally
i would use TOP in the SQL query to limit the number of records i want to retrieve,
but in my case, this value is parameterised and Access won't allow me to parameterise
that value.&amp;nbsp; I tried using a DataView but TOP isn't one of it's supported functions.&amp;nbsp;
So i just loop through the dataset and keep removing rows until the right number of
records is reached.
&lt;/p&gt;
&lt;pre&gt;int maxItems = 5;
while(ds.Tables[0].Rows.Count &amp;gt; MaxItems)
    ds.Tables[0].Rows.RemoveAt(MaxItems);&lt;/pre&gt;&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=94434ffa-247f-44ec-80da-f74529e2b569" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,94434ffa-247f-44ec-80da-f74529e2b569.aspx</comments>
      <category>.Net General</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=e2f0deec-afc0-491d-9302-c640b0eac403</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,e2f0deec-afc0-491d-9302-c640b0eac403.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,e2f0deec-afc0-491d-9302-c640b0eac403.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=e2f0deec-afc0-491d-9302-c640b0eac403</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <pre>public static char GetRandomLowerCaseCharacter(int seed)
{
   return ((char) ( (short) 'a' + new Random(seed).Next(26)));
}

public static char GetRandomUpperCaseCharacter(int seed)
{
   return ((char) ( (short) 'A' + new Random(seed).Next(26)));
}</pre>
        <p>
If you call the above methods straight after each other with the same seed, you may
get the same value on a fast processor.  It is a good reason to pass in a different
seed value for operations that will be done in quick succession.  E.g. use DateTime.Now.Seconds
for one operation and then use Minutes or Hour or Milliseconds for the next ones. 
</p>
        <img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=e2f0deec-afc0-491d-9302-c640b0eac403" />
      </body>
      <title>HowTo: get a random letter in C#</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,e2f0deec-afc0-491d-9302-c640b0eac403.aspx</guid>
      <link>http://tim.mackey.ie/HowToGetARandomLetterInC.aspx</link>
      <pubDate>Tue, 15 Mar 2005 18:26:27 GMT</pubDate>
      <description>&lt;pre&gt;public static char GetRandomLowerCaseCharacter(int seed)
{
   return ((char) ( (short) 'a' + new Random(seed).Next(26)));
}

public static char GetRandomUpperCaseCharacter(int seed)
{
   return ((char) ( (short) 'A' + new Random(seed).Next(26)));
}&lt;/pre&gt;
&lt;p&gt;
If you call the above methods straight after each other with the same seed, you may
get the same value on a fast processor.&amp;nbsp; It is a good reason to pass in a different
seed value for operations that will be done in quick succession.&amp;nbsp; E.g. use DateTime.Now.Seconds
for one operation and then use Minutes or Hour or Milliseconds for the next ones. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=e2f0deec-afc0-491d-9302-c640b0eac403" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,e2f0deec-afc0-491d-9302-c640b0eac403.aspx</comments>
      <category>.Net General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=ea417318-7d9c-4cc0-a211-d4a978638d2c</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,ea417318-7d9c-4cc0-a211-d4a978638d2c.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,ea417318-7d9c-4cc0-a211-d4a978638d2c.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=ea417318-7d9c-4cc0-a211-d4a978638d2c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This came in useful for ensuring that web site users have entered a strong password. 
Thanks to <!--StartFragment -->Eli Robillard for posting this on his <a href="http://weblogs.asp.net/erobillard/">blog</a>.
</p>
        <p>
In this case, a strong password is defined as follows: 
</p>
        <ul>
          <li>
between 5 and 128 characters long</li>
          <li>
contains at least one digit</li>
          <li>
contains at least one upper case letter</li>
          <li>
contains at least one lower case letter. 
</li>
        </ul>
        <p>
Here is the pattern: 
</p>
        <pre>^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{5,128}$ </pre>
        <p>
C# code using this pattern: 
</p>
        <pre>public bool IsStrongPassword(string s)
{
    string pattern = @"^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{5,128}$";
    return Regex.IsMatch(s, pattern, RegexOptions.IgnorePatternWhitespace);
}</pre>
        <img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=ea417318-7d9c-4cc0-a211-d4a978638d2c" />
      </body>
      <title>Regex for a strong password</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,ea417318-7d9c-4cc0-a211-d4a978638d2c.aspx</guid>
      <link>http://tim.mackey.ie/RegexForAStrongPassword.aspx</link>
      <pubDate>Tue, 01 Mar 2005 18:46:28 GMT</pubDate>
      <description>&lt;p&gt;
This came in useful for ensuring that web site users have entered a strong password.&amp;nbsp;
Thanks to&amp;nbsp;&lt;!--StartFragment --&gt;Eli Robillard for posting this on his &lt;a href="http://weblogs.asp.net/erobillard/"&gt;blog&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
In this case, a strong password is defined as follows: 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
between 5 and 128 characters long&lt;/li&gt;
&lt;li&gt;
contains at least one digit&lt;/li&gt;
&lt;li&gt;
contains at least one upper case letter&lt;/li&gt;
&lt;li&gt;
contains at least one lower case letter. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Here is the pattern: 
&lt;/p&gt;
&lt;pre&gt;^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{5,128}$ &lt;/pre&gt;
&lt;p&gt;
C# code using this pattern: 
&lt;/p&gt;
&lt;pre&gt;public bool IsStrongPassword(string s)
{
    string pattern = @"^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{5,128}$";
    return Regex.IsMatch(s, pattern, RegexOptions.IgnorePatternWhitespace);
}&lt;/pre&gt;&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=ea417318-7d9c-4cc0-a211-d4a978638d2c" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,ea417318-7d9c-4cc0-a211-d4a978638d2c.aspx</comments>
      <category>.Net General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=8f6830b0-fde7-4308-a578-90d6bf963615</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,8f6830b0-fde7-4308-a578-90d6bf963615.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,8f6830b0-fde7-4308-a578-90d6bf963615.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=8f6830b0-fde7-4308-a578-90d6bf963615</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h3>Background
</h3>
        <p>
In my content management system, i allow the user to define their own 'objects' (e.g.
Staff Member) and then i provide templated data entry forms to let them populate
instances of these objects.  It's aimed at non-techies so i have my own datatypes
called 'Text' which maps to System.String, 'Number' maps to System.Double etc. 
I also have a few custom data types called 'File' and 'Image' to allow the user
to add files or images to an instance of the object.  
</p>
        <h3>Problem
</h3>
        <p>
This business of doing column-mapping was ok as long as my data types had obvious
.Net equivalents, but 'Image' doesn't in my case. i'm only storing a reference to
the image, but in my application, it's not to be treated just as a System.String. 
When the user is creating a new object with an 'Image' field in it, i want to display
a file upload instead of a textbox, and when i go to display the object on the site,
I want to display a html IMG tag with the SRC set to the value of the image field.  
</p>
        <h3>Solution
</h3>
        <p>
The dataset is serialised into an xml file with the schema embedded. i needed to find
some way of encoding my own custom data type information into the dataset that would
persist into the xml file.  I looked through the VS intellisense and found the
'ExtendedProperties' data column property.  This property allows you to plug
in any number of key/value pairs of information to each column.  This was exactly
what i needed, so i added in a pair with something like "MyDataType=Image" for
each column.  This persisted nicely into the xml file as follows:<br /></p>
        <pre>&lt;xs:complexType&gt;
  &lt;xs:sequence&gt;
     &lt;xs:element name="Photo" msprop:MyDataType="Image" type="xs:string" minOccurs="0" /&gt;</pre>
        <p>
Note that the official type of the field is "xs:string", because it contains a path
to the image. but now it also has the custom data type tagged on to the column definition.
in this respect, i'm glad to see that MS have provided a very elegant and flexible
framework.
</p>
        <img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=8f6830b0-fde7-4308-a578-90d6bf963615" />
      </body>
      <title>Using custom datatypes in a .Net Dataset</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,8f6830b0-fde7-4308-a578-90d6bf963615.aspx</guid>
      <link>http://tim.mackey.ie/UsingCustomDatatypesInANetDataset.aspx</link>
      <pubDate>Mon, 22 Nov 2004 16:53:35 GMT</pubDate>
      <description>&lt;h3&gt;Background
&lt;/h3&gt;
&lt;p&gt;
In my content management system, i allow the user to define their own 'objects' (e.g.
Staff Member)&amp;nbsp;and then i provide templated data entry forms to let them populate
instances of these objects.&amp;nbsp; It's aimed at non-techies so i have my own datatypes
called 'Text' which maps to System.String, 'Number'&amp;nbsp;maps to&amp;nbsp;System.Double&amp;nbsp;etc.&amp;nbsp;
I also have a few custom data types called 'File' and&amp;nbsp;'Image' to allow the user
to add files or images to an instance of the object.&amp;nbsp; 
&lt;/p&gt;
&lt;h3&gt;Problem
&lt;/h3&gt;
&lt;p&gt;
This business of doing column-mapping was ok as long as my data types had obvious
.Net equivalents, but 'Image' doesn't in my case. i'm only storing a reference to
the image, but in my application, it's not to be treated just as a System.String.&amp;nbsp;
When the user is creating a new object with an 'Image' field in it, i want to display
a file upload instead of a textbox, and when i go to display the object on the site,
I want to display a html IMG tag with the SRC set to the value of the image field.&amp;nbsp; 
&lt;/p&gt;
&lt;h3&gt;Solution
&lt;/h3&gt;
&lt;p&gt;
The dataset is serialised into an xml file with the schema embedded. i needed to find
some way of encoding my own custom data type information into the dataset that would
persist into the xml file.&amp;nbsp; I looked through the VS intellisense and found the
'ExtendedProperties' data column property.&amp;nbsp; This property allows you to plug
in any number of key/value pairs of information to each column.&amp;nbsp; This was exactly
what i needed, so i added in a pair with&amp;nbsp;something like "MyDataType=Image" for
each column.&amp;nbsp; This persisted nicely into the xml file as follows:&lt;br&gt;
&lt;/p&gt;
&lt;pre&gt;&amp;lt;xs:complexType&amp;gt;
&amp;nbsp; &amp;lt;xs:sequence&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xs:element name="Photo" msprop:MyDataType="Image" type="xs:string" minOccurs="0" /&amp;gt;&lt;/pre&gt;
&lt;p&gt;
Note that the official type of the field is "xs:string", because it contains a path
to the image. but now it also has the custom data type tagged on to the column definition.
in this respect, i'm glad to see that MS have provided a very elegant and flexible
framework.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=8f6830b0-fde7-4308-a578-90d6bf963615" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,8f6830b0-fde7-4308-a578-90d6bf963615.aspx</comments>
      <category>.Net General</category>
    </item>
    <item>
      <trackback:ping>http://tim.mackey.ie/Trackback.aspx?guid=04cb6fac-5b8f-4e08-a626-2367446d9654</trackback:ping>
      <pingback:server>http://tim.mackey.ie/pingback.aspx</pingback:server>
      <pingback:target>http://tim.mackey.ie/PermaLink,guid,04cb6fac-5b8f-4e08-a626-2367446d9654.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://tim.mackey.ie/CommentView,guid,04cb6fac-5b8f-4e08-a626-2367446d9654.aspx</wfw:comment>
      <wfw:commentRss>http://tim.mackey.ie/SyndicationService.asmx/GetEntryCommentsRss?guid=04cb6fac-5b8f-4e08-a626-2367446d9654</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font>If you get annoyed at Visual Source Safe's complications with using asp.net
web projects, and integrating them with Visual Studio.Net, an increasingly popular
approach is to use 'class library' projects instead of web projects.  (Of
course, this problem will disappear with Whidbey but i'm still using VS 2003).  A
web project compiles a dll / class library anyway, and VS doesn't have to interact
with IIS to load the project.  It isn't hard to set up but it does require careful
instructions to be followed.  A guy called Fritz Onion prepared the content
below: </font>
        </p>
        <p>
          <font>This is copied/pasted here in case Fritz's link changes or disappears. The original
content is available from:<br /></font>
          <a href="http://www.pluralsight.com/fritz/Samples/aspdotnet_without_web_projects.htm">http://www.pluralsight.com/fritz/Samples/aspdotnet_without_web_projects.htm</a>
        </p>
        <p>
          <font color="#006400">Reference prepared by </font>
          <a href="http://staff.develop.com/onion/">
            <font color="#006400">Fritz
Onion</font>
          </a>
        </p>
        <p>
          <font color="#006400">The Web Project wizard in Visual Studio .NET is convenient for
creating quick ASP.NET applications on your local machine, but in an effort to simplify
your life, it also makes many decisions for you that are difficult to change if you
need more flexibility. My biggest pet peeve with Web Projects is that you cannot even
open a .sln file if the virtual directory mapping in IIS is not set up correctly.
I also dislike the way it places .sln and .csproj | .vbproj files in a separate location
from the actual source files (I understand that this is necessary to allow application
creation directly on a server, but I never deploy that way).</font>
        </p>
        <p>
          <font color="#006400">As a result, most of my web projects are created as standard
class library projects. Unfortunately this means that you don't get the nice Web component
wizards (like WebForms and UserControls). However, with a little tweaking, you can
have it all.  I have prepared this document describing how to enable these wizards
in class library projects (thanks to Dan Sullivan for pointing out how to do this),
as well as how to convert existing Web Projects to class library projects and still
keep the nice integrated debugging.</font>
        </p>
        <p>
          <b>
            <font color="#006400">To enable Web wizards in a class library project:</font>
          </b>
          <u>
            <br />
          </u>
          <br />
          <font color="#006400">In a directory called<br /><br />
C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\CSharpProjectItems\LocalProjectItems<br /><br />
is a file callled localprojectitems.vsdir.<br /><br />
Likewise in a directory<br /><br />
C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\CSharpProjectItems\WebProjectItems<br /><br />
is a file called webprojectitems.vsdir.<br /><br />
If open the second file with notepad you can figure out the lines to copy to the first
file to be able to add the usual files you need to create an aspx page or web service
to a class lib project.<br /><br />
Once you have copied these thing open VS, open a class lib and go to add new item
and you will see these additional file types available.<br /><br /></font>
          <font color="#006400">
            <b>To set the output of a class library project to go
to a /bin directory of your choosing:<br /></b>
            <br />
1. Right-click on the project and select properties<br />
2. Set Configuration to 'All Configurations' to affect both debug and release builds<br />
3. Under configuration properties/build set the OutputPath to the /bin directory<br />
 </font>
        </p>
        <p>
          <font color="#006400">
            <b>To convert an existing web project into a class library project:<br /></b>
            <br />
1. Open the .sln file in a text editor, and change the reference to the project from
an http://... reference to a simple reference to the .csproj (or .vbproj) filename.
For example:<br />
change:<br />
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication133", "http://localhost/WebApplication133/WebApplication133.csproj",
"{39CB37A5-F735-4684-B5DA-DD355B683090}"<br /><br />
to:<br />
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication133", "WebApplication133.csproj",
"{39CB37A5-F735-4684-B5DA-DD355B683090}"<br /><br />
2. If there is one, delete the .webinfo file<br />
3. Open the .csproj (or .vbproj) file and change the ProjectType attribute from "Web"
to "Local"<br /><br /></font>
          <font color="#006400">
            <b>To set up a class library project to run a browser
when you debug it:<br /></b>
            <br />
1. Right-click on the project in the solution explorer and select properties<br />
2. Under Configuration Properties/Debugging, change Debug Mode from 'Project' to 'URL'<br />
3. Hit Apply<br />
4. In the Start URL field, enter the complete url to the page you want to hit to debug,
like:<br /><a href="http://localhost/testproj/webform1.aspx">http://localhost/testproj/webform1.aspx</a></font>
        </p>
        <img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=04cb6fac-5b8f-4e08-a626-2367446d9654" />
      </body>
      <title>Problems using Visual Studio.Net and Visual Source Safe with Web Projects</title>
      <guid isPermaLink="false">http://tim.mackey.ie/PermaLink,guid,04cb6fac-5b8f-4e08-a626-2367446d9654.aspx</guid>
      <link>http://tim.mackey.ie/ProblemsUsingVisualStudioNetAndVisualSourceSafeWithWebProjects.aspx</link>
      <pubDate>Sun, 19 Sep 2004 22:32:44 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font&gt;If you get annoyed at Visual Source Safe's complications with using asp.net
web projects, and integrating them with Visual Studio.Net, an increasingly popular
approach is to use 'class library' projects&amp;nbsp;instead of web projects.&amp;nbsp; (Of
course, this problem will disappear with Whidbey but i'm still using VS 2003). &amp;nbsp;A
web project compiles a dll / class library anyway, and&amp;nbsp;VS doesn't have to interact
with IIS to load the project.&amp;nbsp; It isn't hard to set up but it does require careful
instructions to be followed.&amp;nbsp;&amp;nbsp;A guy called Fritz Onion prepared the content
below: &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font&gt;This is copied/pasted here in case Fritz's link changes or disappears. The original
content is available from:&lt;br&gt;
&lt;/font&gt;&lt;a href="http://www.pluralsight.com/fritz/Samples/aspdotnet_without_web_projects.htm"&gt;http://www.pluralsight.com/fritz/Samples/aspdotnet_without_web_projects.htm&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#006400&gt;Reference prepared by &lt;/font&gt;&lt;a href="http://staff.develop.com/onion/"&gt;&lt;font color=#006400&gt;Fritz
Onion&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#006400&gt;The Web Project wizard in Visual Studio .NET is convenient for
creating quick ASP.NET applications on your local machine, but in an effort to simplify
your life, it also makes many decisions for you that are difficult to change if you
need more flexibility. My biggest pet peeve with Web Projects is that you cannot even
open a .sln file if the virtual directory mapping in IIS is not set up correctly.
I also dislike the way it places .sln and .csproj | .vbproj files in a separate location
from the actual source files (I understand that this is necessary to allow application
creation directly on a server, but I never deploy that way).&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#006400&gt;As a result, most of my web projects are created as standard class
library projects. Unfortunately this means that you don't get the nice Web component
wizards (like WebForms and UserControls). However, with a little tweaking, you can
have it all.&amp;nbsp; I have prepared this document describing how to enable these wizards
in class library projects (thanks to Dan Sullivan for pointing out how to do this),
as well as how to convert existing Web Projects to class library projects and still
keep the nice integrated debugging.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;&lt;font color=#006400&gt;To enable Web wizards in a class library project:&lt;/font&gt;&lt;/b&gt;&lt;u&gt;
&lt;br&gt;
&lt;/u&gt;
&lt;br&gt;
&lt;font color=#006400&gt;In a directory called&lt;br&gt;
&lt;br&gt;
C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\CSharpProjectItems\LocalProjectItems&lt;br&gt;
&lt;br&gt;
is a file callled localprojectitems.vsdir.&lt;br&gt;
&lt;br&gt;
Likewise in a directory&lt;br&gt;
&lt;br&gt;
C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\CSharpProjectItems\WebProjectItems&lt;br&gt;
&lt;br&gt;
is a file called webprojectitems.vsdir.&lt;br&gt;
&lt;br&gt;
If open the second file with notepad you can figure out the lines to copy to the first
file to be able to add the usual files you need to create an aspx page or web service
to a class lib project.&lt;br&gt;
&lt;br&gt;
Once you have copied these thing open VS, open a class lib and go to add new item
and you will see these additional file types available.&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color=#006400&gt;&lt;b&gt;To set the output of a class library project to go to
a /bin directory of your choosing:&lt;br&gt;
&lt;/b&gt;
&lt;br&gt;
1. Right-click on the project and select properties&lt;br&gt;
2. Set Configuration to 'All Configurations' to affect both debug and release builds&lt;br&gt;
3. Under configuration properties/build set the OutputPath to the /bin directory&lt;br&gt;
&amp;nbsp;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#006400&gt;&lt;b&gt;To convert an existing web project into a class library project:&lt;br&gt;
&lt;/b&gt;
&lt;br&gt;
1. Open the .sln file in a text editor, and change the reference to the project from
an http://... reference to a simple reference to the .csproj (or .vbproj) filename.
For example:&lt;br&gt;
change:&lt;br&gt;
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication133", "http://localhost/WebApplication133/WebApplication133.csproj",
"{39CB37A5-F735-4684-B5DA-DD355B683090}"&lt;br&gt;
&lt;br&gt;
to:&lt;br&gt;
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication133", "WebApplication133.csproj",
"{39CB37A5-F735-4684-B5DA-DD355B683090}"&lt;br&gt;
&lt;br&gt;
2. If there is one, delete the .webinfo file&lt;br&gt;
3. Open the .csproj (or .vbproj) file and change the ProjectType attribute from "Web"
to "Local"&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color=#006400&gt;&lt;b&gt;To set up a class library project to run a browser when
you debug it:&lt;br&gt;
&lt;/b&gt;
&lt;br&gt;
1. Right-click on the project in the solution explorer and select properties&lt;br&gt;
2. Under Configuration Properties/Debugging, change Debug Mode from 'Project' to 'URL'&lt;br&gt;
3. Hit Apply&lt;br&gt;
4. In the Start URL field, enter the complete url to the page you want to hit to debug,
like:&lt;br&gt;
&lt;a href="http://localhost/testproj/webform1.aspx"&gt;http://localhost/testproj/webform1.aspx&lt;/a&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://tim.mackey.ie/aggbug.ashx?id=04cb6fac-5b8f-4e08-a626-2367446d9654" /&gt;</description>
      <comments>http://tim.mackey.ie/CommentView,guid,04cb6fac-5b8f-4e08-a626-2367446d9654.aspx</comments>
      <category>.Net General</category>
    </item>
  </channel>
</rss>