<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Deployment</title>
        <link>http://geekswithblogs.net/vitus/category/10030.aspx</link>
        <description>Deployment</description>
        <language>ru-RU</language>
        <copyright>Vitus</copyright>
        <managingEditor>vitus@movaxbx.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>WCF REST services: hosting in the IIS7</title>
            <link>http://geekswithblogs.net/vitus/archive/2009/07/12/wcf-rest-services-hosting-in-the-iis7.aspx</link>
            <description>&lt;p&gt;Not long ago I notice interesting “feature” of WCF REST, hosted in the IIS7: when size of data from client exceeds some value, service broke the connection.    &lt;br /&gt;
I created test service, where I could reproduce this issue, using WCF REST Starter Kit (you can download &lt;a href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24644"&gt;here&lt;/a&gt; actual release, Preview 2). One of service's method is:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;[WebHelp(Comment = &lt;span style="color: rgb(0, 96, 128);"&gt;"Sample description for DoWork"&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;[WebInvoke(UriTemplate = &lt;span style="color: rgb(0, 96, 128);"&gt;"DoWork"&lt;/span&gt;, Method = &lt;span style="color: rgb(0, 96, 128);"&gt;"POST"&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;[OperationContract]&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; SampleResponseBody DoWork(SampleRequestBody request)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; SampleResponseBody()&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;        Value = String.Format(&lt;span style="color: rgb(0, 96, 128);"&gt;"Data: {0}, Length: {1}"&lt;/span&gt;, request.Data, &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;                                request.Array.Length)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;So, this method has 1 parameter, which is passed by the POST method. Code of SampleRequestBody entity:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; SampleRequestBody&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; Data { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;byte&lt;/span&gt;[] Array { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I set large quotas and 10 minutes request timeout in the binding configuration (in web.config file) for my test service:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;bindings&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;webHttpBinding&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;binding&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="webBinding"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;             &lt;span style="color: rgb(255, 0, 0);"&gt;maxBufferSize&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="152428800"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;maxReceivedMessageSize&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="152428800"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;             &lt;span style="color: rgb(255, 0, 0);"&gt;receiveTimeout&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="00:10:00"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;      &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;readerQuotas&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;maxStringContentLength&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="152428800"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;                    &lt;span style="color: rgb(255, 0, 0);"&gt;maxArrayLength&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="152428800"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;                    &lt;span style="color: rgb(255, 0, 0);"&gt;maxBytesPerRead&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="4096"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;binding&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;webHttpBinding&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;bindings&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;After that I successfully host my test service in the local development server, and it work normal. Here screenshot of client console application. How you can see, service side received 30Mb file successfully.&lt;/p&gt;
&lt;p&gt;&lt;img height="67" border="0" width="564" src="http://geekswithblogs.net/images/geekswithblogs_net/vitus/WindowsLiveWriter/WCFRESTserviceshostingintheIIS7_14FAD/image_3.png" alt="image" title="image" style="border-width: 0px; display: inline;" /&gt; &lt;/p&gt;
&lt;p&gt;Then I host my test service in the IIS7. And when I try to call service method from the client, I get an exception:&lt;/p&gt;
&lt;p&gt;&lt;img height="123" border="0" width="567" src="http://geekswithblogs.net/images/geekswithblogs_net/vitus/WindowsLiveWriter/WCFRESTserviceshostingintheIIS7_14FAD/image_8.png" alt="image" title="image" style="border: 0px none ; display: inline;" /&gt;&lt;/p&gt;
&lt;p&gt;I check Windows EventLog, but it don’t contain any items about my service. Next step is to allow IIS7 accept large size requests. You can do that with &lt;a href="http://msdn.microsoft.com/en-us/library/e1f13641.aspx"&gt;maxRequestLength&lt;/a&gt; attribute:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;httpRuntime&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;maxRequestLength&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="xxx"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;where &lt;em&gt;xxx&lt;/em&gt; is maximum request size in KB.&lt;/p&gt;
&lt;p&gt;But after that service still can’t serve requests normally. And I noticed, that exception on client side was changed:&lt;/p&gt;
&lt;p&gt;&lt;img height="127" border="0" width="559" src="http://geekswithblogs.net/images/geekswithblogs_net/vitus/WindowsLiveWriter/WCFRESTserviceshostingintheIIS7_14FAD/image_9.png" alt="image" title="image" style="border: 0px none ; display: inline;" /&gt; &lt;/p&gt;
&lt;p&gt;I got 404 error on my client side. Windows EventLogs still don’t had any useful info, and I decided &lt;a href="http://msdn.microsoft.com/en-us/library/ms730064.aspx"&gt;enable logging&lt;/a&gt; of my service. When I try to call service, it log is empty. And I think, that requests from client is dropped by something before they achieve the service, i.e. by IIS7. I check IIS logs, and found, that IIS reply 404 error with subcode 13. It’s &lt;a href="http://support.microsoft.com/default.aspx/kb/943891"&gt;means&lt;/a&gt;, that incoming request is too large. I search &lt;a href="http://forums.iis.net/"&gt;forums.iis.net&lt;/a&gt;, and locate some interesting option. File %windir%\System32\inetsrv\config\applicationHost.config contain &amp;lt;requestFiltering&amp;gt; section. I add following parameter:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;requestLimits&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;maxAllowedContentLength&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="xxx"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;where &lt;em&gt;xxx &lt;/em&gt;is max size of request. And when I set it, service work normal.&lt;/p&gt;
&lt;p&gt;One trick with applicationHost.config: in the x64 version of Windows this file is not visible from 32bit file managers such as FAR Manager and other. Windows Explorer show it normally. I think, that 32bit applications is redirected to some other place, that doesn’t contain applicationHost.config. For example, VS 2008 devenv.exe is 32bit app, and you can’t edit applicationHost.config file in Visual Studio. Use notepad for edit.&lt;/p&gt;
&lt;p&gt;So there are 3 steps to allow large size requests:&lt;/p&gt;
&lt;p&gt;1. deal with binding configuration: set &lt;em&gt;maxReceivedMessageSize&lt;/em&gt;, &lt;em&gt;maxBufferSize&lt;/em&gt; etc. parameters;&lt;/p&gt;
&lt;p&gt;2. set &lt;em&gt;maxRequestLength&lt;/em&gt; attribute of &lt;em&gt;&amp;lt;httpRuntime&amp;gt;&lt;/em&gt; in the web.config;&lt;/p&gt;
&lt;p&gt;3. set max request size in the &lt;em&gt;&amp;lt;requestFiltering&amp;gt;&lt;/em&gt; section and &lt;em&gt;&amp;lt;requestLimit&amp;gt;&lt;/em&gt; element in the  %windir%\System32\inetsrv\config\applicationHost.config;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/vitus/aggbug/133437.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Vitus</dc:creator>
            <guid>http://geekswithblogs.net/vitus/archive/2009/07/12/wcf-rest-services-hosting-in-the-iis7.aspx</guid>
            <pubDate>Sun, 12 Jul 2009 08:14:05 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/vitus/comments/133437.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/vitus/archive/2009/07/12/wcf-rest-services-hosting-in-the-iis7.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/vitus/comments/commentRss/133437.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Working with ClickOnce: some tips</title>
            <link>http://geekswithblogs.net/vitus/archive/2009/05/04/working-with-clickonce-some-tips.aspx</link>
            <description>&lt;p&gt;ClickOnce is a useful deployment system, which consist of many interesting features, such as easy deployment and updating. This technology is introduced long ago, and it's good-described. I want to stop on some tips, which can help you.&lt;/p&gt;  &lt;h4&gt;&lt;strong&gt;1. Making offline-installer&lt;/strong&gt;&lt;/h4&gt;  &lt;p&gt;ClickOnce offer some mechanism for installing prerequisite software, before installing our application. It may be MS .NET Framework of necessary version, SQL Server Compact Edition, etc.    &lt;br /&gt;For example, we have WPF application, which use SQL Compact. In the list of available prerequisites we choose 3 items: Windows Installer 3.1, MS .NET FX 3.5SP1, SQL Server Compact 3.5:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image12" border="0" alt="image12" src="http://geekswithblogs.net/images/geekswithblogs_net/vitus/WindowsLiveWriter/WorkingwithClickOncesometips_D714/image12_3.png" width="326" height="251" /&gt;&lt;/p&gt;  &lt;p&gt;How we can see, first radio button is selected. It's means, that all prerequisite software will be downloaded from vendor's website, and installed to the target computer. So, we need access to the internet.    &lt;br /&gt;And when we choose "Download prerequisites from the same location as my application" radio-button, we get full installation package.     &lt;br /&gt;In the real life I had some troubles with offline-installer. Some of my customers told me, that they can't install MS .NET 3.5SP1 on the computers, which is not connected to the internet. And the connected machines consumed some traffic during installation.     &lt;br /&gt;Solution of problem contains in &lt;a href="http://download.microsoft.com/download/A/2/8/A2807F78-C861-4B66-9B31-9205C3F22252/VS2008SP1Readme.htm#General%20Issues" target="_blank"&gt;Readme to VS2008 SP1&lt;/a&gt; :) This document contains detailed description, how to prepare computer to creating offline ClickOnce installer, and how to avoid need  the internet for installing MS .NET 3.5SP1. Read “Enable Samesite for the .NET Framework 3.5 SP1 bootstrapper package” attentively :)&lt;/p&gt;  &lt;h4&gt;&lt;strong&gt;2. IsFirstRun&lt;/strong&gt;&lt;/h4&gt;  &lt;p&gt;For example, we need to do something only once after application is installed. We have &lt;a href="http://msdn.microsoft.com/en-us/library/system.deployment.application.applicationdeployment.isfirstrun.aspx" target="_blank"&gt;IsFirstRun&lt;/a&gt; static property of ApplicationDeployment class. We can use it:&lt;/p&gt;  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;   &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ApplicationDeployment.IsNetworkDeployed &amp;amp;&amp;amp; &lt;/pre&gt;

  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                ApplicationDeployment.CurrentDeployment.IsFirstRun)&lt;/pre&gt;

  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;

  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// do something&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Here I check, is my application installed, after that I can check for the first run. But IsFirstRun flag is &lt;strong&gt;false&lt;/strong&gt;, when application is updated, and this is an error. Solution is simple - I define bool application setting:&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image10" border="0" alt="image10" src="http://geekswithblogs.net/images/geekswithblogs_net/vitus/WindowsLiveWriter/WorkingwithClickOncesometips_D714/image10_3.png" width="414" height="40" /&gt;&lt;/p&gt;

&lt;p&gt;Default value is &lt;strong&gt;true&lt;/strong&gt;. And then I use it:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (ApplicationDeployment.IsNetworkDeployed &amp;amp;&amp;amp; Settings.Default.IsFirstRun)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// do something&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    Settings.Default.IsFirstRun = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    Settings.Default.Save();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;3. Proxy server side effects&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;And one more issue: I upload new version to server, then click on the update button. And then I get an error: updating, for example, to version 3.1, and server send installation files of version 3.0, and updating process fail. The reason is in the caching proxy server, which is used in the organization. When I clean the cache, all is ok. &lt;/p&gt;

&lt;p&gt;That's all. I'll complete my post later, if remember or find any "features".&lt;/p&gt; &lt;img src="http://geekswithblogs.net/vitus/aggbug/131712.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Vitus</dc:creator>
            <guid>http://geekswithblogs.net/vitus/archive/2009/05/04/working-with-clickonce-some-tips.aspx</guid>
            <pubDate>Mon, 04 May 2009 09:18:43 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/vitus/comments/131712.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/vitus/archive/2009/05/04/working-with-clickonce-some-tips.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/vitus/comments/commentRss/131712.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>
