<?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>Chris May</title>
    <link>http://chrismay.org/</link>
    <description>
	.Net Software and Web applications.  Server and network configuration.  Tech support. 
  </description>
    <language>en-us</language>
    <copyright>Christopher May, Inc</copyright>
    <lastBuildDate>Fri, 22 May 2009 21:41:28 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.6264.0</generator>
    <managingEditor>chris@christophermayinc.com</managingEditor>
    <webMaster>chris@christophermayinc.com</webMaster>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=33919de5-4194-451e-9fe2-b8d7b912ca45</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,33919de5-4194-451e-9fe2-b8d7b912ca45.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,33919de5-4194-451e-9fe2-b8d7b912ca45.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=33919de5-4194-451e-9fe2-b8d7b912ca45</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>Connection can not be established.  Server name, port number, or credentials
may be invalid.</strong>
        </p>
        <p>
I just got that message when trying to enter a perfectly valid set of connection/credential
info into an SSIS package.  But testing the connection failed.
</p>
        <p>
Turns out my issue, and maybe your issue too, is that SSIS doesn't remove white space
from the server name textbox.  So if you pasted in the name of the FTP server,
as I did, you might have fallen victim to the "trailing space" that is frequently
copied with your text, and instead of trying to connect to "ftp.com" it tried to connect
to "ftp.com " notice the extra space.
</p>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=33919de5-4194-451e-9fe2-b8d7b912ca45" />
      </body>
      <title>SSIS FTP Error</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,33919de5-4194-451e-9fe2-b8d7b912ca45.aspx</guid>
      <link>http://chrismay.org/2009/05/22/SSIS+FTP+Error.aspx</link>
      <pubDate>Fri, 22 May 2009 21:41:28 GMT</pubDate>
      <description>&lt;p&gt;
&lt;strong&gt;Connection can not be established.&amp;nbsp; Server name, port number, or credentials
may be invalid.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
I just got that message when trying to enter a perfectly valid set of connection/credential
info into an SSIS package.&amp;nbsp; But testing the connection failed.
&lt;/p&gt;
&lt;p&gt;
Turns out my issue, and maybe your issue too, is that SSIS doesn't remove white space
from the server name textbox.&amp;nbsp; So if you pasted in the name of the FTP server,
as I did, you might have fallen victim to the "trailing space" that is frequently
copied with your text, and instead of trying to connect to "ftp.com" it tried to connect
to "ftp.com " notice the extra space.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=33919de5-4194-451e-9fe2-b8d7b912ca45" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,33919de5-4194-451e-9fe2-b8d7b912ca45.aspx</comments>
      <category>Programming</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=87bc82c5-6346-4c64-8eeb-321c240fd207</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,87bc82c5-6346-4c64-8eeb-321c240fd207.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,87bc82c5-6346-4c64-8eeb-321c240fd207.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=87bc82c5-6346-4c64-8eeb-321c240fd207</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you are like me, you don't like the fact that the first time you realize that a
data driven subscriptions in SQL Server Reporting Services has been failing is when
someone comes up to you and says "Hey, I did XYZ and I never saw the server kick off
an email."  
</p>
        <p>
Really?  Let me check.... oh, looks like it has been broken for god knows how
long.  What the heck?
</p>
        <p>
Well, I wrote a script to notify you when there are errors on the report server.
</p>
        <p>
First, you need to setup Database Mail.  Expand Management, and pick Database
Mail.  For my script I used the name "Email Profile" for the "Email Profile"
get it?
</p>
        <p>
Then create a trigger on the ExecutionLogStorage table like this:
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">USE</span> [ReportServer]
GO <span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">/******
Object: Trigger [dbo].[ExecutionLogStorage_Insert] Script Date: 05/13/2009 10:20:44
******/</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SET</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ANSI_NULLS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ON</span> GO <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SET</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">QUOTED_IDENTIFIER</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ON</span> GO <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ALTER</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">TRIGGER</span> [dbo].[ExecutionLogStorage_Insert] <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ON</span> [dbo].[ExecutionLogStorage]
AFTER <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">INSERT</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BEGIN</span>     <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @sStatus <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">NVARCHAR</span>(32)
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SET</span> @sStatus
= (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> Status <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> inserted)
         <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">IF</span>(@sStatus
&lt;&gt; <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'rsSuccess'</span>)
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BEGIN</span>         <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @sReportName <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">NVARCHAR</span>(425)
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @sPath <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">NVARCHAR</span>(425)
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @ReportId <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">UNIQUEIDENTIFIER</span>         <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @sUserName <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">NVARCHAR</span>(260)
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @sParameters <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">NVARCHAR</span>(4000)
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @dTimeEnd <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DATETIME</span>         <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @iTimeProcessing <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span>         
                 <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span>         
@sReportName = Name,          @sPath =PATH,
         @ReportId = ReportId,         
@sUserName = username,          @sParameters
= (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">select</span><span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CAST</span>(<span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ISNULL</span>(ELS.Parameters,<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">''</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">NVARCHAR</span>(4000)) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">from</span> ExecutionLogStorage
ELS <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Where</span> LogEntryId
= Inserted.LogEntryId),          @dTimeEnd
= TimeEnd,          @iTimeProcessing = <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ISNULL</span>(TimeProcessing,0)
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> inserted <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">INNER</span><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">JOIN</span> [Catalog]
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ON</span> inserted.ReportId
= CATALOG.[ItemID]                  <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @sBody <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">VARCHAR</span>(8000)
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SET</span> @sBody
= <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Error
with SQL Report '</span>                     + <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CAST</span>(@sReportName <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">VARCHAR</span>(100))
                    + <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
at path '</span>                     + <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CAST</span> (@sPath <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">VARCHAR</span>(250))
                    + <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
with ReportId '</span>                     + <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CAST</span>(@ReportId <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">VARCHAR</span>(100))
                    + <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
and username '</span>                     + <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CAST</span>(@sUserName <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">VARCHAR</span>(100))
                    + <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Parameters '</span>                     + <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CAST</span>(@sParameters <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">VARCHAR</span>(5000))
                    + <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
End time '</span>                     + <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CAST</span>(@dTimeEnd <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">VARCHAR</span>(50))
                    + <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Status '</span>                     + <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CAST</span>(@sStatus <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">VARCHAR</span>(50))
                    + <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Time Processing '</span>                     + <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CAST</span>(@iTimeProcessing <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">VARCHAR</span>(50));
                 <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @sSubject <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">VARCHAR</span>(500)
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SET</span> @sSubject
= <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Error
With Report '</span> + @sReportName         
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">EXEC</span> msdb.dbo.sp_send_dbmail
         @profile_name = <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Email
Profile'</span>,          @recipients = <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'email@address.com'</span>,
         @body = @sBody ,         
@subject = @sSubject;     <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">END</span>      <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">END</span></span>
        </pre>
        <p>
Presto!
</p>
        <p>
 
</p>
        <p>
          <strong>UPDATE: Added logic to get the status and parameters.</strong>
        </p>
        <p>
 
</p>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=87bc82c5-6346-4c64-8eeb-321c240fd207" />
      </body>
      <title>Getting error reports when a SQL Reporting Subscription Fails</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,87bc82c5-6346-4c64-8eeb-321c240fd207.aspx</guid>
      <link>http://chrismay.org/2009/05/06/Getting+Error+Reports+When+A+SQL+Reporting+Subscription+Fails.aspx</link>
      <pubDate>Wed, 06 May 2009 21:55:06 GMT</pubDate>
      <description>&lt;p&gt;
