<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Speaking of which... : Misc</title><link>http://blogs.msdn.com/johan/archive/tags/Misc/default.aspx</link><description>Tags: Misc</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Adding Server ROles to an IIS installation on an RODC</title><link>http://blogs.msdn.com/johan/archive/2009/05/05/adding-server-roles-to-an-iis-installation-on-an-rodc.aspx</link><pubDate>Tue, 05 May 2009 17:10:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9588868</guid><dc:creator>JohanS</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/johan/comments/9588868.aspx</comments><wfw:commentRss>http://blogs.msdn.com/johan/commentrss.aspx?PostID=9588868</wfw:commentRss><description>&lt;p&gt;In a recent case I was involved with I stumbled upon something quite interesting. The customer had set up a brand new Windows 2008 Server running IIS, and made it into a &lt;em&gt;Read Only Domain Controller&lt;/em&gt; (RODC). Having done this they now wanted to add the FTP-server Role to the existing IIS installation and found that they couldn't.&lt;/p&gt;  &lt;p&gt;The reason for this is that the RODC is quite picky about what server roles and features it will allow you to install. I recommend looking at the following articles, but they still don't cover everything.&lt;/p&gt;  &lt;p&gt;Applications That Are Known to Work with RODCs   &lt;br /&gt;&lt;a title="http://technet.microsoft.com/en-us/library/cc732790.aspx" href="http://technet.microsoft.com/en-us/library/cc732790.aspx"&gt;http://technet.microsoft.com/en-us/library/cc732790.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Planning for Application Compatibility with RODCs   &lt;br /&gt;&lt;a title="http://technet.microsoft.com/en-us/library/cc731746.aspx" href="http://technet.microsoft.com/en-us/library/cc731746.aspx"&gt;http://technet.microsoft.com/en-us/library/cc731746.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The main lesson to be learned is that although the application is listed as known to work with RODCs that doesn't necessarily mean it installs well once the server has been promoted to RODC. When it comes to FTP you have two valid options to get this working:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Install the FTP server &lt;em&gt;before&lt;/em&gt; promoting the server to RODC&lt;/li&gt;    &lt;li&gt;Install the &lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=b7f5b652-8c5c-447a-88b8-8cfc5c13f571" target="_blank"&gt;FTP Service 7.5 for IIS7&lt;/a&gt;. This is a stand-alone installer and works just fine.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;/ Johan&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9588868" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/johan/archive/tags/IIS7/default.aspx">IIS7</category><category domain="http://blogs.msdn.com/johan/archive/tags/Misc/default.aspx">Misc</category></item><item><title>Creating a game for the Zune</title><link>http://blogs.msdn.com/johan/archive/2009/03/31/creating-a-game-for-the-zune.aspx</link><pubDate>Tue, 31 Mar 2009 17:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9522814</guid><dc:creator>JohanS</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/johan/comments/9522814.aspx</comments><wfw:commentRss>http://blogs.msdn.com/johan/commentrss.aspx?PostID=9522814</wfw:commentRss><description>&lt;P&gt;I've finally had the time to sit down and create a simple game for my Zune. Rather than running off and creating a complex game requiring a lot of AI, etc I wanted to create a simple application so that I could focus on the XNA-specifics. I decided to make a Code Breaker game, also known as Master Mind. It's a pretty straight-forward game. There is no increasing difficulty curve and no fancy AI to be written, so it seemed like an excellent first attempt.&lt;/P&gt;
&lt;H1&gt;&lt;/H1&gt;
&lt;H1&gt;Prerequisites&lt;/H1&gt;
&lt;P&gt;Before I could start I needed to install the necessary software. I already had &lt;A href="http://www.microsoft.com/visualstudio/en-us/default.mspx" target=_blank mce_href="http://www.microsoft.com/visualstudio/en-us/default.mspx"&gt;Visual Studio 2008&lt;/A&gt; and the &lt;A href="http://www.zune.net/en-us/software/download/default.htm" target=_blank mce_href="http://www.zune.net/en-us/software/download/default.htm"&gt;Zune Software&lt;/A&gt;. Actually you don't need the full Visual Studio 2008. You can use the completely free &lt;A href="http://www.microsoft.com/express/download/" target=_blank mce_href="http://www.microsoft.com/express/download/"&gt;Visual C# 2008 Express Edition&lt;/A&gt; instead.&lt;/P&gt;
&lt;P&gt;You &lt;EM&gt;do&lt;/EM&gt; need to sign up as a creator in the &lt;A href="http://creators.xna.com/en-US" target=_blank mce_href="http://creators.xna.com/en-US"&gt;XNA Creators Club&lt;/A&gt;. Having done that, download the XNA Game Studio and install it. Now you're set to go.&lt;/P&gt;
&lt;H1&gt;Creating content&lt;/H1&gt;
&lt;P&gt;I gathered a few sound effects and whipped up some graphics for my project. I decided that this is what I wanted the game to look like:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.msdn.com/photos/johan/images/9522730/original.aspx" mce_src="http://blogs.msdn.com/photos/johan/images/9522730/original.aspx"&gt; &lt;/P&gt;
&lt;P&gt;The background would be customizable. I wanted to be able to cycle through the available pictures on your device.&lt;/P&gt;
&lt;H1&gt;The architecture&lt;/H1&gt;
&lt;P&gt;I decided on a fairly simple architecture for my game. In my main class (Game1.cs) I deal with the necessities. E.g. I load the sound effects that will be used throughout the application, and I create the GraphicsDeviceManager that will be used to draw to the screen. Apart from that I have two classes that I use. MainGame and MainMenu. As their names imply they either show a menu or the game screen. User input is handled in the main class and it then calls methods in the relevant classes. E.g. if the menu is shown and the user clicks on the Zune "squircle" then a menu item has been selected and the event should bubble to the MainMenu class and not to the MainGame class.&lt;/P&gt;
&lt;P&gt;I do more or less the same thing in the Draw-method of the main class. Depending on what is shown on screen individual methods of the two classes are called. And the screen is updated accordingly.&lt;/P&gt;
&lt;H1&gt;Zune features&lt;/H1&gt;
&lt;P&gt;I made sure to add at least &lt;EM&gt;some&lt;/EM&gt; of the Zune-specific features.&lt;/P&gt;
&lt;H2&gt;Pictures&lt;/H2&gt;
&lt;P&gt;Like I've already mentioned I added support for getting backgrounds from the pictures on the device.&lt;/P&gt;
&lt;H2&gt;Music&lt;/H2&gt;
&lt;P&gt;I also let the player choose a playlist to be running in the background. (Anything already playing when the game is started will continue to play until the player actually changes this setting) I could have given full access to each individual song, but building an interface for that would have been quite ridiculous. Playlists only seemed like a good idea.&lt;/P&gt;
&lt;H2&gt;Touch interface&lt;/H2&gt;
&lt;P&gt;After some usability testing I found that in order to get this game working properly I needed to decide if I should incorporate the touch/sweep interface of the Zune 2.0 devices, or if I should settle for "proper" clicks only. I decided on the latter. Mainly because I still needed to rely on the center click, and it was easy to accidentally brush away to the side when trying to click. It also ment that this application would work with &lt;EM&gt;all&lt;/EM&gt; Zunes.&lt;/P&gt;
&lt;H2&gt;Other design choices&lt;/H2&gt;
&lt;P&gt;In the beginning I let the player change colors by clicking up/down and going to the next "peg" by clicking right/left.&lt;/P&gt;
&lt;P&gt;This turned out to be a bit complicated. It was quite easy to accidentally click up or down as well which would mean that you not only moved to the next peg, but also changed the previous pegs color. I ended up using the following key settings.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Click Right - Move Right&lt;/LI&gt;
&lt;LI&gt;Click Left - Move Left&lt;/LI&gt;
&lt;LI&gt;Center Click - Change color / Click button&lt;/LI&gt;
&lt;LI&gt;Play / Pause - Change color "back"&lt;/LI&gt;
&lt;LI&gt;Back - Menu&lt;/LI&gt;&lt;/UL&gt;
&lt;H1&gt;Installing&lt;/H1&gt;
&lt;P&gt;If you want to install and run this little game you need to go through the motions filed under &lt;EM&gt;Prerequisites &lt;/EM&gt;above. Open the project in Visual Studio 2008 and dock your Zune. You should then be able to deploy the release version or debug the application directly on the device.&lt;/P&gt;
&lt;H1&gt;Download&lt;/H1&gt;
&lt;P&gt;You can download the project &lt;A href="http://blogs.msdn.com/johan/attachment/9522814.ashx" mce_href="http://blogs.msdn.com/johan/attachment/9522814.ashx"&gt;here&lt;/A&gt;&lt;/P&gt;
&lt;H1&gt;Additional screenshots&lt;/H1&gt;
&lt;P&gt;Here are some additional screenshots of the game:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.msdn.com/photos/johan/images/9522727/original.aspx" mce_src="http://blogs.msdn.com/photos/johan/images/9522727/original.aspx"&gt;&amp;nbsp;&lt;IMG src="http://blogs.msdn.com/photos/johan/images/9522647/original.aspx" mce_src="http://blogs.msdn.com/photos/johan/images/9522647/original.aspx"&gt; &lt;IMG src="http://blogs.msdn.com/photos/johan/images/9522729/original.aspx" mce_src="http://blogs.msdn.com/photos/johan/images/9522729/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;I hope you enjoy it!&lt;/P&gt;
&lt;P&gt;/ Johan&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9522814" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/johan/attachment/9522814.ashx" length="286924" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/johan/archive/tags/Misc/default.aspx">Misc</category><category domain="http://blogs.msdn.com/johan/archive/tags/Off+topic/default.aspx">Off topic</category><category domain="http://blogs.msdn.com/johan/archive/tags/XNA/default.aspx">XNA</category></item><item><title>Running a scheduled PowerShell script on a pre-Vista OS</title><link>http://blogs.msdn.com/johan/archive/2009/03/05/running-a-scheduled-powershell-script-on-a-pre-vista-os.aspx</link><pubDate>Thu, 05 Mar 2009 13:00:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9459530</guid><dc:creator>JohanS</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/johan/comments/9459530.aspx</comments><wfw:commentRss>http://blogs.msdn.com/johan/commentrss.aspx?PostID=9459530</wfw:commentRss><description>&lt;p&gt;It's been fun to see the reception that PowerShell has gotten. People are using it for tons of different stuff and the ingenuity in some of the scenarios is quite impressive. There is one thing, however, that you should be aware of. PowerShell is not an ideal candidate for execution through the Task Scheduler.&lt;/p&gt;  &lt;h1&gt;Problem&lt;/h1&gt;  &lt;p&gt;A long-running PowerShell script is being executed using the Task Scheduler. At apparently random intervals the script will fail with a &lt;span class="InlineCode"&gt;System.Management.Automation.PipelineStoppedException&lt;/span&gt;.&lt;/p&gt;  &lt;h1&gt;Cause&lt;/h1&gt;  &lt;p&gt;Looking up the exception on &lt;a href="http://msdn.microsoft.com/en-us/library/system.management.automation.pipelinestoppedexception(VS.85).aspx" target="_blank"&gt;MSDN&lt;/a&gt; might not shed any light on the situation unless you know what is happening.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;The exception thrown when a cmdlet or a Windows PowerShell provider attempts to write to the pipeline or perform a number of other Windows PowerShell operations after the pipeline has been terminated. The pipeline could have been terminated before the call was made or during the call.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;When the Task Scheduler executes a PowerShell script it needs to use the .NET Framework. When running the .NET Framework it uses the console session (Session 0). This problem occurs when someone is logged on to the root console (either physically or using Terminal Services) and logs off &lt;em&gt;while the script is executing&lt;/em&gt;.&lt;/p&gt;  &lt;h1&gt;Repro&lt;/h1&gt;  &lt;p&gt;You can easily reproduce this by creating a small script that sleeps for a while. Schedule the script to run immediately and then log off. To illustrate I've used the following script:&lt;/p&gt;  &lt;div class="SampleCode"&gt;function Main()    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Start-Transcript &amp;quot;C:\Test\Psjob.txt&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 'Start-Sleep'     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Start-Sleep (2*60)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 'Ready'     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Stop-Transcript     &lt;br /&gt;}     &lt;br /&gt;&amp;#160; &lt;br /&gt;Main&lt;/div&gt;  &lt;p&gt;When correctly executed this script will generate a transcript that looks like this:&lt;/p&gt;  &lt;div class="DebugSample"&gt;**********************    &lt;br /&gt;Windows PowerShell Transcript Start     &lt;br /&gt;Start time: 20090305111600     &lt;br /&gt;Username&amp;#160; : DOMAIN\SYSTEM     &lt;br /&gt;Machine&amp;#160;&amp;#160; : MACHINENAME (Microsoft Windows NT 5.2.3790 Service Pack 2)     &lt;br /&gt;**********************     &lt;br /&gt;Transcript started, output file is C:\Test\Psjob.txt     &lt;br /&gt;Start-Sleep     &lt;br /&gt;Ready     &lt;br /&gt;**********************     &lt;br /&gt;Windows PowerShell Transcript End     &lt;br /&gt;End time: 20090305111800     &lt;br /&gt;**********************&lt;/div&gt;  &lt;p&gt;However, if I log off the console while the script is executing I get the following transcript:&lt;/p&gt;  &lt;div class="DebugSample"&gt;**********************    &lt;br /&gt;Windows PowerShell Transcript Start     &lt;br /&gt;Start time: 20090305114300     &lt;br /&gt;Username&amp;#160; : DOMAIN\SYSTEM     &lt;br /&gt;Machine&amp;#160;&amp;#160; : MACHINENAME (Microsoft Windows NT 5.2.3790 Service Pack 2)     &lt;br /&gt;**********************     &lt;br /&gt;Transcript started, output file is C:\Test\Psjob.txt     &lt;br /&gt;Start-Sleep     &lt;br /&gt;**********************     &lt;br /&gt;Windows PowerShell Transcript End     &lt;br /&gt;End time: 20090305114340     &lt;br /&gt;**********************&lt;/div&gt;  &lt;p&gt;As you can see the transcript is properly ended as PowerShell shuts down, but if you look at the output in the middle you'll see that we never write &amp;quot;Ready&amp;quot; to the file. This is because the script was prematurely terminated.&lt;/p&gt;  &lt;h1&gt;Resolution&lt;/h1&gt;  &lt;p&gt;The quick and easy resolution is to upgrade to Vista, Windows Server 2008 or later, since as of Windows Vista the console session is no longer running in Session 0.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9459530" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/johan/archive/tags/Misc/default.aspx">Misc</category><category domain="http://blogs.msdn.com/johan/archive/tags/PowerShell/default.aspx">PowerShell</category></item><item><title>Office Automation</title><link>http://blogs.msdn.com/johan/archive/2008/10/14/office-automation.aspx</link><pubDate>Tue, 14 Oct 2008 16:15:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8999436</guid><dc:creator>JohanS</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/johan/comments/8999436.aspx</comments><wfw:commentRss>http://blogs.msdn.com/johan/commentrss.aspx?PostID=8999436</wfw:commentRss><description>&lt;p&gt;A very common scenario that keeps sprouting new heads like a hydra is Office Automation. Let me start by saying that this is &lt;strong&gt;not &lt;/strong&gt;supported.&lt;/p&gt;  &lt;p&gt;There is a KB-article number &lt;a href="http://support.microsoft.com/kb/257757/en-us"&gt;257757&lt;/a&gt; discusses this, and clearly states the following:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.&lt;/strong&gt;&lt;/p&gt;  &lt;h1&gt;&lt;strong&gt;Why is this not supported?&lt;/strong&gt;&lt;/h1&gt;  &lt;p&gt;The crucial thing to consider is the fact that Microsoft Office is designed to be an end-user, single client product. Automating Microsoft Office in a client application, using the identity and security context of the logged on client is supported, but unattended execution is not.&lt;/p&gt;  &lt;p&gt;There are a number of things that can go wrong and article &lt;a href="http://support.microsoft.com/kb/257757/en-us"&gt;257757&lt;/a&gt; lists most of them. For arguments sake, let's consider the following scenario:&lt;/p&gt;  &lt;p&gt;Your server application starts up and uses CreateObject to create an instance of MS Word. Word tries to read the settings of the current client and since your application is using the Network Service account this presents an immediate problem. There are, for example, certain methods that rely on a default printer being installed. All this can lead to serious problems. You then need to monitor the server, since Office might show a modal dialogue for some reason. The &amp;quot;install on first use&amp;quot; feature of MSI might also kick in, prompting the client to install additional features. All this would hang the current thread. Also, running one instance of Word, might be okay, but what happens when you get 100 more or less concurrent requests and each request starts up an instance of Word? MS Word is not a server, it's an excellent piece of single-client software.&lt;/p&gt;  &lt;h1&gt;So what should I do instead?&lt;/h1&gt;  &lt;p&gt;Actually, most of your problems can be resolved using HTML. I've seen applications where lines and lines of complex code were used for generating an Excel document, when it could just as well have been made using a standard HTML-table. Excel would have no problems whatsoever reading a table like the one below:&lt;/p&gt;  &lt;div class="SampleCode"&gt;&amp;lt;table&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Person&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Age&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;Pete&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;30&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;Claire&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;40&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tr&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;Average age&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;td&amp;gt;=AVERAGE(B2:B3)&amp;lt;/td&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tr&amp;gt;     &lt;br /&gt;&amp;lt;/table&amp;gt;&lt;/div&gt;  &lt;p&gt;As you can see all formatting, and even the functions, would be interpreted correctly.&lt;/p&gt;  &lt;p&gt;&lt;img src="http://blogs.msdn.com/photos/johan/images/8999380/original.aspx" /&gt; &lt;/p&gt;  &lt;p&gt;Obviously Word is great with HTML as well, so most formatting issues can quite easily be resolved using this approach.&lt;/p&gt;  &lt;h2&gt;So how do I do this?&lt;/h2&gt;  &lt;p&gt;The solution is quite easy. In order to generate an Excel document all you need to do is to create a table with the data you want, and add the following two lines to the Page_Load event of your page:&lt;/p&gt;  &lt;div class="SampleCode"&gt;Response.ContentType = &amp;quot;application/vnd.ms-excel&amp;quot;;    &lt;br /&gt;Response.AddHeader(&amp;quot;Content-Disposition&amp;quot;, &amp;quot;attachment; filename=Data.xls;&amp;quot;);&lt;/div&gt;  &lt;p&gt;The first line, sets the returned ContentType to Excel, and the second changes the filename of the returned file. This means that the client will be prompted to Open/Save the file, and the filename will be set to &amp;quot;Data.xls&amp;quot; rather than &amp;quot;Default.aspx&amp;quot; (or whatever your original document may be called.)&lt;/p&gt;  &lt;p&gt;If you wanted to return a word document you'd set the ContentType to &amp;quot;application/msword&amp;quot; instead.&lt;/p&gt;  &lt;p&gt;One little thing to consider is the fact that by default you're probably adding a lot of redundant information to your webpage. You might want to remove all excessive HTML from the page so that you remove all unnecessary headers, stylesheets, viewstate, etc. For an example, please consider the code below:&lt;/p&gt;  &lt;div class="SampleCode"&gt;Response.Clear();    &lt;br /&gt;Response.Buffer = true;     &lt;br /&gt;Response.ContentType = &amp;quot;application/vnd.ms-excel&amp;quot;;     &lt;br /&gt;Response.AddHeader(&amp;quot;Content-Disposition&amp;quot;, &amp;quot;attachment; filename=Data.xls;&amp;quot;);     &lt;br /&gt;this.EnableViewState = false;     &lt;br /&gt;System.IO.StringWriter oSw = new System.IO.StringWriter();     &lt;br /&gt;System.Web.UI.HtmlTextWriter oHtml = new System.Web.UI.HtmlTextWriter(oSw);     &lt;br /&gt;Table oTable = new Table();     &lt;br /&gt;for (int ctr = 1; ctr &amp;lt;= 10; ctr++)     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; TableRow oRow = new TableRow();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; TableCell oCell1 = new TableCell();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; oCell1.Text = ctr.ToString();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; TableCell oCell2 = new TableCell();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; oCell2.Text = (ctr*10).ToString();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; oRow.Cells.Add(oCell1);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; oRow.Cells.Add(oCell2);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; oTable.Rows.Add(oRow);     &lt;br /&gt;}     &lt;br /&gt;oTable.RenderControl(oHtml);     &lt;br /&gt;Response.Write(oSw.ToString());     &lt;br /&gt;Response.End();&lt;/div&gt;  &lt;h2&gt;&amp;#160;&lt;/h2&gt;  &lt;h2&gt;Security issues in Office 2007&lt;/h2&gt;  &lt;p&gt;If you're running Office 2007 you might come across the following error message:&lt;/p&gt;  &lt;p&gt;&amp;quot;The file you are trying to open, 'Data.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?&lt;/p&gt;  &lt;p&gt;&amp;lt;Yes&amp;gt; &amp;lt;No&amp;gt; &amp;lt;Help&amp;gt;&lt;/p&gt;  &lt;p&gt;This is completely by design. In this example Excel has noticed that though the file is named .xls it does in fact contain html, so it's warning us about this inconsistency. We might bypass this by actually changing the file extension to htm or, perhaps saving the data as comma separated values (csv) which Excel also supports, but both options would be opened directly in the browser rather than passed on to Excel, so this is a design consideration we have to take into account.&lt;/p&gt;  &lt;p&gt;There is really no way of bypassing this security feature other than manually disabling it, client-side, using a registry hack. (The key is &lt;span class="InlineCode"&gt;HKCU\Software\Microsoft\Office\12.0\Excel\Security\&lt;/span&gt; Add a DWORD named &lt;span class="InlineCode"&gt;xtensionHardening&lt;/span&gt; and set it to 0.) For obvious reasons this is not something that is generally recommended.&lt;/p&gt;  &lt;h2&gt;Other options&lt;/h2&gt;  &lt;p&gt;There are also third-party products available for generating MS Office-compatible documents, but there are also some articles in the knowledge base on the subject. For example this little gem which can easily be adopted to ASP.NET as well:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://support.microsoft.com/kb/270906/en-us"&gt;How to use ASP to generate a Rich Text Format (RTF) document to stream to Microsoft Word&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;/ Johan&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8999436" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/johan/archive/tags/Misc/default.aspx">Misc</category><category domain="http://blogs.msdn.com/johan/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/johan/archive/tags/Automation/default.aspx">Automation</category><category domain="http://blogs.msdn.com/johan/archive/tags/Office/default.aspx">Office</category></item><item><title>Back in business</title><link>http://blogs.msdn.com/johan/archive/2008/08/22/back-in-business.aspx</link><pubDate>Fri, 22 Aug 2008 18:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8887957</guid><dc:creator>JohanS</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/johan/comments/8887957.aspx</comments><wfw:commentRss>http://blogs.msdn.com/johan/commentrss.aspx?PostID=8887957</wfw:commentRss><description>&lt;P&gt;Okay, after a summer break that no doubt got a little longer than expected I am now I'm now back in the saddle again.&lt;/P&gt;
&lt;P&gt;Next post will most likely be a follow-up on the PowerShell post I wrote a while back. Stay tuned.&lt;/P&gt;
&lt;P&gt;/ Johan&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8887957" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/johan/archive/tags/Misc/default.aspx">Misc</category><category domain="http://blogs.msdn.com/johan/archive/tags/Off+topic/default.aspx">Off topic</category></item><item><title>What to do about the slow startup of web services</title><link>http://blogs.msdn.com/johan/archive/2008/04/02/what-to-do-about-the-slow-startup-of-web-services.aspx</link><pubDate>Wed, 02 Apr 2008 18:05:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8351640</guid><dc:creator>JohanS</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/johan/comments/8351640.aspx</comments><wfw:commentRss>http://blogs.msdn.com/johan/commentrss.aspx?PostID=8351640</wfw:commentRss><description>&lt;p&gt;Due to the architecture of web services and web applications they can be quite slow to start. For example on my Windows 2003-box the initial localhost-call to a simple “Hello World!”-web service takes approximately 8 seconds, while the next request is more or less immediate.&lt;/p&gt; &lt;h1&gt;Why is this?&lt;/h1&gt; &lt;p&gt;This isn’t news, really. One of the first things we learned in the early beta stages of ASP.NET was that the first request would take a little extra time due to the &lt;em&gt;Just In Time Compilation &lt;/em&gt;(JIT). This was a major change from the classic ASP architecture where everything was interpreted rather than compiled. Upon the first request the .aspx / .asmx file will be compiled (JIT’ed) into Microsoft Immediate Language (MSIL) and the resulting .dll will be moved to it’s proper location.&lt;/p&gt; &lt;p&gt;This compilation will occur every time the application pool starts causing a significantly longer response time on the first request compared to the following requests.&lt;/p&gt; &lt;h2&gt;Run-time performance over startup performance&lt;/h2&gt; &lt;p&gt;It all comes down to prioritizing run-time performance over a quick startup. Which, in my humble opinion, is a sound choice. There are, however, situations where you may feel that this is to your disadvantage. The other day I got a question from a customer who had a web service that was called quite infrequently and to him this meant that with every other request response times would be horrendous, simply because the application got recompiled.&lt;/p&gt; &lt;p&gt;For each case I get I usually do a quick search on the problem description. I don’t really expect to find the solution this way, since I can only assume that the customer has tried this as well. Instead it will likely present me with a list of troubleshooting steps that the customer has already tried as well as possible solutions that &lt;em&gt;didn’t &lt;/em&gt;fit. (Off course I still need to verify this with the customer).&lt;/p&gt; &lt;p&gt;This time I didn’t really need to do this since I was pretty sure what the cause was. Still, I was curious to see how &lt;em&gt;common&lt;/em&gt; this problem was. I honestly didn’t think this was a very common scenario, but my quick search on the web revealed the contrary. The few hits that I quickly browsed through suggested writing an application that would ping the web service in order to keep it alive. I must admit I find this quite inventive, but I really don’t think it’s the best approach. :)&lt;/p&gt; &lt;h1&gt;What to do&lt;/h1&gt; &lt;p&gt;So, what is to be done about this? Well, I’ve already mentioned that there are better solutions than pinging the web service. As I told my customer there are basically two good options:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Precompile the assemblies  &lt;li&gt;Change the settings for automatic recycling on the worker process&lt;/li&gt;&lt;/ol&gt; &lt;h2&gt;Precompiling the assemblies&lt;/h2&gt; &lt;p&gt;There is a nice little tool called Native Image Generator. (ngen.exe) It will compile the assembly into native images and installs them into the native image cache. The syntax is pretty straight-forward: &lt;span class="InlineCode"&gt;ngen.exe install [assembly]&lt;/span&gt; The problem is that once you’ve changed the assembly you’d have to precompile it again making updates a bit tedious.&lt;/p&gt; &lt;p&gt;There is also a service-version of the ngen called the Native Image Service. More information about ngen can be found at &lt;a title="http://msdn2.microsoft.com/sv-se/magazine/cc163808(en-us).aspx" href="http://msdn2.microsoft.com/sv-se/magazine/cc163808(en-us).aspx"&gt;http://msdn2.microsoft.com/sv-se/magazine/cc163808(en-us).aspx&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;Changing the recycling settings&lt;/h2&gt; &lt;p&gt;The reason why my customer was experiencing this problem was because his application pool would time out and recycle itself due to the default settings in the IIS manager. By default the worker process will recycle after 20 minutes of inactivity, so if no one has pinged your application in that time the next request will cause the application to recompile, resulting in a longer response time. By tweaking this setting in the IIS manager to something more suitable to the current rate of requests, like 40 minutes or maybe even 60 he should also be able to find a nice balance. Actually, considering the low load it would probably be a good idea to turn this setting off completely. Here’s how:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Open up IIS Manager&lt;/li&gt; &lt;li&gt;Locate the Application Pool in question&lt;/li&gt; &lt;li&gt;Right-click it and select “Properties”&lt;/li&gt; &lt;li&gt;Go to the “Performance”-tab&lt;/li&gt; &lt;li&gt;Change, or disable the “Idle timeout” setting&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;img src="http://blogs.msdn.com/photos/johan/images/8351583/original.aspx"&gt; &lt;/p&gt; &lt;p&gt;/ Johan&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8351640" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/johan/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/johan/archive/tags/Misc/default.aspx">Misc</category><category domain="http://blogs.msdn.com/johan/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/johan/archive/tags/Web+Services/default.aspx">Web Services</category></item><item><title>Did you know Windows 9 will be voice controlled only?</title><link>http://blogs.msdn.com/johan/archive/2008/04/01/did-you-know-windows-9-will-be-voice-controlled-only.aspx</link><pubDate>Tue, 01 Apr 2008 12:12:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8347691</guid><dc:creator>JohanS</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/johan/comments/8347691.aspx</comments><wfw:commentRss>http://blogs.msdn.com/johan/commentrss.aspx?PostID=8347691</wfw:commentRss><description>&lt;p&gt;Yesterday an early Alpha of Windows 9 was released on the corporate network and I couldn’t resist installing it. I started up the installation, which went very smoothly by the way, filled in the necessary details, clicked “Finish" and left it running overnight. When I arrived this morning a friendly Power Shell-window was greeting me asking me to calibrate the voice control.&lt;/p&gt; &lt;h1&gt;Working with Voice control&lt;/h1&gt; &lt;p&gt;After less than 90 minutes of training I was able to open notepad and highlight a section of text which was very exciting.&lt;/p&gt; &lt;p&gt;I wasn’t the only one who’d leapt at the opportunity to run the Alpha, so there were quite a lot of us shouting commands at our computers which caused quite a ruckus at times. It was quite impossible to keep a normal conversation over the phone with people shouting “New Paragraph!” and “Dear Mom!” left and right. Still, that’s the price you pay for being an early adopter I guess.&lt;/p&gt; &lt;p&gt;The decision to use voice command (VC) only is definitively a brave move, but I think it’s the right way to go. People have been generally hesitant to use the VC features of Vista, but I think that’s mainly due to the lack of support. Forcing developers to think outside the box and adapt their software for this new means of control is definitively the way of the future. Just like Nintendo demands that developers adapt to their unorthodox controller for the Wii, I’m sure Microsoft will start a new era in computer software with this revolutionary step.&lt;/p&gt; &lt;p&gt;&lt;img src="http://blogs.msdn.com/photos/johan/images/8347654/original.aspx"&gt; &lt;/p&gt; &lt;p&gt;&lt;em&gt;After only 90 minutes I was able to highlight text in Notepad.&lt;/em&gt; &lt;/p&gt; &lt;h1&gt;Other cool features&lt;/h1&gt; &lt;p&gt;Apart from the VC there were a lot of other cool features that I really enjoyed.&lt;/p&gt; &lt;h2&gt;Xbox 360 emulator&lt;/h2&gt; &lt;p&gt;The next Windows will ship with a complete Xbox 360 emulator. It is basically a tweaked version of Virtual PC that allows you to run console games on your PC. I fired it up and played a little Halo 3, but I must say I was a bit disappointed. The voice control needs additional working on. It quickly got tiresome yelling at Master Chief and my cries of “go forward”, “go forward”, “fire”, “turn around”, “left”, “left”, “fire” and “reload” made it quite hard for me to disguise to my boss what I was doing. One of my colleagues had just picked up a case regarding twelve crashed IIS-servers and an on-line banking application. He was on the phone trying to sort the situation out and started giving me dirty looks after a while. I also must add that the whole Xbox-live experience was somehow diminished. The usual chatter was sadly missing since we were all so busy shouting directions. Still, it’s only an alpha, so I’m certain these things will be addressed.&lt;/p&gt; &lt;h2&gt;&lt;/h2&gt; &lt;h2&gt;Boss key&lt;/h2&gt; &lt;p&gt;Another nice addition that also seems to heir from the Home Entertainment Division is a boss key. It's really quite surprising that we had to reach the 9th installment of Windows before this was introduced. All I had to do was say "Hi boss" and the screen would immediately present a blue-screen. This is useful in more ways than one. Not only does it quickly hide your Halo 3 session from view, but it also gives you a reasonable explanation as to why your productivity has been somewhat lacking. It's a pure stroke of genius.&lt;/p&gt; &lt;p&gt;On one occasion it turned out that the alpha had blue-screened &lt;em&gt;for real&lt;/em&gt; due to some conflict with my graphics driver. It took me almost 15 minutes to realize this after having spent several fruitless attempts trying to wake it up from boss mode. :)&lt;/p&gt; &lt;h1&gt;Release date&lt;/h1&gt; &lt;p&gt;From what I've heard the planned release date is April 1st 2009, exactly one year from now.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;/ Johan&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8347691" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/johan/archive/tags/Did+you+know_3F00_/default.aspx">Did you know?</category><category domain="http://blogs.msdn.com/johan/archive/tags/Misc/default.aspx">Misc</category></item><item><title>Games on the Zune</title><link>http://blogs.msdn.com/johan/archive/2008/02/21/games-on-the-zune.aspx</link><pubDate>Thu, 21 Feb 2008 13:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7834732</guid><dc:creator>JohanS</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/johan/comments/7834732.aspx</comments><wfw:commentRss>http://blogs.msdn.com/johan/commentrss.aspx?PostID=7834732</wfw:commentRss><description>&lt;P&gt;I was really excited to hear that XNA 3.0 will support game development for the Zune. I've always been interested in XNA and have secretly dreamed of writing my own Xbox 360 game ever since the alpha. Sadly I just don't seem to find the spare time.&lt;/P&gt;
&lt;H1&gt;Key features&lt;/H1&gt;
&lt;P&gt;As I looked at the info released on the &lt;A href="http://creators.xna.com/whatsnew.aspx" mce_href="http://creators.xna.com/whatsnew.aspx"&gt;XNA Creators Club&lt;/A&gt;&amp;nbsp;these are the features that caught my interest:&lt;/P&gt;
&lt;H2&gt;2D graphics&lt;/H2&gt;
&lt;P&gt;Well this was a no-brainer. I don't think anyone expected the Zune to have a full-featured 3D API available.&lt;/P&gt;
&lt;H2&gt;Support for all Zunes&lt;/H2&gt;
&lt;P&gt;This was really cool. XNA Game Studio will not only support the second generation Zunes (Zune 4/8 &amp;amp; Zune 80) but the &lt;EM&gt;first generation&lt;/EM&gt; devices as well (Zune 30).&lt;/P&gt;
&lt;H2&gt;Access to music and Pictures&lt;/H2&gt;
&lt;P&gt;As long as the music isn't DRM protected it's available to use in the application.&lt;/P&gt;
&lt;H2&gt;Wireless support&lt;/H2&gt;
&lt;P&gt;This is probably the coolest.&amp;nbsp;I'm really glad they got this included from the start.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know this is a bit outside my normal scope. I just thought it was some pretty cool news and I didn't see them coming...&lt;/P&gt;
&lt;P&gt;/ Johan&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7834732" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/johan/archive/tags/Misc/default.aspx">Misc</category></item></channel></rss>