If you are like me, you don't like the fact that the first time you realize that a
data driven subscriptions in SQL Server Reporting Services has been failing is when
someone comes up to you and says "Hey, I did XYZ and I never saw the server kick off
an email."&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Really?&amp;nbsp; Let me check.... oh, looks like it has been broken for god knows how
long.&amp;nbsp; What the heck?
&lt;/p&gt;
&lt;p&gt;
Well, I wrote a script to notify you when there are errors on the report server.
&lt;/p&gt;
&lt;p&gt;
First, you need to setup Database Mail.&amp;nbsp; Expand Management, and pick Database
Mail.&amp;nbsp; For my script I used the name "Email Profile" for the "Email Profile"
get it?
&lt;/p&gt;
&lt;p&gt;
Then create a trigger on the ExecutionLogStorage table like this:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;USE&lt;/span&gt; [ReportServer]
GO &lt;span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;/******
Object: Trigger [dbo].[ExecutionLogStorage_Insert] Script Date: 05/13/2009 10:20:44
******/&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SET&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ANSI_NULLS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ON&lt;/span&gt; GO &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SET&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;QUOTED_IDENTIFIER&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ON&lt;/span&gt; GO &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ALTER&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;TRIGGER&lt;/span&gt; [dbo].[ExecutionLogStorage_Insert] &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ON&lt;/span&gt; [dbo].[ExecutionLogStorage]
AFTER &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;INSERT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BEGIN&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @sStatus &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;NVARCHAR&lt;/span&gt;(32)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SET&lt;/span&gt; @sStatus
= (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; Status &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; inserted)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;IF&lt;/span&gt;(@sStatus
&amp;lt;&amp;gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'rsSuccess'&lt;/span&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BEGIN&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @sReportName &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;NVARCHAR&lt;/span&gt;(425)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @sPath &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;NVARCHAR&lt;/span&gt;(425)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @ReportId &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;UNIQUEIDENTIFIER&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @sUserName &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;NVARCHAR&lt;/span&gt;(260)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @sParameters &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;NVARCHAR&lt;/span&gt;(4000)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @dTimeEnd &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DATETIME&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @iTimeProcessing &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
@sReportName = Name, &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @sPath =PATH,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ReportId = ReportId, &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
@sUserName = username, &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @sParameters
= (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;select&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CAST&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ISNULL&lt;/span&gt;(ELS.Parameters,&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;''&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;NVARCHAR&lt;/span&gt;(4000)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;from&lt;/span&gt; ExecutionLogStorage
ELS &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Where&lt;/span&gt; LogEntryId
= Inserted.LogEntryId), &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @dTimeEnd
= TimeEnd, &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @iTimeProcessing = &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ISNULL&lt;/span&gt;(TimeProcessing,0)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; inserted &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;INNER&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;JOIN&lt;/span&gt; [Catalog]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ON&lt;/span&gt; inserted.ReportId
= CATALOG.[ItemID] &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;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @sBody &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;VARCHAR&lt;/span&gt;(8000)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SET&lt;/span&gt; @sBody
= &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Error
with SQL Report '&lt;/span&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+ &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CAST&lt;/span&gt;(@sReportName &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;VARCHAR&lt;/span&gt;(100))
&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;+ &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
at path '&lt;/span&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+ &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CAST&lt;/span&gt; (@sPath &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;VARCHAR&lt;/span&gt;(250))
&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;+ &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
with ReportId '&lt;/span&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+ &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CAST&lt;/span&gt;(@ReportId &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;VARCHAR&lt;/span&gt;(100))
&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;+ &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
and username '&lt;/span&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+ &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CAST&lt;/span&gt;(@sUserName &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;VARCHAR&lt;/span&gt;(100))
&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;+ &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Parameters '&lt;/span&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+ &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CAST&lt;/span&gt;(@sParameters &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;VARCHAR&lt;/span&gt;(5000))
&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;+ &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
End time '&lt;/span&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+ &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CAST&lt;/span&gt;(@dTimeEnd &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;VARCHAR&lt;/span&gt;(50))
&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;+ &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Status '&lt;/span&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+ &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CAST&lt;/span&gt;(@sStatus &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;VARCHAR&lt;/span&gt;(50))
&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;+ &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Time Processing '&lt;/span&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;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+ &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CAST&lt;/span&gt;(@iTimeProcessing &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;VARCHAR&lt;/span&gt;(50));
&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;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @sSubject &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;VARCHAR&lt;/span&gt;(500)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SET&lt;/span&gt; @sSubject
= &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Error
With Report '&lt;/span&gt; + @sReportName &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;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;EXEC&lt;/span&gt; msdb.dbo.sp_send_dbmail
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @profile_name = &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Email
Profile'&lt;/span&gt;, &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @recipients = &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'email@address.com'&lt;/span&gt;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @body = @sBody , &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
@subject = @sSubject; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;END&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;END&lt;/span&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Presto!
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;UPDATE: Added logic to get the status and parameters.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=87bc82c5-6346-4c64-8eeb-321c240fd207" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,87bc82c5-6346-4c64-8eeb-321c240fd207.aspx</comments>
      <category>Programming;Programming/.Net;Programming/Database;Programming/Database/SQL Server;Programming/Database/T-Sql;Programming/Reporting</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=f0bec023-2d3d-4af2-9c6a-47462df5d795</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,f0bec023-2d3d-4af2-9c6a-47462df5d795.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,f0bec023-2d3d-4af2-9c6a-47462df5d795.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=f0bec023-2d3d-4af2-9c6a-47462df5d795</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm working on something where I wanted to know if some parameters to a SQL Server
Stored Procedure were nullable (or, in otherwords, if they had a default value).
</p>
        <p>
The API I was working with provided a way to find info about the SP, but the
isNullable value was never accurate.
</p>
        <p>
I tried working with with the MS DAABs which have a way to fetch SP parameter
info, but this method also produced faulty information.
</p>
        <p>
Looking into the code of the DAAB, it was internally calling:
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">command</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> SqlCommand
SqlCommandBuilder.DeriveParameters(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">command</span>) </span>
        </pre>
        <br />
        <p>
Somewhere I came across some code for the DeriveParameters method (I think from the
Mono project maybe?) which showed it calling this system SP:
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">sp_procedure_params_rowset</span>
        </pre>
        <p>
Which returns output fields,:
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PARAMETER_HASDEFAULT<br /><br />
IS_NULLABLE</span>
        </pre>
        <p>
But, again, neither of these appear correctly.
</p>
        <p>
However, I finally came across this thread where a MSFT poster indicates that this
data is simply not available:
</p>
        <p>
          <a href="http://social.msdn.microsoft.com/forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c/">http://social.msdn.microsoft.com/forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c/</a>
        </p>
        <p>
Instead, you need to parse the SP definition to see what the default parameter value
is, which is a pain, but at least I know why these other methods kept not working.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=f0bec023-2d3d-4af2-9c6a-47462df5d795" />
      </body>
      <title>Finding if SP Parameters are Nullable</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,f0bec023-2d3d-4af2-9c6a-47462df5d795.aspx</guid>
      <link>http://chrismay.org/2009/04/26/Finding+If+SP+Parameters+Are+Nullable.aspx</link>
      <pubDate>Sun, 26 Apr 2009 03:55:55 GMT</pubDate>
      <description>&lt;p&gt;
I'm working on something where I wanted to know if some parameters to a SQL Server
Stored Procedure were nullable (or, in otherwords, if they had a default value).
&lt;/p&gt;
&lt;p&gt;
The API I was working with provided a way to find info about&amp;nbsp;the SP, but the
isNullable value was never accurate.
&lt;/p&gt;
&lt;p&gt;
I tried working with with the MS DAABs which have a way to fetch&amp;nbsp;SP parameter
info, but this method also produced faulty information.
&lt;/p&gt;
&lt;p&gt;
Looking into the code of the DAAB, it was internally calling:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;command&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; SqlCommand
SqlCommandBuilder.DeriveParameters(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;command&lt;/span&gt;) &lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
&lt;p&gt;
Somewhere I came across some code for the DeriveParameters method (I think from the
Mono project maybe?) which showed it calling this system SP:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;sp_procedure_params_rowset&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Which returns output fields,:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PARAMETER_HASDEFAULT&lt;br&gt;
&lt;br&gt;
IS_NULLABLE&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
But, again, neither of these appear correctly.
&lt;/p&gt;
&lt;p&gt;
However, I finally came across this thread where a MSFT poster indicates that this
data is simply not available:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://social.msdn.microsoft.com/forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c/"&gt;http://social.msdn.microsoft.com/forums/en-US/transactsql/thread/900756fd-3980-48e3-ae59-a15d7fc15b4c/&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Instead, you need to parse the SP definition to see what the default parameter value
is, which is a pain, but at least I know why these other methods kept not working.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=f0bec023-2d3d-4af2-9c6a-47462df5d795" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,f0bec023-2d3d-4af2-9c6a-47462df5d795.aspx</comments>
      <category>Programming;Programming/Database;Programming/Database/SQL Server;Programming/Database/T-Sql</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=149a6f78-5c95-4234-a79b-9107755ab1aa</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,149a6f78-5c95-4234-a79b-9107755ab1aa.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,149a6f78-5c95-4234-a79b-9107755ab1aa.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=149a6f78-5c95-4234-a79b-9107755ab1aa</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of the challenges of using code generation is to avoid overwriting your custom
changes when you re-generate the code later.
</p>
        <p>
This is a trick I am using to avoid overwriting my stored procedures if I update them
manually.  The trick is to include a comment indicating that the SP has been
code generated, and then to remove that comment if you update the SP.  So lets
say that you generate:
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CREATE</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PROCEDURE</span> OrderDetails_Get
@OrderId <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">--
CODE GENERATED</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> * <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> OrderDetails <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span> OrderId
= @OrderId</span>
        </pre>
        <p>
and you made some customizations to the SP so it now looks like this:
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CREATE</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PROCEDURE</span> OrderDetails_Get
@OrderId <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> * <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> OrderDetails <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">INNER</span><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">JOIN</span> Orders <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ON</span> Orders.OrderId
= OrderDetails.OrderId <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span> OrderId
= @OrderId</span>
        </pre>
        <p>
          <font face="Courier New" color="#000000">The following code will help you when generating
your SPs to avoid overwriting this change:</font>
        </p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">IF</span>
            <span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">EXISTS</span>( <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> [definition] <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span> objectText <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> sys.sql_modules <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span> [<span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object_id</span>]
= <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">OBJECT_ID</span>(N<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'OrderDetails_Get'</span>, <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'P'</span>) <span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AND</span> definition <span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">LIKE</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'%CODE
GENERATED%'</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BEGIN</span><span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">--
overwrite is ok</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">END</span></span>
        </pre>
        <p>
 
</p>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=149a6f78-5c95-4234-a79b-9107755ab1aa" />
      </body>
      <title>Avoid Overwriting Modified SPs With Code Generation</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,149a6f78-5c95-4234-a79b-9107755ab1aa.aspx</guid>
      <link>http://chrismay.org/2009/04/18/Avoid+Overwriting+Modified+SPs+With+Code+Generation.aspx</link>
      <pubDate>Sat, 18 Apr 2009 14:37:55 GMT</pubDate>
      <description>&lt;p&gt;
One of the challenges of using code generation is to avoid overwriting your custom
changes when you re-generate the code later.
&lt;/p&gt;
&lt;p&gt;
This is a trick I am using to avoid overwriting my stored procedures if I update them
manually.&amp;nbsp; The trick is to include a comment indicating that the SP has been
code generated, and then to remove that comment if you update the SP.&amp;nbsp; So lets
say that you generate:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CREATE&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PROCEDURE&lt;/span&gt; OrderDetails_Get
@OrderId &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;--
CODE GENERATED&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; * &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; OrderDetails &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt; OrderId
= @OrderId&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
and you made some customizations to the SP so it now looks like this:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CREATE&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PROCEDURE&lt;/span&gt; OrderDetails_Get
@OrderId &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; * &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; OrderDetails &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;INNER&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;JOIN&lt;/span&gt; Orders &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ON&lt;/span&gt; Orders.OrderId
= OrderDetails.OrderId &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt; OrderId
= @OrderId&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font face="Courier New" color=#000000&gt;The following code will help you when generating
your SPs to avoid overwriting this change:&lt;/font&gt;
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;IF&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;EXISTS&lt;/span&gt;( &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; [definition] &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt; objectText &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; sys.sql_modules &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt; [&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object_id&lt;/span&gt;]
= &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;OBJECT_ID&lt;/span&gt;(N&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'OrderDetails_Get'&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'P'&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AND&lt;/span&gt; definition &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;LIKE&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'%CODE
GENERATED%'&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BEGIN&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;--
overwrite is ok&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;END&lt;/span&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=149a6f78-5c95-4234-a79b-9107755ab1aa" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,149a6f78-5c95-4234-a79b-9107755ab1aa.aspx</comments>
      <category>Programming;Programming/Database;Programming/Database/SQL Server;Programming/Database/T-Sql</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=93b017d8-877b-4fdf-b98e-5d935f835c73</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,93b017d8-877b-4fdf-b98e-5d935f835c73.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,93b017d8-877b-4fdf-b98e-5d935f835c73.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=93b017d8-877b-4fdf-b98e-5d935f835c73</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Do you frequently get ConnectionError1 when using Mozy?
</p>
        <p>
Try this: change your scheduled backup time to something more random than 2:00am. 
Try 2:09 or 2:41.
</p>
        <p>
It's that simple.
</p>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=93b017d8-877b-4fdf-b98e-5d935f835c73" />
      </body>
      <title>Mozy ConnectionError1</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,93b017d8-877b-4fdf-b98e-5d935f835c73.aspx</guid>
      <link>http://chrismay.org/2009/04/09/Mozy+ConnectionError1.aspx</link>
      <pubDate>Thu, 09 Apr 2009 14:13:51 GMT</pubDate>
      <description>&lt;p&gt;
Do you frequently get ConnectionError1 when using Mozy?
&lt;/p&gt;
&lt;p&gt;
Try this: change your scheduled backup time to something more random than 2:00am.&amp;nbsp;
Try 2:09 or 2:41.
&lt;/p&gt;
&lt;p&gt;
It's that simple.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=93b017d8-877b-4fdf-b98e-5d935f835c73" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,93b017d8-877b-4fdf-b98e-5d935f835c73.aspx</comments>
      <category>Misc</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=23219b10-ccac-425e-a9f0-0709ed3c96a6</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,23219b10-ccac-425e-a9f0-0709ed3c96a6.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,23219b10-ccac-425e-a9f0-0709ed3c96a6.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=23219b10-ccac-425e-a9f0-0709ed3c96a6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
My lenovo came with Sierra Wireless MC5725 for use with Verizon's EVDO network.
</p>
        <p>
VZAccess manager (Verizons POS software) told me today that there was a firmware update
for my Sierra Wireless device.
</p>
        <p>
This update failed, and now my device won't work.  I basically can't enable the
device.  It doen't show up in my network list, and I can't turn it on using the
fn+F5 screen.
</p>
        <p>
Where can I get the firmware for this thing?  Sierra Wireless says they don't
support these OEM devices, and Lenovo has nothing regarding firmware on their site,
only drivers.
</p>
        <p>
VZAccess Manager is one of the worst pieces of software I have ever had the chance
to work with.  It never stops suprising me how crappy it can be, and yet I am
still forced to use it every day.  I hate Verizon for doing this to me.
</p>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=23219b10-ccac-425e-a9f0-0709ed3c96a6" />
      </body>
      <title>I hate Verizon</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,23219b10-ccac-425e-a9f0-0709ed3c96a6.aspx</guid>
      <link>http://chrismay.org/2009/04/09/I+Hate+Verizon.aspx</link>
      <pubDate>Thu, 09 Apr 2009 06:17:15 GMT</pubDate>
      <description>&lt;p&gt;
My lenovo came with Sierra Wireless MC5725 for use with Verizon's EVDO network.
&lt;/p&gt;
&lt;p&gt;
VZAccess manager (Verizons POS software) told me today that there was a firmware update
for my Sierra Wireless device.
&lt;/p&gt;
&lt;p&gt;
This update failed, and now my device won't work.&amp;nbsp; I basically can't enable the
device.&amp;nbsp; It doen't show up in my network list, and I can't turn it on using the
fn+F5 screen.
&lt;/p&gt;
&lt;p&gt;
Where can I get the firmware for this thing?&amp;nbsp; Sierra Wireless says they don't
support these OEM devices, and Lenovo has nothing regarding firmware on their site,
only drivers.
&lt;/p&gt;
&lt;p&gt;
VZAccess Manager is one of the worst pieces of software I have ever had the chance
to work with.&amp;nbsp; It never stops suprising me how crappy it can be, and yet I am
still forced to use it every day.&amp;nbsp; I hate Verizon for doing this to me.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=23219b10-ccac-425e-a9f0-0709ed3c96a6" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,23219b10-ccac-425e-a9f0-0709ed3c96a6.aspx</comments>
      <category>Misc</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=70a24aa8-378d-4a56-9d8d-521588fbf59f</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,70a24aa8-378d-4a56-9d8d-521588fbf59f.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,70a24aa8-378d-4a56-9d8d-521588fbf59f.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=70a24aa8-378d-4a56-9d8d-521588fbf59f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have written before about some of the problems that a frequently recycling asp.net
application can cause, espically if you are using session for anything.
</p>
        <p>
          <a href="http://chrismay.org/2007/04/11/ASPNET+Process+Recycling+Too+Often.aspx">ASP.NET
Process Recycling Too Often</a>
        </p>
        <p>
But I ran into a situation where the recycle was caused by the application itself
for a client of mine.  I had bought and customized a asp.net application that
allows my client to give THEIR clients access to a section of their site where they
can upload/download/manage files very nicely.  But after moving to a new hosting
environment, users kept losing their login sessions very quickly.
</p>
        <p>
After some research, I found out that session was being used to track if the user
was logged in, and session was being lost very quickly because the application was
recycling.
</p>
        <p>
I used the following code to help diagnose the cause for the application restarting:
</p>
        <p>
(this goes in Application_End)
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> runtime <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> HttpRuntime <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">GetType</span>(System.Web.HttpRuntime).InvokeMember(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"_theRuntime"</span>,
_ BindingFlags.NonPublic <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> _
BindingFlags.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Static</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> _
BindingFlags.GetField, _ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span> runtime <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Is</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span> logger.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Error</span>(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"The
application is closing at "</span> &amp; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Now</span>.ToShortDateString
&amp; <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"
"</span> &amp; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Now</span>.ToLongTimeString) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Return</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> shutDownMessage <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> runtime.GetType().InvokeMember(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"_shutDownMessage"</span>,
BindingFlags.NonPublic <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.Instance <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.GetField, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>,
runtime, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>) <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'If
shutDownMessage = "HostingEnvironment caused shutdown" Then</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
'*** this is normal, you can include this commented out section or not</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Return</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'End
If</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> shutDownStack <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> runtime.GetType().InvokeMember(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"_shutDownStack"</span>,
BindingFlags.NonPublic <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.Instance <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.GetField, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>,
runtime, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>) <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'***
email this error</span> logger.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Error</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span>.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Format</span>(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"The
application is closing at "</span> &amp; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Now</span>.ToShortDateString
&amp; <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"
"</span> &amp; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Now</span>.ToLongTimeString
&amp; <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"
"</span> &amp; vbCrLf &amp; vbCrLf &amp; <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"_shutDownMessage={0}"</span> &amp;
vbCrLf &amp; vbCrLf &amp; <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"_shutDownStack={1}"</span>,
shutDownMessage, shutDownStack)) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">log</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> EventLog <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">log</span>.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Source</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">".NET
Runtime"</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">log</span>.WriteEntry(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span>.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Format</span>(vbCrLf
&amp; vbCrLf &amp; <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"_shutDownMessage={0}"</span> &amp;
vbCrLf &amp; vbCrLf &amp; <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"_shutDownStack={1}"</span>,
shutDownMessage, shutDownStack), EventLogEntryType.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Error</span>) </span>
        </pre>
        <p>
The cause was:
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Directory
rename change notification for 'APP PATH HERE. Clients dir change or directory rename
HostingEnvironment caused shutdown </span>
        </pre>
        <p>
Because this app was now hosted with a 3rd party, I didn't have control over the environment
to go see if there was an AV scanner or backup manager running that was touching the
files.
</p>
        <p>
However, I because I was able to reproduce the error in my dev environment, I was
confident I could rule out those causes.
</p>
        <p>
I eventually found that the problem was 2 fold:
</p>
        <p>
1) The application allows the user to upload files/create folders that reside in subfolders
of the application.  The app could think these changes require a recycle.
</p>
        <p>
2) The application creates a temp folder for the user for each session under the root
as well.  Changing folder structure can cause a recycle.
</p>
        <p>
So what can be done?
</p>
        <p>
Well, I adapted some code from a few places to turn off the FCN (File change notifications)
for sub directories of the website.  This isn't easy to do if you don't have
something to go off of, becaues you basically have to hijack your way into private
methods on classes in the .net framework, using reflection to call methods that you
shouldn't be accessing, in order to turn off specific behavior.
</p>
        <p>
Here are the methods I created to help me do this.  I also have some log4net
code in here, so you'll have to pull that out if you want to use this.
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> TurnOffDirectoryMonitoring() <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> p <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.Reflection.PropertyInfo <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">GetType</span>(System.Web.HttpRuntime).GetProperty(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"FileChangesMonitor"</span>,
BindingFlags.NonPublic <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Static</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> o <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> p.GetValue(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> f <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> FieldInfo <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> o.GetType.GetField(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"_dirMonSubdirs"</span>,
BindingFlags.Instance <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.NonPublic <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.IgnoreCase) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> monitor <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> f.GetValue(o) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> asdf <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.Reflection.MethodInfo() <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> monitor.GetType.GetMethods() <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> propIsMonitoring <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.Reflection.MethodInfo <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> monitor.GetType.GetMethod(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"IsMonitoring"</span>,
System.Reflection.BindingFlags.Instance <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> System.Reflection.BindingFlags.NonPublic) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> bIsMonitoring <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Boolean</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> propIsMonitoring.Invoke(monitor, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> logger <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> log4net.ILog <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> log4net.LogManager.GetLogger(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"File"</span>)
logger.Info(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Directory
monitoring IsMonitoring was "</span> &amp; bIsMonitoring) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> m <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.Reflection.MethodInfo <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> monitor.GetType.GetMethod(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"StopMonitoring"</span>,
System.Reflection.BindingFlags.Instance <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> System.Reflection.BindingFlags.NonPublic) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> objArray() <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> {}
m.Invoke(monitor, objArray) logger.Info(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Directory
monitoring IsMonitoring after change is "</span> &amp; bIsMonitoring) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Catch</span> ex <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Exception <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> logger <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> log4net.ILog <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> log4net.LogManager.GetLogger(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"File"</span>)
logger.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Error</span>(ex) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> CheckDirectoryMonitoring() <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> p <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.Reflection.PropertyInfo <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">GetType</span>(System.Web.HttpRuntime).GetProperty(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"FileChangesMonitor"</span>,
BindingFlags.NonPublic <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Static</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> o <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> p.GetValue(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> f <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> FieldInfo <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> o.GetType.GetField(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"_dirMonSubdirs"</span>,
BindingFlags.Instance <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.NonPublic <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.IgnoreCase) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> monitor <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> f.GetValue(o) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> asdf <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.Reflection.MethodInfo() <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> monitor.GetType.GetMethods() <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> propIsMonitoring <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.Reflection.MethodInfo <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> monitor.GetType.GetMethod(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"IsMonitoring"</span>,
System.Reflection.BindingFlags.Instance <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> System.Reflection.BindingFlags.NonPublic) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> bIsMonitoring <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Boolean</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> propIsMonitoring.Invoke(monitor, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> logger <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> log4net.ILog <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> log4net.LogManager.GetLogger(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"File"</span>)
logger.Info(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"In
CheckDirectoryMonitoring, Directory monitoring IsMonitoring is "</span> &amp; bIsMonitoring) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Catch</span> ex <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Exception <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> logger <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> log4net.ILog <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> log4net.LogManager.GetLogger(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"File"</span>)
logger.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Error</span>(ex) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> CheckFCNMode() <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> p <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.Reflection.PropertyInfo <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">GetType</span>(System.Web.HttpRuntime).GetProperty(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"FileChangesMonitor"</span>,
BindingFlags.NonPublic <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Static</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> o <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> p.GetValue(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> f <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> FieldInfo <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> o.GetType.GetField(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"_FCNMode"</span>,
BindingFlags.Instance <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.NonPublic <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Or</span> BindingFlags.IgnoreCase) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> iFCNMode <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> f.GetValue(o) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> logger <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> log4net.ILog <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> log4net.LogManager.GetLogger(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"File"</span>)
logger.Info(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"In
CheckFCNMode, FCNMode is "</span> &amp; iFCNMode) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Catch</span> ex <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Exception <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> logger <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> log4net.ILog <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> log4net.LogManager.GetLogger(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"File"</span>)
logger.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Error</span>(ex) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span></span>
        </pre>
        <p>
These methods are not refactored or "best practice" at all, there is a lot of copy/paste
code in here, but you'll get the idea of what I'm doing.
</p>
        <p>
You can call these methods from the beginning on Application_Start.  
</p>
        <p>
1 thing to note.  I found that my code that checks to make sure that logging
was turned off, doesn't seem to report the right value the first time I check it. 
But by the time the first session starts, it has indeed stopped monitoring.
</p>
        <p>
Just try calling these methods from a few places after application_start and you can
see what happens.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=70a24aa8-378d-4a56-9d8d-521588fbf59f" />
      </body>
      <title>ASP.NET Apps Recycling Because of FCN Issues</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,70a24aa8-378d-4a56-9d8d-521588fbf59f.aspx</guid>
      <link>http://chrismay.org/2009/04/02/ASPNET+Apps+Recycling+Because+Of+FCN+Issues.aspx</link>
      <pubDate>Thu, 02 Apr 2009 18:27:04 GMT</pubDate>
      <description>&lt;p&gt;
I have written before about some of the problems that a frequently recycling asp.net
application can cause, espically if you are using session for anything.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://chrismay.org/2007/04/11/ASPNET+Process+Recycling+Too+Often.aspx"&gt;ASP.NET
Process Recycling Too Often&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
But I ran into a situation where the recycle was caused by the application itself
for a client of mine.&amp;nbsp; I had bought and customized a asp.net application that
allows my client to give THEIR clients access to a section of their site where they
can upload/download/manage files very nicely.&amp;nbsp; But after moving to a new hosting
environment, users kept losing their login sessions very quickly.
&lt;/p&gt;
&lt;p&gt;
After some research, I found out that session was being used to track if the user
was logged in, and session was being lost very quickly because the application was
recycling.
&lt;/p&gt;
&lt;p&gt;
I used the following code to help diagnose the cause for the application restarting:
&lt;/p&gt;
&lt;p&gt;
(this goes in Application_End)
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; runtime &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; HttpRuntime &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;GetType&lt;/span&gt;(System.Web.HttpRuntime).InvokeMember(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"_theRuntime"&lt;/span&gt;,
_ BindingFlags.NonPublic &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; _
BindingFlags.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; _
BindingFlags.GetField, _ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; runtime &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Is&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt; logger.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Error&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"The
application is closing at "&lt;/span&gt; &amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Now&lt;/span&gt;.ToShortDateString
&amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"
"&lt;/span&gt; &amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Now&lt;/span&gt;.ToLongTimeString) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Return&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; shutDownMessage &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; runtime.GetType().InvokeMember(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"_shutDownMessage"&lt;/span&gt;,
BindingFlags.NonPublic &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.Instance &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.GetField, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;,
runtime, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'If
shutDownMessage = "HostingEnvironment caused shutdown" Then&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
'*** this is normal, you can include this commented out section or not&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Return&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'End
If&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; shutDownStack &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; runtime.GetType().InvokeMember(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"_shutDownStack"&lt;/span&gt;,
BindingFlags.NonPublic &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.Instance &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.GetField, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;,
runtime, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'***
email this error&lt;/span&gt; logger.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Error&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Format&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"The
application is closing at "&lt;/span&gt; &amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Now&lt;/span&gt;.ToShortDateString
&amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"
"&lt;/span&gt; &amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Now&lt;/span&gt;.ToLongTimeString
&amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"
"&lt;/span&gt; &amp;amp; vbCrLf &amp;amp; vbCrLf &amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"_shutDownMessage={0}"&lt;/span&gt; &amp;amp;
vbCrLf &amp;amp; vbCrLf &amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"_shutDownStack={1}"&lt;/span&gt;,
shutDownMessage, shutDownStack)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;log&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; EventLog &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;log&lt;/span&gt;.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Source&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;".NET
Runtime"&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;log&lt;/span&gt;.WriteEntry(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Format&lt;/span&gt;(vbCrLf
&amp;amp; vbCrLf &amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"_shutDownMessage={0}"&lt;/span&gt; &amp;amp;
vbCrLf &amp;amp; vbCrLf &amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"_shutDownStack={1}"&lt;/span&gt;,
shutDownMessage, shutDownStack), EventLogEntryType.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Error&lt;/span&gt;) &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
The cause was:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Directory
rename change notification for 'APP PATH HERE. Clients dir change or directory rename
HostingEnvironment caused shutdown &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Because this app was now hosted with a 3rd party, I didn't have control over the environment
to go see if there was an AV scanner or backup manager running that was touching the
files.
&lt;/p&gt;
&lt;p&gt;
However, I because I was able to reproduce the error in my dev environment, I was
confident I could rule out those causes.
&lt;/p&gt;
&lt;p&gt;
I eventually found that the problem was 2 fold:
&lt;/p&gt;
&lt;p&gt;
1) The application allows the user to upload files/create folders that reside in subfolders
of the application.&amp;nbsp; The app could think these changes require a recycle.
&lt;/p&gt;
&lt;p&gt;
2) The application creates a temp folder for the user for each session under the root
as well.&amp;nbsp; Changing folder structure can cause a recycle.
&lt;/p&gt;
&lt;p&gt;
So what can be done?
&lt;/p&gt;
&lt;p&gt;
Well, I adapted some code from a few places to turn off the FCN (File change notifications)
for sub directories of the website.&amp;nbsp; This isn't easy to do if you don't have
something to go off of, becaues you basically have to hijack your way into private
methods on classes in the .net framework, using reflection to call methods that you
shouldn't be accessing, in order to turn off specific behavior.
&lt;/p&gt;
&lt;p&gt;
Here are the methods I created to help me do this.&amp;nbsp; I also have some log4net
code in here, so you'll have to pull that out if you want to use this.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; TurnOffDirectoryMonitoring() &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; p &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.Reflection.PropertyInfo &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;GetType&lt;/span&gt;(System.Web.HttpRuntime).GetProperty(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"FileChangesMonitor"&lt;/span&gt;,
BindingFlags.NonPublic &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Static&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; o &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; p.GetValue(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; f &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; FieldInfo &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; o.GetType.GetField(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"_dirMonSubdirs"&lt;/span&gt;,
BindingFlags.Instance &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.NonPublic &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.IgnoreCase) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; monitor &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; f.GetValue(o) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; asdf &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.Reflection.MethodInfo() &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; monitor.GetType.GetMethods() &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; propIsMonitoring &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.Reflection.MethodInfo &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; monitor.GetType.GetMethod(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"IsMonitoring"&lt;/span&gt;,
System.Reflection.BindingFlags.Instance &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; System.Reflection.BindingFlags.NonPublic) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; bIsMonitoring &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Boolean&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; propIsMonitoring.Invoke(monitor, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; logger &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; log4net.ILog &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; log4net.LogManager.GetLogger(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"File"&lt;/span&gt;)
logger.Info(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Directory
monitoring IsMonitoring was "&lt;/span&gt; &amp;amp; bIsMonitoring) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; m &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.Reflection.MethodInfo &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; monitor.GetType.GetMethod(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"StopMonitoring"&lt;/span&gt;,
System.Reflection.BindingFlags.Instance &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; System.Reflection.BindingFlags.NonPublic) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; objArray() &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; {}
m.Invoke(monitor, objArray) logger.Info(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Directory
monitoring IsMonitoring after change is "&lt;/span&gt; &amp;amp; bIsMonitoring) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Catch&lt;/span&gt; ex &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Exception &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; logger &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; log4net.ILog &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; log4net.LogManager.GetLogger(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"File"&lt;/span&gt;)
logger.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Error&lt;/span&gt;(ex) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; CheckDirectoryMonitoring() &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; p &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.Reflection.PropertyInfo &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;GetType&lt;/span&gt;(System.Web.HttpRuntime).GetProperty(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"FileChangesMonitor"&lt;/span&gt;,
BindingFlags.NonPublic &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Static&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; o &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; p.GetValue(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; f &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; FieldInfo &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; o.GetType.GetField(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"_dirMonSubdirs"&lt;/span&gt;,
BindingFlags.Instance &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.NonPublic &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.IgnoreCase) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; monitor &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; f.GetValue(o) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; asdf &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.Reflection.MethodInfo() &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; monitor.GetType.GetMethods() &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; propIsMonitoring &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.Reflection.MethodInfo &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; monitor.GetType.GetMethod(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"IsMonitoring"&lt;/span&gt;,
System.Reflection.BindingFlags.Instance &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; System.Reflection.BindingFlags.NonPublic) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; bIsMonitoring &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Boolean&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; propIsMonitoring.Invoke(monitor, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; logger &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; log4net.ILog &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; log4net.LogManager.GetLogger(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"File"&lt;/span&gt;)
logger.Info(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"In
CheckDirectoryMonitoring, Directory monitoring IsMonitoring is "&lt;/span&gt; &amp;amp; bIsMonitoring) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Catch&lt;/span&gt; ex &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Exception &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; logger &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; log4net.ILog &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; log4net.LogManager.GetLogger(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"File"&lt;/span&gt;)
logger.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Error&lt;/span&gt;(ex) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; CheckFCNMode() &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; p &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.Reflection.PropertyInfo &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;GetType&lt;/span&gt;(System.Web.HttpRuntime).GetProperty(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"FileChangesMonitor"&lt;/span&gt;,
BindingFlags.NonPublic &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Static&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; o &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; p.GetValue(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; f &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; FieldInfo &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; o.GetType.GetField(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"_FCNMode"&lt;/span&gt;,
BindingFlags.Instance &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.NonPublic &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Or&lt;/span&gt; BindingFlags.IgnoreCase) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; iFCNMode &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; f.GetValue(o) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; logger &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; log4net.ILog &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; log4net.LogManager.GetLogger(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"File"&lt;/span&gt;)
logger.Info(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"In
CheckFCNMode, FCNMode is "&lt;/span&gt; &amp;amp; iFCNMode) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Catch&lt;/span&gt; ex &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Exception &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; logger &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; log4net.ILog &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; log4net.LogManager.GetLogger(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"File"&lt;/span&gt;)
logger.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Error&lt;/span&gt;(ex) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
These methods are not refactored or "best practice" at all, there is a lot of copy/paste
code in here, but you'll get the idea of what I'm doing.
&lt;/p&gt;
&lt;p&gt;
You can call these methods from the beginning on Application_Start.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
1 thing to note.&amp;nbsp; I found that my code that checks to make sure that logging
was turned off, doesn't seem to report the right value the first time I check it.&amp;nbsp;
But by the time the first session starts, it has indeed stopped monitoring.
&lt;/p&gt;
&lt;p&gt;
Just try calling these methods from a few places after application_start and you can
see what happens.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=70a24aa8-378d-4a56-9d8d-521588fbf59f" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,70a24aa8-378d-4a56-9d8d-521588fbf59f.aspx</comments>
      <category>Programming;Programming/.Net;Programming/.Net/ASP.Net</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=cab7ccda-c9ea-4e42-b8a3-e5c5097610f9</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,cab7ccda-c9ea-4e42-b8a3-e5c5097610f9.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,cab7ccda-c9ea-4e42-b8a3-e5c5097610f9.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=cab7ccda-c9ea-4e42-b8a3-e5c5097610f9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Rocky Lhotka had this over on his site:
</p>
        <div class="ForumPostTitleArea">
          <h4 class="ForumPostTitle">The Golden Rule of Windows Forms data binding 
</h4>
          <p class="ForumPostTitle">
            <strong>
              <em>Never directly interact with a business object while it is data bound
- only interact with the bindingsource</em>
            </strong>
          </p>
          <p>
            <a href="http://forums.lhotka.net/forums/thread/22990.aspx">http://forums.lhotka.net/forums/thread/22990.aspx</a>
          </p>
          <p>
I have to say, I am guilty of doing this, and I didn't even know it was considered
a bad practice, but I do recall running into problems with the behavior in getting
the UI to refresh as I would want it to.
</p>
        </div>
        <div>
        </div>
        <div>
        </div>
        <div>I also found a nice article talking about how to speed up binding to the datagrid:
</div>
        <div>
          <a href="http://forums.lhotka.net/forums/thread/15747.aspx">http://forums.lhotka.net/forums/thread/15747.aspx</a>
        </div>
        <div>
          <a href="http://msdn.microsoft.com/en-us/library/ha5xt0d9.aspx">http://msdn.microsoft.com/en-us/library/ha5xt0d9.aspx</a>
        </div>
        <div> 
</div>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=cab7ccda-c9ea-4e42-b8a3-e5c5097610f9" />
      </body>
      <title>Golden Rule of Winform Databinding</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,cab7ccda-c9ea-4e42-b8a3-e5c5097610f9.aspx</guid>
      <link>http://chrismay.org/2009/03/23/Golden+Rule+Of+Winform+Databinding.aspx</link>
      <pubDate>Mon, 23 Mar 2009 21:08:22 GMT</pubDate>
      <description>&lt;p&gt;
Rocky Lhotka had this over on his site:
&lt;/p&gt;
&lt;div class=ForumPostTitleArea&gt;
&lt;h4 class=ForumPostTitle&gt;The Golden Rule of Windows Forms data binding 
&lt;/h4&gt;
&lt;p class=ForumPostTitle&gt;
&lt;strong&gt;&lt;em&gt;Never directly interact with a business object while it is data bound
- only interact with the bindingsource&lt;/em&gt;&lt;/strong&gt;
&lt;/p&gt;
&gt;&gt; 
&lt;p&gt;
&lt;a href="http://forums.lhotka.net/forums/thread/22990.aspx"&gt;http://forums.lhotka.net/forums/thread/22990.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
I have to say, I am guilty of doing this, and I didn't even know it was considered
a bad practice, but I do recall running into problems with the behavior in getting
the UI to refresh as I would want it to.
&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&gt;
&gt;
&gt;&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;I also found a nice article talking about how to speed up binding to the datagrid:
&lt;/div&gt;
&lt;div&gt;&lt;a href="http://forums.lhotka.net/forums/thread/15747.aspx"&gt;http://forums.lhotka.net/forums/thread/15747.aspx&lt;/a&gt;
&lt;/div&gt;
&lt;div&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ha5xt0d9.aspx"&gt;http://msdn.microsoft.com/en-us/library/ha5xt0d9.aspx&lt;/a&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=cab7ccda-c9ea-4e42-b8a3-e5c5097610f9" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,cab7ccda-c9ea-4e42-b8a3-e5c5097610f9.aspx</comments>
      <category>Programming;Programming/.Net;Programming/.Net/WinForms</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=961dd1f1-fef0-458e-ae04-f73fd3c520d1</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,961dd1f1-fef0-458e-ae04-f73fd3c520d1.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,961dd1f1-fef0-458e-ae04-f73fd3c520d1.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=961dd1f1-fef0-458e-ae04-f73fd3c520d1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I don't think etrade has learned the lessons in my posts on floating point numbers/variables.
</p>
        <p>
          <a href="http://www.chrismay.org/2006/09/06/SQL+Server+DecimalMoneyFloat+Datatypes.aspx">SQL
Server Decimal/Money/Float datatypes</a>
        </p>
        <p>
          <a href="http://www.chrismay.org/2005/05/23/Javascript+And+Apparently+Other+Programming+Languages+Cant+Do+Math.aspx">Javascript
(and apparently other programming languages) can't do math </a>
        </p>
        <p>
          <img src="http://chrismay.org/content/binary/EtradeFloatingPointSmall.png" border="0" />
        </p>
        <p>
          <a href="http://chrismay.org/content/binary/EtradeFloatingPoint.png" target="_blank" border="0">Click
here for a screen shot of the full page.</a>
        </p>
        <a href="https://us.etrade.com/e/t/jumppage/viewjumppage?PageName=CSAlanding">Here</a> is
a link to the page where I found it. I hope they fix it soon. It's pretty sad. 
<p>
But, on the other hand, I wonder what I will do with that extra .00000000000005 dollars?
</p><img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=961dd1f1-fef0-458e-ae04-f73fd3c520d1" /></body>
      <title>Why should you not use floats for actual decimal numbers?</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,961dd1f1-fef0-458e-ae04-f73fd3c520d1.aspx</guid>
      <link>http://chrismay.org/2009/03/23/Why+Should+You+Not+Use+Floats+For+Actual+Decimal+Numbers.aspx</link>
      <pubDate>Mon, 23 Mar 2009 18:22:12 GMT</pubDate>
      <description>&lt;p&gt;
I don't think etrade has learned the lessons in my posts on floating point numbers/variables.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.chrismay.org/2006/09/06/SQL+Server+DecimalMoneyFloat+Datatypes.aspx"&gt;SQL
Server Decimal/Money/Float datatypes&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.chrismay.org/2005/05/23/Javascript+And+Apparently+Other+Programming+Languages+Cant+Do+Math.aspx"&gt;Javascript
(and apparently other programming languages) can't do math &lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://chrismay.org/content/binary/EtradeFloatingPointSmall.png" border=0&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://chrismay.org/content/binary/EtradeFloatingPoint.png" target=_blank border="0"&gt;Click
here for a screen shot of the full page.&lt;/a&gt;
&lt;/p&gt;
&lt;a href="https://us.etrade.com/e/t/jumppage/viewjumppage?PageName=CSAlanding"&gt;Here&lt;/a&gt; is
a link to the page where I found it. I hope they fix it soon. It's pretty sad. 
&lt;p&gt;
But, on the other hand, I wonder what I will do with that extra .00000000000005 dollars?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=961dd1f1-fef0-458e-ae04-f73fd3c520d1" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,961dd1f1-fef0-458e-ae04-f73fd3c520d1.aspx</comments>
      <category>Funny Stuff</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=88d8b56e-2fb0-44d8-aa24-c31e084f8dbe</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,88d8b56e-2fb0-44d8-aa24-c31e084f8dbe.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,88d8b56e-2fb0-44d8-aa24-c31e084f8dbe.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=88d8b56e-2fb0-44d8-aa24-c31e084f8dbe</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It took me a while to figure out that I didn't have a driver problem.
</p>
        <p>
I was looking everywhere to find the switch for the wifi on this HP Elitebook 8730w,
but it turns out the LED icon in the upper left that shows the WIFI status IS the
button, but clicking it does nothing.. why?
</p>
        <p>
Well, b/c HP is using "LAN/WLAN switching" which means that it automatically turns
off the wifi connection if you are plugged in.
</p>
        <p>
Just unplug your network cable and your wifi card will enable!  
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=88d8b56e-2fb0-44d8-aa24-c31e084f8dbe" />
      </body>
      <title>Trying to find the WIFI Switch on the HP Elitebook 8730w?</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,88d8b56e-2fb0-44d8-aa24-c31e084f8dbe.aspx</guid>
      <link>http://chrismay.org/2009/03/23/Trying+To+Find+The+WIFI+Switch+On+The+HP+Elitebook+8730w.aspx</link>
      <pubDate>Mon, 23 Mar 2009 04:28:44 GMT</pubDate>
      <description>&lt;p&gt;
It took me&amp;nbsp;a while to figure out that I didn't have a driver problem.
&lt;/p&gt;
&lt;p&gt;
I was looking everywhere to find the switch for the wifi on this HP Elitebook 8730w,
but it turns out the LED icon in the upper left that shows the WIFI status IS the
button, but clicking it does nothing.. why?
&lt;/p&gt;
&lt;p&gt;
Well, b/c HP is using "LAN/WLAN switching" which means that it automatically turns
off the wifi connection if you are plugged in.
&lt;/p&gt;
&lt;p&gt;
Just unplug your network cable and your wifi card will enable!&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=88d8b56e-2fb0-44d8-aa24-c31e084f8dbe" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,88d8b56e-2fb0-44d8-aa24-c31e084f8dbe.aspx</comments>
      <category>Hardware;Misc</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=7d65d5a4-bfa3-4a48-acc9-ad2deacd9277</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,7d65d5a4-bfa3-4a48-acc9-ad2deacd9277.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,7d65d5a4-bfa3-4a48-acc9-ad2deacd9277.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=7d65d5a4-bfa3-4a48-acc9-ad2deacd9277</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Ever get this error?
</p>
        <pre>More than one data set, data region, or grouping in the report has 
<br />
the name 'SOMENAME'.  Data set, data region, and grouping names 
<br />
must be unique within a report. </pre>
        <p>
Basically what happened was, somehow VS lost track of an existing datasource you were
using, why I don't know. When you went to add a new field or change something it added
a 2nd copy of the same datasource, and now you have 2 datasources with same name.
You can't do that. To fix this, when you are editing the report, choose Report --&gt;
Data Sources from the menu and remove one of the duplicate datasource names.
</p>
        <p>
In a related error, you may notice that you can't use some fields that are part of
your dataset.  For example, in my app, I had a field called "CreatedDate". 
This was a public property of my object, and it showed up in my data source that I
was using to bind to the report, but the report refused to acknowledge it.
</p>
        <p>
So in this case you need to delete the original datasource using the same steps as
above, and do something to cause it to add a new copy of the correct datasource (like
drag a field onto the report).
</p>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=7d65d5a4-bfa3-4a48-acc9-ad2deacd9277" />
      </body>
      <title>SQL Reports RDLC Errors</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,7d65d5a4-bfa3-4a48-acc9-ad2deacd9277.aspx</guid>
      <link>http://chrismay.org/2009/03/22/SQL+Reports+RDLC+Errors.aspx</link>
      <pubDate>Sun, 22 Mar 2009 22:32:16 GMT</pubDate>
      <description>&lt;p&gt;
Ever get this error?
&lt;/p&gt;
&lt;pre&gt;More than one data set, data region, or grouping in the report has 
&lt;br&gt;
the name 'SOMENAME'.&amp;nbsp; Data set, data region, and grouping names 
&lt;br&gt;
must be unique within a report.&amp;nbsp;&lt;/pre&gt;
&lt;p&gt;
Basically what happened was, somehow VS lost track of an existing datasource you were
using, why I don't know. When you went to add a new field or change something it added
a 2nd copy of the same datasource, and now you have 2 datasources with same name.
You can't do that. To fix this, when you are editing the report, choose Report --&amp;gt;
Data Sources from the menu and remove one of the duplicate datasource names.
&lt;/p&gt;
&lt;p&gt;
In a related error, you may notice that you can't use some fields that are part of
your dataset.&amp;nbsp; For example, in my app, I had a field called "CreatedDate".&amp;nbsp;
This was a public property of my object, and it showed up in my data source that I
was using to bind to the report, but the report refused to acknowledge it.
&lt;/p&gt;
&lt;p&gt;
So in this case you need to delete the original datasource using the same steps as
above, and do something to cause it to add a new copy of the correct datasource (like
drag a field onto the report).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=7d65d5a4-bfa3-4a48-acc9-ad2deacd9277" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,7d65d5a4-bfa3-4a48-acc9-ad2deacd9277.aspx</comments>
      <category>Programming;Programming/Reporting</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=7405cb76-d2b3-4032-828d-4ad1a88c29b2</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,7405cb76-d2b3-4032-828d-4ad1a88c29b2.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,7405cb76-d2b3-4032-828d-4ad1a88c29b2.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=7405cb76-d2b3-4032-828d-4ad1a88c29b2</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
        <p>
          <img src="http://chrismay.org/content/binary/OpenSTA-logo-247x65[1].png" border="0" />
        </p>
        <p>
I have been looking around for a quick easy load testing package.  Right now
I'm trying out OpenSTA.  I can't say that it has been very direct, but I am still
holding out hope that it will work.
</p>
        <p>
This is the <a href="http://www.opensta.org/docs/gsg/index.htm">Getting Started Guide</a> that
I have been using.
</p>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=7405cb76-d2b3-4032-828d-4ad1a88c29b2" />
      </body>
      <title>Getting Started With OpenSTA</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,7405cb76-d2b3-4032-828d-4ad1a88c29b2.aspx</guid>
      <link>http://chrismay.org/2009/03/16/Getting+Started+With+OpenSTA.aspx</link>
      <pubDate>Mon, 16 Mar 2009 19:19:16 GMT</pubDate>
      <description>&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://chrismay.org/content/binary/OpenSTA-logo-247x65[1].png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
I have been looking around for a quick easy load testing package.&amp;nbsp; Right now
I'm trying out OpenSTA.&amp;nbsp; I can't say that it has been very direct, but I am still
holding out hope that it will work.
&lt;/p&gt;
&lt;p&gt;
This is the &lt;a href="http://www.opensta.org/docs/gsg/index.htm"&gt;Getting Started Guide&lt;/a&gt; that
I have been using.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=7405cb76-d2b3-4032-828d-4ad1a88c29b2" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,7405cb76-d2b3-4032-828d-4ad1a88c29b2.aspx</comments>
      <category>Misc;Programming;Programming/Testing</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=ff12cef1-1698-445e-a3dc-3470d3b37238</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,ff12cef1-1698-445e-a3dc-3470d3b37238.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,ff12cef1-1698-445e-a3dc-3470d3b37238.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=ff12cef1-1698-445e-a3dc-3470d3b37238</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Problem:
</p>
        <p>
We have a server that gets all files from TFS and uses Nant w/ Visual studio to compile
our projects.  Basically nant issues a command line statement to get VS to build
a given solution.<br /><br />
Everything was working great, until I upgraded our clients to 2008.<br /><br />
I went through and upgraded all our solutions.<br /><br />
I installed vs 2008 on the server.  But when I try to build from the command
line, it tells me that the solution file "is from a previous version of this application
and must be converted in order to build in this version of the application."<br /><br />
I tried directly copying my solution file (skipping the source control step) directly
to the server but I get the same message.<br /><br />
If I try to build it from the command line with VS 2005 it tells me that the solution
is too new!!  
<br /><br />
So 2005 says the solution is too new, 2008 says it is too old!<br /><br />
The solution on the server has the "version 9" icon, just like on my laptop.<br /><br />
The solution file starts with:<br />
Microsoft Visual Studio Solution File, Format Version 10.00<br />
# Visual Studio 2008
</p>
        <p>
Resolution:
</p>
        <p>
Even thought I compared the solution files and found them to be exactly the same using
a diff compare tool, I allowed the server to run the "upgrade" process on the solutions. 
I didn't save any of the changes it made, but from then on it recognized those files
as having been already upgraded.
</p>
        <p>
I even replaced the "server upgraded" solution files with the old solution files that
it didn't like and it continued to work just fine.
</p>
        <p>
There must be some other files stored somewhere that made it think that it hadn't
been upgraded yet.
</p>
        <p>
This isn't a great solution, but it works at least.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=ff12cef1-1698-445e-a3dc-3470d3b37238" />
      </body>
      <title>Problems Upgrading VS Solutions to 2008 With CruiseControl.Net</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,ff12cef1-1698-445e-a3dc-3470d3b37238.aspx</guid>
      <link>http://chrismay.org/2009/03/16/Problems+Upgrading+VS+Solutions+To+2008+With+CruiseControlNet.aspx</link>
      <pubDate>Mon, 16 Mar 2009 15:43:30 GMT</pubDate>
      <description>&lt;p&gt;
Problem:
&lt;/p&gt;
&lt;p&gt;
We have a server that gets all files from TFS and uses Nant w/ Visual studio to compile
our projects.&amp;nbsp; Basically nant issues a command line statement to get VS to build
a given solution.&lt;br&gt;
&lt;br&gt;
Everything was working great, until I upgraded our clients to 2008.&lt;br&gt;
&lt;br&gt;
I went through and upgraded all our solutions.&lt;br&gt;
&lt;br&gt;
I installed vs 2008 on the server.&amp;nbsp; But when I try to build from the command
line, it tells me that the solution file "is from a previous version of this application
and must be converted in order to build in this version of the application."&lt;br&gt;
&lt;br&gt;
I tried directly copying my solution file (skipping the source control step) directly
to the server but I get the same message.&lt;br&gt;
&lt;br&gt;
If I try to build it from the command line with VS 2005 it tells me that the solution
is too new!!&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
So 2005 says the solution is too new, 2008 says it is too old!&lt;br&gt;
&lt;br&gt;
The solution on the server has the "version 9" icon, just like on my laptop.&lt;br&gt;
&lt;br&gt;
The solution file starts with:&lt;br&gt;
Microsoft Visual Studio Solution File, Format Version 10.00&lt;br&gt;
# Visual Studio 2008
&lt;/p&gt;
&lt;p&gt;
Resolution:
&lt;/p&gt;
&lt;p&gt;
Even thought I compared the solution files and found them to be exactly the same using
a diff compare tool, I allowed the server to run the "upgrade" process on the solutions.&amp;nbsp;
I didn't save any of the changes it made, but from then on it recognized those files
as having been already upgraded.
&lt;/p&gt;
&lt;p&gt;
I even replaced the "server upgraded" solution files with the old solution files that
it didn't like and it continued to work just fine.
&lt;/p&gt;
&lt;p&gt;
There must be some other files stored somewhere that made it think that it hadn't
been upgraded yet.
&lt;/p&gt;
&lt;p&gt;
This isn't a great solution, but it works at least.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=ff12cef1-1698-445e-a3dc-3470d3b37238" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,ff12cef1-1698-445e-a3dc-3470d3b37238.aspx</comments>
      <category>Programming;Programming/.Net;Programming/.Net/VS.Net;Programming/TFS;Programming/VSS</category>
    </item>
    <item>
      <trackback:ping>http://chrismay.org/Trackback.aspx?guid=a9ac57f9-0e79-459f-8891-b2e26ebd72b4</trackback:ping>
      <pingback:server>http://chrismay.org/pingback.aspx</pingback:server>
      <pingback:target>http://chrismay.org/PermaLink,guid,a9ac57f9-0e79-459f-8891-b2e26ebd72b4.aspx</pingback:target>
      <dc:creator>ChrisMay</dc:creator>
      <wfw:comment>http://chrismay.org/CommentView,guid,a9ac57f9-0e79-459f-8891-b2e26ebd72b4.aspx</wfw:comment>
      <wfw:commentRss>http://chrismay.org/SyndicationService.asmx/GetEntryCommentsRss?guid=a9ac57f9-0e79-459f-8891-b2e26ebd72b4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
ASP.NET has a limited number of threads that it uses to service incoming requests. 
Thes threads from the its thread pool, and when its collection of threads are busy,
requests have to queue up waiting for an open thread.
</p>
        <p>
But, what happens when you have threads that are blocking waiting for another process
to complete?  This could we a database call, or a webservice call, or an IO operation
etc.
</p>
        <p>
Well, what happens is that the thread, while doing no real work, is unavailable to
service requests.
</p>
        <p>
So, if your database is crunching on some long queries, other simple web requests
may be sitting in the queue unable to be handled, even though the webserver CPU is
idle.
</p>
        <p>
One solution to this is to use Async pages/methods in ASP.NET 2 or greater.
</p>
        <p>
Async operations allow the thread to be returned back to the thread pool instead
of blocking, while some process is executed.
</p>
        <p>
          <img src="http://chrismay.org/content/binary/cc163725.fig02(en-us)[1].gif" border="0" />
        </p>
        <p>
 
</p>
        <p>
There is more than 1 way to do async operations like this from asp.net pages.  
</p>
        <p>
One is to use <font size="2"><strong>RegisterAsyncTask</strong> and the other to user <font size="2"><strong>AddOnPreRenderCompleteAsync</strong> as
well as declare the page as <font color="#ff0000" size="2"><font color="#ff0000" size="2">Async</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">="true"</font></font>.</font></font></p>
        <p>
          <font size="2">
            <font size="2">I won't go into all the details, but <font size="2">AddOnPreRenderCompleteAsync
is probably simpler, but you can't define a timeout, you can't call it multiple
times in parallel, and in the <font size="2">EndAsyncOperation event handler you can't
access things like the httpcontext object.</font></font></font>
          </font>
        </p>
        <p>
          <font size="2">
            <font size="2">
              <font size="2">
                <font size="2">Here are 2 examples of
pages that are asynchronously serving up a PDF document (which is itself served from
a page DownloadPDF.aspx, which has a 5 second thread sleep in it to simulate the processing
of the report on another server.</font>
              </font>
            </font>
          </font>
        </p>
        <p>
          <font size="2">
            <font size="2">
              <font size="2">
                <font size="2">Using <strong>AddOnPreRenderCompleteAsync:</strong></font>
              </font>
            </font>
          </font>
        </p>
        <font size="2">
          <font size="2">
            <font size="2">
              <font size="2">
                <strong>
                  <pre>
                    <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                      <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Imports</span> System.Net <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Imports</span> System.IO <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Partial</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Class</span> AsyncServer <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Inherits</span> System.Web.UI.Page <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> _request <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> WebRequest <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Protected</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> Page_Load(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> sender <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> e <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.EventArgs) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Handles</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Me</span>.Load
AddOnPreRenderCompleteAsync(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> BeginEventHandler(<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AddressOf</span> BeginAsyncOperation),
_ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> EndEventHandler(<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AddressOf</span> EndAsyncOperation)) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span> BeginAsyncOperation(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> sender <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> e <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> EventArgs, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> cb <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> AsyncCallback, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> state <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> IAsyncResult
_request <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> WebRequest.Create(HttpContext.Current.Request.Url.Scheme
&amp; _ <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"://"</span> &amp;
HttpContext.Current.Request.Url.Authority &amp; _ Page.ResolveUrl(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"DownloadPDF.aspx"</span>)) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Return</span> _request.BeginGetResponse(cb,
state) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> EndAsyncOperation(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> ar <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> IAsyncResult) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> reportResponse <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> WebResponse <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> _request.EndGetResponse(ar) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> reader <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> BinaryReader(reportResponse.GetResponseStream()) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> buffer(reportResponse.ContentLength) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Byte</span> buffer <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> reader.ReadBytes(buffer.Length)
         Response.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Clear</span>()
Response.ClearHeaders() Response.ClearContent() Response.ContentType <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Application/pdf"</span> Response.BinaryWrite(buffer) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Class</span></span>
                  </pre>
                </strong>
              </font>
            </font>
          </font>
        </font>
        <p>
 
</p>
        <p>
But I prefer to use <strong>RegisterAsyncTask.  </strong>Now, keep in mind that
many operations will already support async versions (webrequests, webservice calls,
databases calls, file IO etc), but if there isn't already built in support for an
async call, you can make your own method work in this framework with an async delegate. 
Check out the commented code below for how you could do this, but because webrequests
already support making the call in an asynchronous fashion, I don't need to.
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Imports</span> System.Net <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Imports</span> System.IO <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Partial</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Class</span> RegisterAsyncTaskServer <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Inherits</span> System.Web.UI.Page <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Protected</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> Page_Load(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> sender <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> e <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.EventArgs) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Handles</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Me</span>.Load
Page.AsyncTimeout <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> System.TimeSpan(0,
0, 8) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> task <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> PageAsyncTask(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> BeginEventHandler(<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AddressOf</span> BeginGetAsyncData),
_ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> EndEventHandler(<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AddressOf</span> EndGetAsyncData),
_ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> EndEventHandler(<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AddressOf</span> TimeoutGetAsyncData), <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"task1"</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">True</span>)
RegisterAsyncTask(task) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'***************
This is one way to do this if not using an async download method by creating an async
delegate</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Dim
taskDelegate As AsyncTaskDelegate</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">''
Create delegate.</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Delegate
Sub AsyncTaskDelegate()</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Private
Function BeginGetAsyncData(ByVal src As Object, ByVal args As EventArgs, ByVal cb
As AsyncCallback, ByVal state As Object) As IAsyncResult</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Dim extraData As New Object</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
taskDelegate = New AsyncTaskDelegate(AddressOf DownloadReport)</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Dim result As IAsyncResult = taskDelegate.BeginInvoke(cb, extraData)</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Return result</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'End
Function</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Private
Sub DownloadReport()</span><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'End
Sub</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span> reportRequest <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> WebRequest <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span> BeginGetAsyncData(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> src <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> args <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> EventArgs, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> cb <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> AsyncCallback, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> state <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> IAsyncResult
reportRequest <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> WebRequest.Create(HttpContext.Current.Request.Url.Scheme
&amp; <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"://"</span> &amp;
_ HttpContext.Current.Request.Url.Authority &amp; _ Page.ResolveUrl(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"DownloadPDF.aspx"</span>)) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Return</span> reportRequest.BeginGetResponse(cb,
state) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> TimeoutGetAsyncData(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> ar <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> IAsyncResult)
Response.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Write</span>(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"TIMEOUT"</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> EndGetAsyncData(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> ar <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> IAsyncResult) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> reportResponse <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> WebResponse <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> reportRequest.EndGetResponse(ar) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> reader <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> BinaryReader(reportResponse.GetResponseStream()) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> buffer(reportResponse.ContentLength <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">-</span> 1) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Byte</span> buffer <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> reader.ReadBytes(buffer.Length)
Response.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Clear</span>()
Response.ClearHeaders() Response.ClearContent() Response.ContentType <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Application/pdf"</span> Response.BinaryWrite(buffer)
Response.Flush() <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Class</span></span>
        </pre>
        <p>
Nice!
</p>
        <img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=a9ac57f9-0e79-459f-8891-b2e26ebd72b4" />
      </body>
      <title>Using Asyncronous Tasks In ASP.NET</title>
      <guid isPermaLink="false">http://chrismay.org/PermaLink,guid,a9ac57f9-0e79-459f-8891-b2e26ebd72b4.aspx</guid>
      <link>http://chrismay.org/2009/03/13/Using+Asyncronous+Tasks+In+ASPNET.aspx</link>
      <pubDate>Fri, 13 Mar 2009 16:46:43 GMT</pubDate>
      <description>&lt;p&gt;
ASP.NET has a limited number of threads that it uses to service incoming requests.&amp;nbsp;
Thes threads from the its thread pool, and when its collection of threads are busy,
requests have to queue up waiting for an open thread.
&lt;/p&gt;
&lt;p&gt;
But, what happens when you have threads that are blocking waiting for another process
to complete?&amp;nbsp; This could we a database call, or a webservice call, or an IO operation
etc.
&lt;/p&gt;
&lt;p&gt;
Well, what happens is that the thread, while doing no real work, is unavailable to
service requests.
&lt;/p&gt;
&lt;p&gt;
So, if your database is crunching on some long queries, other simple web requests
may be sitting in the queue unable to be handled, even though the webserver CPU is
idle.
&lt;/p&gt;
&lt;p&gt;
One solution to this is to use Async pages/methods in ASP.NET 2 or greater.
&lt;/p&gt;
&lt;p&gt;
Async operations allow the thread to&amp;nbsp;be returned back to the thread pool instead
of blocking, while some process is executed.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://chrismay.org/content/binary/cc163725.fig02(en-us)[1].gif" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
There is more than 1 way to do async operations like this from asp.net pages.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
One is to use &lt;font size=2&gt;&lt;strong&gt;RegisterAsyncTask&lt;/strong&gt; and the other to user &lt;font size=2&gt;&lt;strong&gt;AddOnPreRenderCompleteAsync&lt;/strong&gt; as
well as declare the page as &lt;font color=#ff0000 size=2&gt;&lt;font color=#ff0000 size=2&gt;Async&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;="true"&lt;/font&gt;&lt;/font&gt;.&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font size=2&gt;I won't go into all the details, but &lt;font size=2&gt;AddOnPreRenderCompleteAsync
is probably simpler, but you can't define a timeout,&amp;nbsp;you can't call it multiple
times in parallel, and in the &lt;font size=2&gt;EndAsyncOperation event handler you can't
access things like the httpcontext object.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font size=2&gt;&lt;font size=2&gt;&lt;font size=2&gt;Here are 2 examples of pages that
are asynchronously serving up a PDF document (which is itself served from a page DownloadPDF.aspx,
which has a 5 second thread sleep in it to simulate the processing of the report on
another server.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font size=2&gt;&lt;font size=2&gt;&lt;font size=2&gt;Using &lt;strong&gt;AddOnPreRenderCompleteAsync:&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt;&lt;font size=2&gt;&lt;font size=2&gt;&lt;font size=2&gt;&lt;strong&gt;&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Imports&lt;/span&gt; System.Net &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Imports&lt;/span&gt; System.IO &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Partial&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Class&lt;/span&gt; AsyncServer &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Inherits&lt;/span&gt; System.Web.UI.Page &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; _request &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; WebRequest &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Protected&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; Page_Load(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; sender &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; e &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Handles&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Me&lt;/span&gt;.Load
AddOnPreRenderCompleteAsync(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; BeginEventHandler(&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AddressOf&lt;/span&gt; BeginAsyncOperation),
_ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; EndEventHandler(&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AddressOf&lt;/span&gt; EndAsyncOperation)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt; BeginAsyncOperation(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; sender &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; e &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; EventArgs, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; cb &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; AsyncCallback, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; state &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; IAsyncResult
_request &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; WebRequest.Create(HttpContext.Current.Request.Url.Scheme
&amp;amp; _ &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"://"&lt;/span&gt; &amp;amp;
HttpContext.Current.Request.Url.Authority &amp;amp; _ Page.ResolveUrl(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"DownloadPDF.aspx"&lt;/span&gt;)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Return&lt;/span&gt; _request.BeginGetResponse(cb,
state) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; EndAsyncOperation(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; ar &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; IAsyncResult) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; reportResponse &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; WebResponse &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; _request.EndGetResponse(ar) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; reader &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; BinaryReader(reportResponse.GetResponseStream()) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; buffer(reportResponse.ContentLength) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Byte&lt;/span&gt; buffer &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; reader.ReadBytes(buffer.Length)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Response.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Clear&lt;/span&gt;()
Response.ClearHeaders() Response.ClearContent() Response.ContentType &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Application/pdf"&lt;/span&gt; Response.BinaryWrite(buffer) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Class&lt;/span&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; 
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
But I prefer to use &lt;strong&gt;RegisterAsyncTask.&amp;nbsp; &lt;/strong&gt;Now, keep in mind that
many operations will already support async versions (webrequests, webservice calls,
databases calls, file IO etc), but if there isn't already built in support for an
async call, you can make your own method work in this framework with an async delegate.&amp;nbsp;
Check out the commented code below for how you could do this, but because webrequests
already support making the call in an asynchronous fashion, I don't need to.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Imports&lt;/span&gt; System.Net &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Imports&lt;/span&gt; System.IO &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Partial&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Class&lt;/span&gt; RegisterAsyncTaskServer &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Inherits&lt;/span&gt; System.Web.UI.Page &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Protected&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; Page_Load(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; sender &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; e &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Handles&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Me&lt;/span&gt;.Load
Page.AsyncTimeout &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; System.TimeSpan(0,
0, 8) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; task &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; PageAsyncTask(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; BeginEventHandler(&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AddressOf&lt;/span&gt; BeginGetAsyncData),
_ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; EndEventHandler(&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AddressOf&lt;/span&gt; EndGetAsyncData),
_ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; EndEventHandler(&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AddressOf&lt;/span&gt; TimeoutGetAsyncData), &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"task1"&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;True&lt;/span&gt;)
RegisterAsyncTask(task) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'***************
This is one way to do this if not using an async download method by creating an async
delegate&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Dim
taskDelegate As AsyncTaskDelegate&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;''
Create delegate.&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Delegate
Sub AsyncTaskDelegate()&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Private
Function BeginGetAsyncData(ByVal src As Object, ByVal args As EventArgs, ByVal cb
As AsyncCallback, ByVal state As Object) As IAsyncResult&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Dim extraData As New Object&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
taskDelegate = New AsyncTaskDelegate(AddressOf DownloadReport)&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Dim result As IAsyncResult = taskDelegate.BeginInvoke(cb, extraData)&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Return result&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'End
Function&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Private
Sub DownloadReport()&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'End
Sub&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; reportRequest &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; WebRequest &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt; BeginGetAsyncData(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; src &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; args &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; EventArgs, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; cb &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; AsyncCallback, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; state &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; IAsyncResult
reportRequest &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; WebRequest.Create(HttpContext.Current.Request.Url.Scheme
&amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"://"&lt;/span&gt; &amp;amp;
_ HttpContext.Current.Request.Url.Authority &amp;amp; _ Page.ResolveUrl(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"DownloadPDF.aspx"&lt;/span&gt;)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Return&lt;/span&gt; reportRequest.BeginGetResponse(cb,
state) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; TimeoutGetAsyncData(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; ar &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; IAsyncResult)
Response.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Write&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"TIMEOUT"&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; EndGetAsyncData(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; ar &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; IAsyncResult) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; reportResponse &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; WebResponse &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; reportRequest.EndGetResponse(ar) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; reader &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; BinaryReader(reportResponse.GetResponseStream()) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; buffer(reportResponse.ContentLength &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;-&lt;/span&gt; 1) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Byte&lt;/span&gt; buffer &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; reader.ReadBytes(buffer.Length)
Response.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Clear&lt;/span&gt;()
Response.ClearHeaders() Response.ClearContent() Response.ContentType &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Application/pdf"&lt;/span&gt; Response.BinaryWrite(buffer)
Response.Flush() &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Class&lt;/span&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Nice!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrismay.org/aggbug.ashx?id=a9ac57f9-0e79-459f-8891-b2e26ebd72b4" /&gt;</description>
      <comments>http://chrismay.org/CommentView,guid,a9ac57f9-0e79-459f-8891-b2e26ebd72b4.aspx</comments>
      <category>Programming;Programming/.Net;Programming/.Net/.Net Framework;Programming/.Net/ASP.Net</category>
    </item>
  </channel>
</rss>