<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Bits and Pieces</title>
		<link>https://bits.strawjackal.org/</link>
		<description>Recent content on Bits and Pieces</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Sun, 21 Feb 2016 08:22:02 +0200</lastBuildDate>
		
			<atom:link href="https://bits.strawjackal.org/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>When Not-True Doesn’t Equal False</title>
				<link>https://bits.strawjackal.org/102/</link>
				<pubDate>Sun, 21 Feb 2016 08:22:02 +0200</pubDate>
				<guid>https://bits.strawjackal.org/102/</guid>
				<description>&lt;p&gt;There is a strangely common, reoccurring bug I’ve seen return, again and again, in most projects I’ve worked on in recent years. I call it the “Not True != False” bug, and it crops up, usually, when passing query parameters to a search service of some sort, when you want to search for entities who match a certain condition, and you end up not being able &lt;strong&gt;not&lt;/strong&gt; to search by that condition.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Snippet of the Day: AsSingleton</title>
				<link>https://bits.strawjackal.org/94/</link>
				<pubDate>Thu, 26 Nov 2015 14:03:15 +0200</pubDate>
				<guid>https://bits.strawjackal.org/94/</guid>
				<description>&lt;p style=&#34;direction: rtl; text-align: right;&#34;&gt;מכירים את זה שאתם צריכים להעביר ערך בודד לפונקציה שמצפה לקבל מערך או רשימה? נמאס לכם לכתוב כל פעם&lt;/p&gt;&#xD;&#xA;&lt;pre style=&#34;color: #000000; background: #ffffff;&#34;&gt;&lt;span style=&#34;color: #800000; font-weight: bold;&#34;&gt;var&lt;/span&gt; myList &lt;span style=&#34;color: #808030;&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #800000; font-weight: bold;&#34;&gt;new&lt;/span&gt; List&lt;span style=&#34;color: #808030;&#34;&gt;&amp;lt;&lt;/span&gt;MyClass&lt;span style=&#34;color: #808030;&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color: #800080;&#34;&gt;{&lt;/span&gt; myObject &lt;span style=&#34;color: #800080;&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color: #800080;&#34;&gt;;&lt;/span&gt;&#xD;&#xA;&lt;/pre&gt;&#xD;&#xA;&lt;p style=&#34;direction: rtl; text-align: right;&#34;&gt;רק בשביל לקבל רשימה בת איבר אחד? אל דאגה, שוועתכם נשמעה!&lt;/p&gt;&#xD;&#xA;&lt;p style=&#34;direction: rtl; text-align: right;&#34;&gt;אני פותח את פינת ה-Snippet of the Day עם שני פונקציות קטנטנות להפוך את הקוד לקריא יותר. אפשר גם בכלל לשנות את השם ל-AsList ו-AsArray לקבל קוד עוד יותר קצר, אבל העדפתי את הגרסה המפורשת יותר.&lt;/p&gt;</description>
			</item>
			<item>
				<title>איך לשמור על אותיות גדולות וקטנות בעולם עוין</title>
				<link>https://bits.strawjackal.org/89/</link>
				<pubDate>Tue, 24 Nov 2015 23:17:03 +0200</pubDate>
				<guid>https://bits.strawjackal.org/89/</guid>
				<description>&lt;p style=&#34;direction: rtl; text-align: right;&#34;&gt;כמתכנת C#, אני רגיל לחשיבות של case sensitivity - משתנים בשם test ו-TEST הם שונים ונפרדים. גם ב-XML וב-JSON, שני הפורמטים הנפוצים לתעבורת מידע, נהוג להקפיד על case sensitivity בשמות של השדות/אלמנטים. ולרוב זה לא בעיה - אתה שומר עם case מסוים ואז קורא באותו case, והכל בסדר.&lt;/p&gt;&#xD;&#xA;&lt;p style=&#34;direction: rtl; text-align: right;&#34;&gt;אבל היום נתקלתי בבעיה. במערכת מורכבת ומבוזרת שעליה אני עובד, מידע מעובד בקצה אחד, שדות נשמרים, והישות כולה נשמרת בתוך מסד נתונים מסוים, כשכל ערכי השדות שלה נשמרים תמיד ב-UPPERCASE. אבל היום הייתי צריך לשמור בתוך כמה שדות מידע שה-case שלו היה חשוב לשימור - במקרה הזה, שם קובץ מתוך שרת לינוקס עם מערכת קבצים רגישה ל-case, ובלוק של XML שגם בו הייתי חייב לשמור על גודל האותיות. אבל המנגנון היחיד שהיה לי לשמור את המידע בשביל להוציא אותו ולפעול עליו בקצה השני של המערכת לא משמר את ה-case של הנתונים. אז מה עושים?&lt;/p&gt;</description>
			</item>
			<item>
				<title>Building a Nullable ComboBox</title>
				<link>https://bits.strawjackal.org/80/</link>
				<pubDate>Mon, 04 Aug 2014 15:38:43 +0200</pubDate>
				<guid>https://bits.strawjackal.org/80/</guid>
				<description>&lt;p&gt;I like WPF. It has a bit of a learning curve, but once you get over it, you have an extremely extensible UI model that you can tweak very deeply. Unfortunately, this mindset made Microsoft leave many of the built-in controls with some missing functionality, apparently with the intention that people extend it if they felt like it. &lt;/p&gt; &lt;p&gt;One painfully missing piece, for me, was the ability to clear a ComboBox’s selection back to null, for a non-mandatory selection. You can add a Null value to the ComboBox’s ItemSource, but you can’t &lt;em&gt;select&lt;/em&gt; it – selecting a null-backed value will simply return the last-selected value. &lt;/p&gt; &lt;p&gt;After viewing some less than optimal options on StackOverflow, I decided to roll my own clearable, nullable ComboBox, using a combination of two techniques – editing the ComboBox’s ControlTemplate to add a little “x” button to the SelectionBox, and a set of Attached Properties to apply the logic to the ComboBox in question.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Attaching on Startup</title>
				<link>https://bits.strawjackal.org/106/</link>
				<pubDate>Thu, 23 Jan 2014 07:21:35 +0200</pubDate>
				<guid>https://bits.strawjackal.org/106/</guid>
				<description>&lt;p&gt;Here’s a neat trick I stumbled onto that can make life a lot easier – in our development workstations, certainly, and even in a pinch on staging and testing machines:&lt;/p&gt;&#xA;&lt;p&gt;How many times have you wished you could attach to a process immediately when it launchs? If we’re running a simple EXE, we can launch it from the debugger directly, but if we’re trying to debug a Windows Service, a scheduled task or a sub-process that is launched automatically, it isn’t that simple. We can try to press CTRL-ALT-P as quickly as possible, but that will almost always miss the very beginning. We can add a call to &lt;span style=&#34;font-family: Consolas;&#34;&gt;System.Diagnostics.Debugger.Launch()&lt;/span&gt; to our &lt;span style=&#34;font-family: Consolas;&#34;&gt;Application_Startup()&lt;/span&gt; function (or equivalent), but that’s polluting production code with debugging statements, and it isn’t really something we can send over to a staging or QA machine.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Quick and Dirty Code Timing</title>
				<link>https://bits.strawjackal.org/73/</link>
				<pubDate>Wed, 30 Oct 2013 13:27:52 +0200</pubDate>
				<guid>https://bits.strawjackal.org/73/</guid>
				<description>&lt;p&gt;When looking to optimize our code, the first and best advice we should keep in mind is this: Measure. Don’t optimize before you know what takes time, and then only optimize where it makes sense. &lt;/p&gt; &lt;p&gt;Measuring can be done in many ways. Using Performance Counters, high-performance timers and stress tests. But often, especially in early iterations, we just want to get a ballpark figure for how long a bit of code takes. Maybe a low-level database call that gets used a lot, maybe as a wrapper in our initialization code to know what should be moved to lazy evaluation. In those cases, the quickest approach is to simply use .NET’s System.Diagnostics.Stopwatch class. Start it, stop it, and print out the timing.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Not-So-Lazy Static Constructors in C# 4.0</title>
				<link>https://bits.strawjackal.org/71/</link>
				<pubDate>Mon, 25 Feb 2013 11:46:02 +0200</pubDate>
				<guid>https://bits.strawjackal.org/71/</guid>
				<description>&lt;p&gt;A &lt;a href=&#34;http://www.hmemcpy.com/blog/&#34;&gt;coworker&lt;/a&gt; pointed me towards an &lt;a href=&#34;http://msmvps.com/blogs/jon_skeet/archive/2010/01/26/type-initialization-changes-in-net-4-0.aspx&#34;&gt;interesting blog post&lt;/a&gt; by John Skeet about the changed behavior of static constructors in C# 4.0 (yes, I know, it’s been a few years now, but I never ran into it).&lt;/p&gt; &lt;p&gt;It seems that C# 4.0 now tries to be lazier when instantiated static fields. So if I have a side-effect free static method that doesn’t touch any members, calling it will not bother initializing the static fields. From Skeet’s post:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Not-So-Lazy Static Constructors in C# 4.0</title>
				<link>https://bits.strawjackal.org/107/</link>
				<pubDate>Mon, 25 Feb 2013 09:55:04 +0200</pubDate>
				<guid>https://bits.strawjackal.org/107/</guid>
				<description>&lt;p align=&#34;left&#34;&gt;A &lt;a href=&#34;http://www.hmemcpy.com/blog/&#34;&gt;coworker&lt;/a&gt; pointed me towards an &lt;a href=&#34;http://msmvps.com/blogs/jon_skeet/archive/2010/01/26/type-initialization-changes-in-net-4-0.aspx&#34;&gt;interesting blog post&lt;/a&gt; by John Skeet about the changed behavior of static constructors in C# 4.0 (yes, I know, it’s been a few years now, but I never ran into it).&lt;/p&gt;  &lt;p align=&#34;left&#34;&gt;It seems that C# 4.0 now tries to be lazier when instantiated static fields. So if I have a side-effect free static method that doesn’t touch any members, calling it will not bother initializing the static fields. From Skeet’s post:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Attaching on Startup</title>
				<link>https://bits.strawjackal.org/70/</link>
				<pubDate>Wed, 30 Jan 2013 14:34:55 +0200</pubDate>
				<guid>https://bits.strawjackal.org/70/</guid>
				<description>&lt;p&gt;Here’s a neat trick I stumbled onto that can make life a lot easier – in our development workstations, certainly, and even in a pinch on staging and testing machines:&lt;/p&gt;&#xA;&lt;p&gt;How many times have you wished you could attach to a process immediately when it launchs? If we’re running a simple EXE, we can launch it from the debugger directly, but if we’re trying to debug a Windows Service, a scheduled task or a sub-process that is launched automatically, it isn’t that simple. We can try to press CTRL-ALT-P as quickly as possible, but that will almost always miss the very beginning. We can add a call to &lt;span style=&#34;font-family: Consolas;&#34;&gt;System.Diagnostics.Debugger.Launch()&lt;/span&gt; to our &lt;span style=&#34;font-family: Consolas;&#34;&gt;Application_Startup()&lt;/span&gt; function (or equivalent), but that’s polluting production code with debugging statements, and it isn’t really something we can send over to a staging or QA machine.&lt;/p&gt;</description>
			</item>
			<item>
				<title>האם עוד צריך את VB.NET לתכנת מול אופיס?</title>
				<link>https://bits.strawjackal.org/63/</link>
				<pubDate>Tue, 29 Jan 2013 22:29:12 +0200</pubDate>
				<guid>https://bits.strawjackal.org/63/</guid>
				<description>&lt;p dir=&#34;rtl&#34; align=&#34;right&#34;&gt;עברו כמה שנים מאז שעבדתי עם Visual Basic.NET, והייתי בטוח שבימינו, ב-2013, נגמרו כבר הויכוחים של “איזו שפה יותר טובה”. שתיהן שפות עם יכולות דומות, והבחירה ביניהן היא בעיקר העדפה סגנונית. אבל מידי פעם אני עדיין רואה בפורומים או ב-Stack Overflow שאלה בנוגע ליתרונות של שפה אחת על השניה, וספציפית על יכולות ה-COM Interop של VB. האם היא באמת שפה נוחה יותר?&lt;/p&gt;&#xD;&#xA;&lt;p dir=&#34;rtl&#34; align=&#34;right&#34;&gt;&lt;strong&gt;המצב טרום .NET 4.0&lt;/strong&gt;&lt;/p&gt;&#xD;&#xA;&lt;p dir=&#34;rtl&#34; align=&#34;right&#34;&gt;לפני .NET 4.0 (שיצאה, יש להזכיר, לפני כמעט 3 שנים), התשובה היתה “כן”, אם כי “כן” קצת דחוק. VB הגיעה מתוך עולם ה-Late Binding, ולא היה לה בעיה להעביר לרכיב רק חלק מהפרמטרים שהם צריכים, ולדאוג לשאר לברירות מחדל מאחורי הקלעים. היתרון הזה היה בולט במיוחד כשעובדים מול אובייקטים של אופיס, שמכילים מתודות שמקבלות חמישה, עשרה, ולפעמים שישה-עשר פרמטרים אופציונאליים, כשברוב המקרים אנחנו נרצה להעביר רק אחד או שניים מהם, אם בכלל. ההבדל בין C# ל-VB במקרה כזה הוא ההבדל בין הקוד הזה ב-C#:&lt;/p&gt;</description>
			</item>
			<item>
				<title>האם עוד צריך את VB.NET לתכנת מול אופיס?</title>
				<link>https://bits.strawjackal.org/108/</link>
				<pubDate>Tue, 29 Jan 2013 20:37:17 +0200</pubDate>
				<guid>https://bits.strawjackal.org/108/</guid>
				<description>&lt;p dir=&#34;rtl&#34; align=&#34;right&#34;&gt;עברו כמה שנים מאז שעבדתי עם Visual Basic.NET, והייתי בטוח שבימינו, ב-2013, נגמרו כבר הויכוחים של “איזו שפה יותר טובה”. שתיהן שפות עם יכולות דומות, והבחירה ביניהן היא בעיקר העדפה סגנונית. אבל מידי פעם אני עדיין רואה בפורומים או ב-Stack Overflow שאלה בנוגע ליתרונות של שפה אחת על השניה, וספציפית על יכולות ה-COM Interop של VB. האם היא באמת שפה נוחה יותר?&lt;/p&gt;&#xD;&#xA;&lt;p dir=&#34;rtl&#34; align=&#34;right&#34;&gt;&lt;strong&gt;המצב טרום .NET 4.0&lt;/strong&gt;&lt;/p&gt;&#xD;&#xA;&lt;p dir=&#34;rtl&#34; align=&#34;right&#34;&gt;לפני .NET 4.0 (שיצאה, יש להזכיר, לפני כמעט 3 שנים), התשובה היתה “כן”, אם כי “כן” קצת דחוק. VB הגיעה מתוך עולם ה-Late Binding, ולא היה לה בעיה להעביר לרכיב רק חלק מהפרמטרים שהם צריכים, ולדאוג לשאר לברירות מחדל מאחורי הקלעים. היתרון הזה היה בולט במיוחד כשעובדים מול אובייקטים של אופיס, שמכילים מתודות שמקבלות חמישה, עשרה, ולפעמים שישה-עשר פרמטרים אופציונאליים, כשברוב המקרים אנחנו נרצה להעביר רק אחד או שניים מהם, אם בכלל. ההבדל בין C# ל-VB במקרה כזה הוא ההבדל בין הקוד הזה ב-C#:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Surviving the Enterprise Application</title>
				<link>https://bits.strawjackal.org/62/</link>
				<pubDate>Tue, 01 Jan 2013 23:50:48 +0200</pubDate>
				<guid>https://bits.strawjackal.org/62/</guid>
				<description>&lt;p&gt;Many of us have worked on this sort of application: “The Monster”, “The Big One”, “The Behemoth”, or simply “The Enterprise Application”. You know the kind I mean: it’s a mess of dozens of projects and solutions. It requires setting up three console applications and two databases just so you can debug something (god forbid you could just launch it from within Visual Studio), and after making changes to some code, getting the updates DLLs to the right place can be a headache. The sheer amount of time wasted on getting around the architecture can be daunting, and changing this behavior, especially when the app has years of crud and not enough tests, is not something you want to take on yourself.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Remote Debugging through fire, snow or fog</title>
				<link>https://bits.strawjackal.org/54/</link>
				<pubDate>Thu, 19 Jul 2012 11:30:55 +0200</pubDate>
				<guid>https://bits.strawjackal.org/54/</guid>
				<description>&lt;p&gt;Remote Debugging in Visual Studio is a wonderful feature, especially during the later stages of testing and deployment, and even (if all else fails) when in production, but getting it to work is rarely smooth. Everything is fine if both the computer running VS and the one running the application are in the same domain, but when they aren’t, things start to break, fast. I&lt;/p&gt;  &lt;p&gt;So for those stuck debugging remote applications in different domains, here’s a quick guide to east the pain. &lt;/p&gt;</description>
			</item>
			<item>
				<title>Remote Debugging through fire, snow or fog</title>
				<link>https://bits.strawjackal.org/109/</link>
				<pubDate>Thu, 19 Jul 2012 10:23:10 +0200</pubDate>
				<guid>https://bits.strawjackal.org/109/</guid>
				<description>&lt;p&gt;Remote Debugging in Visual Studio is a wonderful feature, especially during the later stages of testing and deployment, and even (if all else fails) when in production, but getting it to work is rarely smooth. Everything is fine if both the computer running VS and the one running the application are in the same domain, but when they aren’t, things start to break, fast. I&lt;/p&gt;  &lt;p&gt;So for those stuck debugging remote applications in different domains, here’s a quick guide to east the pain. &lt;/p&gt;</description>
			</item>
			<item>
				<title>ArcGIS–Getting the Legend Labels out</title>
				<link>https://bits.strawjackal.org/110/</link>
				<pubDate>Tue, 27 Mar 2012 08:18:19 +0200</pubDate>
				<guid>https://bits.strawjackal.org/110/</guid>
				<description>&lt;p&gt;Working with ESRI’s ArcGIS package, especially the WPF API, can be confusing. There’s the REST API, the SOAP APIs, and the WPF classes themselves, which expose some web service calls and information, but not everything. With all that, it can be hard to find specific features between the different options. Some functionality is handed to you on a silver platter, while some is maddeningly hard to implement.&lt;/p&gt;  &lt;p&gt;Today, for instance, I was working on adding a Legend control to my map-based WPF application, to explain the different symbols that can appear on the map.&lt;/p&gt;</description>
			</item>
			<item>
				<title>ArcGIS–Getting the Legend Labels out</title>
				<link>https://bits.strawjackal.org/43/</link>
				<pubDate>Mon, 26 Mar 2012 23:59:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/43/</guid>
				<description>&lt;p&gt;Working with ESRI’s ArcGIS package, especially the WPF API, can be confusing. There’s the REST API, the SOAP APIs, and the WPF classes themselves, which expose some web service calls and information, but not everything. With all that, it can be hard to find specific features between the different options. Some functionality is handed to you on a silver platter, while some is maddeningly hard to implement.&lt;/p&gt;  &lt;p&gt;Today, for instance, I was working on adding a Legend control to my map-based WPF application, to explain the different symbols that can appear on the map. &lt;/p&gt;</description>
			</item>
			<item>
				<title>The Case of the Unexpected Expected Exception</title>
				<link>https://bits.strawjackal.org/111/</link>
				<pubDate>Thu, 01 Mar 2012 19:20:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/111/</guid>
				<description>&lt;p&gt;“NUnit is being problematic again”, they told me when I came to visit the project. “When running unattended it’s not catching assertions properly and the test is coming up green, but when stepping through in the debugger, it works fine.”. It’s nice, when getting a passing test is acknowledged as a bad thing, at least when you don’t expect it to be. In this case, though, the fault wasn’t really with NUnit.&lt;/p&gt;</description>
			</item>
			<item>
				<title>The Case of the Expected Unexpected Exception</title>
				<link>https://bits.strawjackal.org/38/</link>
				<pubDate>Thu, 01 Mar 2012 11:58:53 +0200</pubDate>
				<guid>https://bits.strawjackal.org/38/</guid>
				<description>&lt;p&gt;“NUnit is being problematic again”, they told me when I came to visit the project. “When running unattended it’s not catching assertions properly and the test is coming up green, but when stepping through in the debugger, it works fine.”. It’s nice, when getting a passing test is acknowledged as a bad thing, at least when you don’t expect it to be. In this case, though, the fault wasn’t really with NUnit.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Open Source Vigilantes?</title>
				<link>https://bits.strawjackal.org/35/</link>
				<pubDate>Sun, 26 Feb 2012 12:37:19 +0200</pubDate>
				<guid>https://bits.strawjackal.org/35/</guid>
				<description>&lt;p&gt;&amp;lt;Placeholder for StackOverflow Weekday counter&amp;gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Open Source Vigilantes?</title>
				<link>https://bits.strawjackal.org/112/</link>
				<pubDate>Sun, 26 Feb 2012 10:37:20 +0200</pubDate>
				<guid>https://bits.strawjackal.org/112/</guid>
				<description>&lt;Placeholder for StackOverflow Weekday counter&gt;</description>
			</item>
			<item>
				<title>Testing cross-post.</title>
				<link>https://bits.strawjackal.org/31/</link>
				<pubDate>Thu, 23 Feb 2012 16:44:13 +0200</pubDate>
				<guid>https://bits.strawjackal.org/31/</guid>
				<description>&lt;p&gt;Please ignore.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Blog</title>
				<link>https://bits.strawjackal.org/blog/</link>
				<pubDate>Sun, 12 Feb 2012 11:48:52 +0200</pubDate>
				<guid>https://bits.strawjackal.org/blog/</guid>
				<description></description>
			</item>
			<item>
				<title>Tools &amp; Projects</title>
				<link>https://bits.strawjackal.org/homepage/</link>
				<pubDate>Sun, 12 Feb 2012 11:48:18 +0200</pubDate>
				<guid>https://bits.strawjackal.org/homepage/</guid>
				<description></description>
			</item>
			<item>
				<title>Moq, Callbacks and Out parameters: a particularly tricky edge case</title>
				<link>https://bits.strawjackal.org/113/</link>
				<pubDate>Fri, 07 Oct 2011 00:16:03 +0200</pubDate>
				<guid>https://bits.strawjackal.org/113/</guid>
				<description>&lt;p&gt;In my current project we’re using &lt;a href=&#34;http://code.google.com/p/moq&#34;&gt;Moq&lt;/a&gt; as our mocking framework for unit testing. It’s a very nice package – very simple, very intuitive for someone who has his wrapped around basic mocking concepts, but tonight I ran into an annoying limitation that, while rare, impeded my tests considerably.&lt;/p&gt;  &lt;p&gt;Consider the following code:&lt;/p&gt;  &lt;pre style=&#34;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 567px; padding-right: 5px; height: 390px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&#34;&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;  1: &lt;span style=&#34;color: #0000ff&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color: #0000ff&#34;&gt;interface&lt;/span&gt; IOut&#xD;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;  2: {&#xD;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;  3:    &lt;span style=&#34;color: #0000ff&#34;&gt;void&lt;/span&gt; DoOut (&lt;span style=&#34;color: #0000ff&#34;&gt;out&lt;/span&gt; &lt;span style=&#34;color: #0000ff&#34;&gt;string&lt;/span&gt; outval);&#xD;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;  4: }&#xD;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;  5: &#xD;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;  6: [Test]&#xD;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;  7: &lt;span style=&#34;color: #0000ff&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color: #0000ff&#34;&gt;void&lt;/span&gt; TestMethod()&#xD;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;  8: {&#xD;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;  9:   var mock = &lt;span style=&#34;color: #0000ff&#34;&gt;new&lt;/span&gt; Mock&lt;IOut&gt;();&#xD;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt; 10:   &lt;span style=&#34;color: #0000ff&#34;&gt;string&lt;/span&gt; outVal = &#34;&lt;span style=&#34;color: #8b0000&#34;&gt;&lt;/span&gt;&#34;;&#xD;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt; 11:   mock.Setup(&lt;span style=&#34;color: #0000ff&#34;&gt;out&lt;/span&gt; =&gt; &lt;span style=&#34;color: #0000ff&#34;&gt;out&lt;/span&gt;.DoOut(&lt;span style=&#34;color: #0000ff&#34;&gt;out&lt;/span&gt; outVal))&#xD;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #ffff00; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt; 12:       .Callback&lt;&lt;span style=&#34;color: #0000ff&#34;&gt;string&lt;/span&gt;&gt;(theValue =&gt; DoSomethingWithTheValue(theValue));&#xD;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt; 13: }&lt;/pre&gt;&lt;/pre&gt;&#xD;&#xA;&lt;p&gt;What this code SHOULD do is create a mock object for the IOut interface that, when called with an out parameter, both assigns a value to it, and does something with the value in the Callback. &lt;/p&gt;</description>
			</item>
			<item>
				<title>WPF: Snooping Attached Properties</title>
				<link>https://bits.strawjackal.org/114/</link>
				<pubDate>Thu, 01 Sep 2011 11:28:20 +0200</pubDate>
				<guid>https://bits.strawjackal.org/114/</guid>
				<description>&lt;p&gt;When developing WPF applications, &lt;a href=&#34;http://snoopwpf.codeplex.com/&#34;&gt;Snoop&lt;/a&gt; is a wonderful tool that can let us see our visual tree at runtime, and find errors in data binding that are otherwise hard to track down in debugging. However, Snoop has an annoying limitation – it can’t show us data-bound Attached Properties. Let’s say we have the following XAML:   &lt;pre style=&#34;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&#34;&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;&lt;span style=&#34;color: #0000ff&#34;&gt;&amp;laquo;/span&amp;gt;&lt;span style=&#34;color: #800000&#34;&gt;Canvas&lt;/span&gt;&lt;span style=&#34;color: #0000ff&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;   &lt;span style=&#34;color: #0000ff&#34;&gt;&amp;laquo;/span&amp;gt;&lt;span style=&#34;color: #800000&#34;&gt;Button&lt;/span&gt; &lt;span style=&#34;color: #ff0000&#34;&gt;Canvas&lt;/span&gt;.&lt;span style=&#34;color: #ff0000&#34;&gt;Left&lt;/span&gt;=&lt;span style=&#34;color: #0000ff&#34;&gt;&amp;quot;{Binding Location.X}&amp;quot;&lt;/span&gt;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;           &lt;span style=&#34;color: #ff0000&#34;&gt;Canvas&lt;/span&gt;.&lt;span style=&#34;color: #ff0000&#34;&gt;Top&lt;/span&gt;=&lt;span style=&#34;color: #0000ff&#34;&gt;&amp;quot;{Binding Location.Y&amp;quot;&lt;/span&gt;}&lt;span style=&#34;color: #0000ff&#34;&gt;/&amp;gt;&lt;/span&gt;&#xA;&lt;/pre&gt;&lt;pre style=&#34;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px&#34;&gt;&lt;span style=&#34;color: #0000ff&#34;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#34;color: #800000&#34;&gt;Canvas&lt;/span&gt;&lt;span style=&#34;color: #0000ff&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Saving Your Settings</title>
				<link>https://bits.strawjackal.org/115/</link>
				<pubDate>Tue, 10 Feb 2009 14:38:51 +0200</pubDate>
				<guid>https://bits.strawjackal.org/115/</guid>
				<description>&lt;p&gt;Tomorrow I am bidding my laptop farewell, and will soon buy me a new one. This results in what I like to call Settings Anxiety. I spend months tuning various aspects of my computer to my liking, and starting afresh with a new machine is wearisome. There are solutions to this, of course. I can make a full settings backup using &lt;a href=&#34;http://support.microsoft.com/kb/928635&#34;&gt;Windows Easy Transfer&lt;/a&gt; or some such tool to store my settings and registry information and reload them on my new computer. I am, however, leery of it. First of all, I don’t trust WET to backup everything, especially 3rd party settings and application data. Secondly, I don’t want to copy all the cruft that’s accumulated in my user settings. One advantage to leaving the old computer is to start fresh.&lt;/p&gt;</description>
			</item>
			<item>
				<title>About Me</title>
				<link>https://bits.strawjackal.org/about/</link>
				<pubDate>Sun, 25 Jan 2009 05:30:47 +0200</pubDate>
				<guid>https://bits.strawjackal.org/about/</guid>
				<description>&lt;p&gt;Bits &amp;amp; Pieces is part blog, part portfolio. A place for me to share my technical rants and raves about technology and programming (mostly C#/.NET), as originally published on &lt;a href=&#34;http://weblogs.asp.net/avnerk&#34;&gt;weblogs.asp.net&lt;/a&gt;. Additionally, it&amp;rsquo;s a place to post various tools, open-source projects and code snippets that I&amp;rsquo;m working on, or have released to the public.&lt;/p&gt;&#xA;&lt;p&gt;Feel free to contact me about this site or any project in it, if you&amp;rsquo;re trying to get it to work.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Tales from the Unmanaged Side – System.String –&gt; char* (pt. 2)</title>
				<link>https://bits.strawjackal.org/116/</link>
				<pubDate>Tue, 13 Jan 2009 15:04:17 +0200</pubDate>
				<guid>https://bits.strawjackal.org/116/</guid>
				<description>&lt;p&gt;A while ago, I &lt;a href=&#34;http://weblogs.asp.net/avnerk/archive/2007/08/28/more-tales-from-the-unmanaged-side-system-string-gt-char.aspx&#34;&gt;posted an entry&lt;/a&gt; about marshalling a managed System.String into an unmanaged C string, specifically a plain char*. The solution I suggested, back in 2007, involved calling Marshal::StringToHGlobalAuto method to allocate memory and copy the string data into it, and then cast the HGlobal pointer into a char*. &lt;/p&gt;  &lt;p&gt;It seems that in Visual Studio 2008 a new way of doing it was added, as part of the new &lt;a href=&#34;http://msdn.microsoft.com/en-us/library/bb384865.aspx&#34;&gt;Marshalling Library&lt;/a&gt;. This library provides a whole set of conversions between System.String and popular unmanaged string representations, like char*, wchar_t*, BSTR, CStringT&lt;wchar_t&gt; and others I am even less familiar with. &lt;/p&gt;</description>
			</item>
			<item>
				<title>Static Constructor throws the same exception again and again</title>
				<link>https://bits.strawjackal.org/117/</link>
				<pubDate>Tue, 16 Dec 2008 10:17:39 +0200</pubDate>
				<guid>https://bits.strawjackal.org/117/</guid>
				<description>&lt;p&gt;Here’s a little gotcha I ran into today – if you have code in a class’s static constructor that throws an exception, we will get a TypeInitializationException with the original exception as the InnerException – so far, nothing new. &lt;/p&gt;  &lt;p&gt;However, if we keep on calling methods on that object, we’ll keep receiving TypeInitializationExceptions. If it cannot be initialized, it cannot be called. Every time we try, we’ll receive the &lt;em&gt;exact same exception&lt;/em&gt;. However, the static ctor will &lt;em&gt;not&lt;/em&gt; be called again. What appears to happen is that the CLR caches the TypeInitializationException object itself, InnerException included, and rethrows it whenever the type is called.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Upgrading all projects to .NET 3.5</title>
				<link>https://bits.strawjackal.org/118/</link>
				<pubDate>Sun, 25 May 2008 08:56:14 +0200</pubDate>
				<guid>https://bits.strawjackal.org/118/</guid>
				<description>&lt;p&gt;A simple macro to change the Target Framework for a project from .NET 2.0 to .NET 3.5, hacked together in a few minutes. This will fail for C++/CLI projects, and possibly VB.NET projects (haven&#39;t checked). Works fine for regular C# projects, as well as web projects:&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;div&gt;   &lt;pre style=&#34;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&#34;&gt;&lt;span style=&#34;color: #0000ff&#34;&gt;For&lt;/span&gt; &lt;span style=&#34;color: #0000ff&#34;&gt;Each&lt;/span&gt; proj &lt;span style=&#34;color: #0000ff&#34;&gt;As&lt;/span&gt; Project &lt;span style=&#34;color: #0000ff&#34;&gt;In&lt;/span&gt; DTE.Solution.Projects&#xD;&#xA;   &lt;span style=&#34;color: #0000ff&#34;&gt;Try&lt;/span&gt;&#xD;&#xA;       proj.Properties.Item(&lt;span style=&#34;color: #006080&#34;&gt;&#34;TargetFramework&#34;&lt;/span&gt;).Value = 196613&#xD;&#xA;       Debug.Print(&lt;span style=&#34;color: #006080&#34;&gt;&#34;Upgraded {0} to 3.5&#34;&lt;/span&gt;, proj.Name)&#xD;&#xA;   &lt;span style=&#34;color: #0000ff&#34;&gt;Catch&lt;/span&gt; ex &lt;span style=&#34;color: #0000ff&#34;&gt;As&lt;/span&gt; Exception&#xD;&#xA;       Debug.Print(&lt;span style=&#34;color: #006080&#34;&gt;&#34;Failed to upgrade {0} to 3.5&#34;&lt;/span&gt;, proj.Name)&#xD;&#xA;   &lt;span style=&#34;color: #0000ff&#34;&gt;End&lt;/span&gt; &lt;span style=&#34;color: #0000ff&#34;&gt;Try&lt;/span&gt;&#xD;&#xA;&lt;p&gt;&lt;span style=&#34;color: #0000ff&#34;&gt;Next&lt;/span&gt; proj&lt;/pre&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Sneaking past the SharePoint Usage Log</title>
				<link>https://bits.strawjackal.org/119/</link>
				<pubDate>Wed, 16 Apr 2008 15:13:16 +0200</pubDate>
				<guid>https://bits.strawjackal.org/119/</guid>
				<description>&lt;p&gt;I&#39;m writing a piece of code that regularly polls a MOSS server and checks several files. This can happen quite a few times a day, and this totally skews my Usage Reports for my sites. &lt;/p&gt;  &lt;p&gt;Does anyone know of a way to tell MOSS to ignore calls made by a specific user, a specific IP (my code runs on a dedicated server), a specific UserAgent or whatever?&lt;/p&gt;</description>
			</item>
			<item>
				<title>Any signs of life for the SharePoint Extensions for Visual Studio?</title>
				<link>https://bits.strawjackal.org/120/</link>
				<pubDate>Wed, 23 Jan 2008 19:57:31 +0200</pubDate>
				<guid>https://bits.strawjackal.org/120/</guid>
				<description>&lt;p&gt;Has anything been released - or, in fact, talked about - since August&#39;s release of the &lt;a href=&#34;http://www.microsoft.com/downloads/details.aspx?FamilyID=3e1dcccd-1cca-433a-bb4d-97b96bf7ab63&amp;displaylang=en&#34;&gt;v1.1 CTP&lt;/a&gt;?&lt;/p&gt;  &lt;p&gt;Haven&#39;t done any web-part development in a while and wanted to get back in the game. I last used the v1.0 extensions, and was surprised that nothing much has changed in that field except for the CTP release, and even that can&#39;t be downloaded - I just get a broken link.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Seeking advice - strong names and config files</title>
				<link>https://bits.strawjackal.org/121/</link>
				<pubDate>Thu, 20 Dec 2007 11:48:49 +0200</pubDate>
				<guid>https://bits.strawjackal.org/121/</guid>
				<description>&lt;p&gt;I&#39;ll use my blog for a bit of fishing for advice and guidance on an issue that&#39;s been bugging me.&lt;/p&gt; &lt;p&gt;We&#39;ve been moving towards using strong names on all of our assemblies. The benefits are obvious, and it&#39;s a must before we deploy to clients out in the wild.&lt;/p&gt; &lt;p&gt;The problem is that we have several different processes running, each with its own app.config or web.config file. These config files contain references to custom configuration sections, whether they&#39;re application configuration, Enterprise Library extensions or whatnot. Seeing as my DLLs are signed, I have to use the fully qualified assembly name in all my references. This means that in a nightly build scenario where my version number is bumped continuously, I have to change 5-6 references in 5-6 configuration files with every build. &lt;/p&gt;</description>
			</item>
			<item>
				<title>System.Diagnostics.EventLogEntry and the non-equal Equals.</title>
				<link>https://bits.strawjackal.org/122/</link>
				<pubDate>Sun, 25 Nov 2007 18:12:21 +0200</pubDate>
				<guid>https://bits.strawjackal.org/122/</guid>
				<description>&lt;p&gt;Just a quick heads-up in case you&#39;re stumped with this problem, or just passing by:&lt;/p&gt; &lt;p&gt;The System.Diagnostics.EventLogEntry class implements the Equals method to check if two entries are identical, even if they&#39;re not the same instance. However, contrary to best practices, it does NOT overload the operator==, so these two bits of code will behave differently:&lt;/p&gt; &lt;div&gt;&lt;pre style=&#34;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&#34;&gt;EventLog myEventLog = &lt;span style=&#34;color: #0000ff&#34;&gt;new&lt;/span&gt; EventLog(&lt;span style=&#34;color: #006080&#34;&gt;&#34;Application&#34;&lt;/span&gt;);&#xD;&#xA;EventLogEntry entry1 = myEventLog.Entries[0];&#xD;&#xA;EventLogEntry entry2 = myEventLog.Entries[0];&#xD;&#xA;&lt;p&gt;&lt;span style=&#34;color: #0000ff&#34;&gt;bool&lt;/span&gt; correct = entry1.Equals(entry2);&#xA;&lt;span style=&#34;color: #0000ff&#34;&gt;bool&lt;/span&gt; incorrect = entry1 == entry2;&#xA;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Displaying live log file contents</title>
				<link>https://bits.strawjackal.org/123/</link>
				<pubDate>Wed, 21 Nov 2007 14:12:54 +0200</pubDate>
				<guid>https://bits.strawjackal.org/123/</guid>
				<description>&lt;p&gt;I&#39;m writing some benchmarking code, which involves a Console application calling a COM+ hosted process and measuring performance. I want to constantly display results on my active console, but since some of my code is running out-of-process, I can&#39;t really write directly to the console from all parts of the system. Not to mention the fact that I want it logged to a file as well.&lt;/p&gt; &lt;p&gt;So I cobbled together a quick Log class that does two things - it writes to a shared log file, keeping no locks so several processes can access it (I do serialize access to the WriteLine method itself, though). I don&#39;t mind the overhead of opening/closing the file every time, since this isn&#39;t production code.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Another minor C#/C&#43;&#43; difference - adding existing files</title>
				<link>https://bits.strawjackal.org/124/</link>
				<pubDate>Sun, 28 Oct 2007 14:35:24 +0200</pubDate>
				<guid>https://bits.strawjackal.org/124/</guid>
				<description>&lt;p&gt;Another minor detail that bit me for a few minutes today. I&#39;m posting this so I&#39;ll see it and remember, and possibly lodge it in other people&#39;s consciousness.&lt;/p&gt; &lt;p&gt;Using Visual Studio 2005, adding an existing .cs file to a C# project will cause a copy of that file to be created in the project directory. If I want to link to the original file, I need to explicitly choose Add As Link from the dropdown on the Add button. &lt;/p&gt;</description>
			</item>
			<item>
				<title>Another Sharepoint Web Services rant : untyped data vs. incompletely typed data</title>
				<link>https://bits.strawjackal.org/125/</link>
				<pubDate>Thu, 06 Sep 2007 13:18:37 +0200</pubDate>
				<guid>https://bits.strawjackal.org/125/</guid>
				<description>&lt;p&gt;Working with the Web Services in WSSv2 and v3 is an exercise in sheer frustration. I&#39;ve written before about serious and &lt;a href=&#34;http://weblogs.asp.net/avnerk/archive/2007/07/02/no-per-item-permissions-in-wssv3-s-web-services.aspx&#34;&gt;glaring&lt;/a&gt; &lt;a href=&#34;http://weblogs.asp.net/avnerk/archive/2007/07/18/some-more-glaring-omissions-in-the-sharepoint-2007-sdk-and-web-services.aspx&#34;&gt;omissions&lt;/a&gt; in the Web Services API that Sharepoint exposes, but it&#39;s not only the things missing, it&#39;s the lack of consistency in the APIs that ARE implemented that&#39;s annoying.&lt;/p&gt; &lt;p&gt;For most of the APIs, the return value for most methods is an XmlNode, usually documented pretty well in the SDK. It means we have to fiddle with XML to extract data, but it&#39;s not so bad. For instance the Lists WS&#39;s GetListCollection() returns a known, documented, schema-linked XML containing many properties for a given list.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Return of the GC Hole: Another one from the C&#43;&#43;/CLI trenches</title>
				<link>https://bits.strawjackal.org/126/</link>
				<pubDate>Thu, 06 Sep 2007 11:09:18 +0200</pubDate>
				<guid>https://bits.strawjackal.org/126/</guid>
				<description>&lt;p&gt;A few days ago I wrote of a &lt;a href=&#34;http://weblogs.asp.net/avnerk/archive/2007/08/28/a-c-coder-in-a-c-cli-world-part-1.aspx&#34;&gt;GC hole&lt;/a&gt; I accidently created in my C++/CLI code (with thanks to commenter &lt;a href=&#34;http://weblogs.asp.net/avnerk/archive/2007/08/28/a-c-coder-in-a-c-cli-world-part-1.aspx#3645664&#34;&gt;Nish&lt;/a&gt; for the name of the phenomenon). I had the following code snippet set inside a private function:&lt;/p&gt; &lt;p&gt;&lt;font face=&#34;courier new&#34;&gt;   pin_ptr&lt;Byte&gt; pinnedBuffer = &amp;data[0];&lt;br&gt;   char* buffer = (char*)pinnedBuffer;&lt;/font&gt;     &lt;p&gt;Because the pin_ptr went out of scope when the function ended, I had a pointer to a memory location that was quickly moved by the GC, and got me a whole buffer full of garbage. To avoid that, I moved those two lines of code to my main method and pinned it throughout that method.  &lt;p&gt;I thought that was the end of that, but today I noticed that I was still getting garbage occasionally in my buffer. This stumped me for a bit - it seemed like the pin_ptr wasn&#39;t doing its job - until I noticed how my C++ code looked: &lt;p&gt;&lt;font face=&#34;courier new&#34;&gt;public void DoStuff (array&lt;Byte&gt;^ data)&lt;/font&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Windows Services, services.msc and the &#34;This Service is marked for deletion&#34; error.</title>
				<link>https://bits.strawjackal.org/127/</link>
				<pubDate>Wed, 05 Sep 2007 09:14:54 +0200</pubDate>
				<guid>https://bits.strawjackal.org/127/</guid>
				<description>&lt;p&gt;In my current project, we have a windows service that we are developing and debugging, which involves a lot of installing/uninstalling the service. One common problem when uninstalling a service is that while the uninstallation is successful, you still see the service listed in the Services console(services.msc). If you try to start it, stop it or uninstall it again (using installutil.exe or &lt;em&gt;sc delete&lt;/em&gt;) you get an uninformative &#34;This service has been marked for deletion&#34;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Dynamically creating a Sharepoint Web-Service proxy instance</title>
				<link>https://bits.strawjackal.org/128/</link>
				<pubDate>Mon, 03 Sep 2007 16:55:35 +0200</pubDate>
				<guid>https://bits.strawjackal.org/128/</guid>
				<description>&lt;p&gt;In my current code, I find myself accessing many Sharepoint web services. In one run of code I can access 5-6 different web services on dozens of different sites, not necessarily even on the same server. Given that I find myself writing a lot of boilerplate code looking like this:&lt;/p&gt; &lt;p&gt;&lt;font face=&#34;Courier New&#34;&gt;using (SiteData siteDataWS = new SiteData())&lt;br&gt;{&lt;br&gt;   siteDataWS.Credentials = CredentialsCache.DefaultNetworkCredentials;&lt;br&gt;   siteDataWS.Url = currentSite.ToString() + &#34;/_vti_bin/SiteData.asmx&#34;;&lt;br&gt;&lt;br&gt;   // Do something with the WS.&lt;br&gt;}&lt;/font&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Visual Studio help-launcher rant</title>
				<link>https://bits.strawjackal.org/129/</link>
				<pubDate>Mon, 03 Sep 2007 12:34:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/129/</guid>
				<description>&lt;p&gt;Yes, I know I am far from the first to bemoan the &lt;em&gt;atrocious&lt;/em&gt; behavior of Visual Studio 2005 when you press the F1 button, even accidently. The first time you do it - or other times, if it deems the contents sufficiently changed for some reason - you are treated to an obnoxious and uncancellable dialog saying Help is updating itself and showing an uninformative neverending progress bar. &lt;/p&gt; &lt;p&gt;Worse yet, this window, despite being non-modal (due to running in a different process, dexplorer.exe) still blocks the calling thread on devenv.exe, preventing me from working for up to 5 minutes(!) at a time. No Abort button, no way to tell it to skip this pointless operation - launching help from VS is simply a giant waste of time.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Wrong constructor called in COM&#43;: sneaky, sneaky bug</title>
				<link>https://bits.strawjackal.org/130/</link>
				<pubDate>Thu, 30 Aug 2007 14:35:25 +0200</pubDate>
				<guid>https://bits.strawjackal.org/130/</guid>
				<description>&lt;p&gt;Here&#39;s another nasty one that tried to bite me today. Let&#39;s say I have the following classes:&lt;/p&gt; &lt;div style=&#34;border-right: black 1px solid; border-top: black 1px solid; padding: 4px; border-left: black 1px solid; border-bottom: black 1px solid&#34;&gt;&lt;font face=&#34;courier new&#34;&gt;public class COMPlusClass : ServicedComponent&lt;br&gt;{&lt;br&gt;   public COMPlusClass()&lt;br&gt;   {&lt;br&gt;      // Default initialization.&lt;br&gt;   }&lt;br&gt;&lt;br&gt;   public COMPlusClass (string data)&lt;br&gt;   {&lt;br&gt;      // Parameterized initialization.&lt;br&gt;   }&lt;br&gt;}&lt;br&gt;&lt;br&gt;public class Client&lt;br&gt;{&lt;br&gt;    public Client()&lt;br&gt;    {&lt;br&gt;       COMPlusClass cpc = new COMPlusClass(&#34;I am a client&#34;);&lt;br&gt;    }&lt;br&gt;}&lt;/font&gt;&lt;/div&gt; &lt;p&gt;Which constructor do you think will be called?&lt;/p&gt;</description>
			</item>
			<item>
				<title>Unmanaged deployment is a true DLL Hell</title>
				<link>https://bits.strawjackal.org/131/</link>
				<pubDate>Wed, 29 Aug 2007 23:16:07 +0200</pubDate>
				<guid>https://bits.strawjackal.org/131/</guid>
				<description>&lt;p&gt;By a staggering margin, most of my problems integrating C++/CLI code into my C#-based project has been deployment problems. Without fail, every integration or test deployment will be plagued with inexplicable problems. I&#39;ll try to list a few, with their causes and (probable) solutions:&lt;/p&gt; &lt;p&gt;1) .NET assemblies are usually very loose in what they&#39;ll bind to. If I compiled A.DLL against B.DLL version 1.0.0.0, it will still work if it can only find B.DLL version 1.2.0.0. I don&#39;t have to rebuild and reversion everything every time. However, if my C# A.DLL has a reference to my CPPCLI.DLL v1.0.0.0, and I then put CPPCLI.DLL v1.1.0.0, I&#39;ll get an exception saying the referenced DLL wasn&#39;t found. Annoying.&lt;/p&gt;</description>
			</item>
			<item>
				<title>More Tales from the Unmanaged Side - System.String -&gt; char*</title>
				<link>https://bits.strawjackal.org/132/</link>
				<pubDate>Tue, 28 Aug 2007 16:08:50 +0200</pubDate>
				<guid>https://bits.strawjackal.org/132/</guid>
				<description>&lt;p&gt;Today, I had a very tight deadline to achieve a very simple task: pass a managed .NET string to an API function that expects a null-terminated char*. Trivial, you would expect? Unfortunately it wasn&#39;t.&lt;/p&gt; &lt;p&gt;My first though was to do the pinning trick that I mentioned in my last post, but in this case I needed my resulting char* to be null-terminated.&lt;/p&gt; &lt;p&gt;Second thought was to go to the System.Runtime.InteropServices.Marshal class and see what it had for me. I found two contenders:&lt;/p&gt;</description>
			</item>
			<item>
				<title>A C# coder in a C&#43;&#43;/CLI world, part 1</title>
				<link>https://bits.strawjackal.org/133/</link>
				<pubDate>Tue, 28 Aug 2007 13:48:50 +0200</pubDate>
				<guid>https://bits.strawjackal.org/133/</guid>
				<description>&lt;p&gt;Recently I&#39;ve found myself stumbling around some C++/CLI code. C++ is a language which I learned years ago and never really worked with seriously, so I&#39;ve been cursing and moaning as I worked. Strange for me to go back to a (partially) unmanaged environment now, with all sorts of assumptions that I have proven to be false. I&#39;ll try to go over some pitfalls and insights I&#39;m having during the visit. This is the first:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Allowing timeout on long-running operations - possible bug</title>
				<link>https://bits.strawjackal.org/134/</link>
				<pubDate>Mon, 27 Aug 2007 07:18:27 +0200</pubDate>
				<guid>https://bits.strawjackal.org/134/</guid>
				<description>&lt;p&gt;A while ago, I wrote about a &lt;a href=&#34;http://weblogs.asp.net/avnerk/archive/2007/07/24/waiting-for-a-return-value-from-an-asynchronous-method.aspx&#34;&gt;simple pattern&lt;/a&gt; to allow us to put a timeout limitation on a long running operations. Simply put, it allows us to replace this:&lt;/p&gt; &lt;div style=&#34;border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid&#34;&gt; &lt;p&gt;&lt;font face=&#34;courier new&#34;&gt;public MyObject GetData()&lt;br&gt;{&lt;br&gt;   try&lt;br&gt;   {&lt;br&gt;      MyObject data = BigComponent.LongRunningOperation();&lt;br&gt;      return data;&lt;br&gt;   }&lt;br&gt;   catch (Exception ex)&lt;br&gt;   {&lt;br&gt;      // Log and rethrow.&lt;br&gt;      throw;&lt;br&gt;   }&lt;br&gt;}&lt;/font&gt; &lt;/p&gt;&lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;with this:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Waiting for a return value from an asynchronous method</title>
				<link>https://bits.strawjackal.org/135/</link>
				<pubDate>Tue, 24 Jul 2007 08:56:05 +0200</pubDate>
				<guid>https://bits.strawjackal.org/135/</guid>
				<description>&lt;p&gt;The topic of the post might not make sense, initially. If I invoke a method asynchronously, why would I want to wait for a return value? And if I&#39;m waiting, what&#39;s the point of launching it asynchronously?&lt;/p&gt; &lt;p&gt;Well, the most common scenario is when I want to run a process that could take time and might freeze on me, but I want to limit the time it can take and throw an exception if the timeout is exceeded. This means running the main logic in a worker thread, which means we have to find a way to get the result back to the calling method.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Some more glaring omissions in the Sharepoint 2007 SDK and Web Services</title>
				<link>https://bits.strawjackal.org/136/</link>
				<pubDate>Wed, 18 Jul 2007 08:57:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/136/</guid>
				<description>&lt;p&gt;I downloaded the &lt;a href=&#34;http://www.microsoft.com/downloads/details.aspx?familyid=6d94e307-67d9-41ac-b2d6-0074d6286fa9&amp;displaylang=en&#34;&gt;new Sharepoint 2007 SDK&lt;/a&gt; today, published last week though it&#39;s dated from April 2007. There appears to be no change history for this version of the SDK.&lt;/p&gt; &lt;p&gt;I was hoping for more information on new Web Service methods available in 2007 - hoping that the lack of 2007-specific functionality was more of a documentation error than an actual oversight. It seems this is not the case.&lt;/p&gt; &lt;p&gt;I&#39;ve &lt;a href=&#34;http://weblogs.asp.net/avnerk/archive/2007/07/02/no-per-item-permissions-in-wssv3-s-web-services.aspx&#34;&gt;written about&lt;/a&gt; the lack of item-level permissions in the WSSv3 web services before, but I&#39;ve found some other serious problems. &lt;/p&gt;</description>
			</item>
			<item>
				<title>No Per-item permissions in WSSv3&#39;s Web Services?!</title>
				<link>https://bits.strawjackal.org/137/</link>
				<pubDate>Mon, 02 Jul 2007 14:52:59 +0200</pubDate>
				<guid>https://bits.strawjackal.org/137/</guid>
				<description>&lt;p&gt;How did I miss this until now? It&#39;s great that WSSv3 and MOSS give us granular permissions, and it&#39;s great that I can access those permissions via an SPListItem&#39;s RoleAssignments collection - but is there really no way of getting this information in a web service?&lt;/p&gt; &lt;p&gt;The Permissions web service remains unchanged from WSSv2, GetPermissionCollection() receiving a List GUID and returning permissions for that list. Nothing for specific documents. Interestingly enough, the method also receives an &lt;em&gt;objectType&lt;/em&gt; string, which could ostensibly allow us to pass other types of objects and get permissions data for them - but this apparently never made the cut for WSSv3 RTM. &lt;/p&gt;</description>
			</item>
			<item>
				<title>Retrieving all properties for a Sharepoint list</title>
				<link>https://bits.strawjackal.org/138/</link>
				<pubDate>Sun, 03 Jun 2007 19:33:30 +0200</pubDate>
				<guid>https://bits.strawjackal.org/138/</guid>
				<description>&lt;p&gt;When we call the GetListItems or GetListItemChanges methods in Sharepoint&#39;s Lists Web Service, we pass an XmlNode parameter specifying which fields we want to return, in this format:&lt;/p&gt; &lt;p&gt;&lt;ViewFields&gt;&lt;br&gt;   &lt;FieldRef Name=&#34;ows_ID&#34;/&gt;&lt;br&gt;&lt;/ViewFields&gt;&lt;/p&gt; &lt;p&gt;Now, if we leave this field as &lt;em&gt;null&lt;/em&gt;, we get a certain set of properties back - Name, Last Modified and so forth. Basic, commonly used properties. However, if we want to return ALL properties, and we don&#39;t want to explicitly state them, we need to pass an XmlNode with an empty-but-valid ViewFields XML:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Yet ANOTHER C# language enhancement - this_method()</title>
				<link>https://bits.strawjackal.org/139/</link>
				<pubDate>Sun, 03 Jun 2007 11:34:24 +0200</pubDate>
				<guid>https://bits.strawjackal.org/139/</guid>
				<description>&lt;p&gt;This one was suggested by a &lt;a href=&#34;http://weblogs.asp.net/avnerk/archive/2005/10/06/426743.aspx&#34;&gt;coworker&lt;/a&gt; leery of accidental recursion. Too many people aren&#39;t used to thinking in terms of recursion and will miss a recursive call inside a method and accidently start an infinite loop, or miss the meaning of a method thinking it&#39;s an overload call. &lt;/p&gt; &lt;p&gt;His idea - a language keyword that specifies a call to the CURRENT method, again. He originally suggested the &lt;em&gt;recurse&lt;/em&gt; keyword to be totally explicit. I thought of &lt;em&gt;this_method&lt;/em&gt; as another substitute that&#39;s similar to the existing &lt;em&gt;this&lt;/em&gt; keyword.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Another pointless operator for C#</title>
				<link>https://bits.strawjackal.org/140/</link>
				<pubDate>Sun, 03 Jun 2007 08:23:05 +0200</pubDate>
				<guid>https://bits.strawjackal.org/140/</guid>
				<description>&lt;p&gt;I remember &lt;a href=&#34;http://weblogs.asp.net/avnerk/archive/2006/05/04/A-new-conditional-assignment-operator_3F003F00_.aspx&#34;&gt;discovering&lt;/a&gt; C#&#39;s null coalescing operator a while ago. I can&#39;t say I use it a &lt;em&gt;lot&lt;/em&gt;, but it&#39;s useful to clean up my code when I do need it. However, there is another similar scenario that it doesn&#39;t cover:&lt;/p&gt; &lt;p&gt;&lt;font face=&#34;courier new&#34;&gt;SearchResult res = directorySearcher.FindOne();&lt;br&gt;return res != null ? res.GetDirectoryEntry() : null;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;In this case I have my first object, &lt;em&gt;res&lt;/em&gt;, and if it IS null, I want to return it - and if it isn&#39;t, I want to return a property of that object. In effect, it&#39;s the reverse of the ?? operator - return the first object if it is null, or the second object otherwise.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Granting User Rights in C#</title>
				<link>https://bits.strawjackal.org/141/</link>
				<pubDate>Thu, 10 May 2007 09:36:41 +0200</pubDate>
				<guid>https://bits.strawjackal.org/141/</guid>
				<description>&lt;p&gt;As a follow-up to my &lt;a href=&#34;http://weblogs.asp.net/avnerk/archive/2007/05/08/setting-windows-service-account-c-and-wmi.aspx&#34;&gt;previous post&lt;/a&gt; about changing a Windows Service&#39;s user account - there was one think I forgot.&lt;/p&gt; &lt;p&gt;In order for a user to run a service, that user must be granted the &#34;Run as Service&#34; right by the operating system. Usually it&#39;s not a problem - the Services MMC snap-in automatically adds that right to a user we choose, and the ServiceProcessInstaller that we get when creating services in .NET also contains code to grant that right. The problem is when we&#39;re doing it ourselves through our code - the Change() method on the Win32_Service WMI object doesn&#39;t grant that right, and the only other WMI classes that seemed relevant, the RSoP classes, seem to be read-only classes that give us auditing and reports on what user rights are granted, but don&#39;t let us manage them. &lt;/p&gt;</description>
			</item>
			<item>
				<title>Setting Windows Service Account - C# and WMI</title>
				<link>https://bits.strawjackal.org/142/</link>
				<pubDate>Tue, 08 May 2007 07:54:55 +0200</pubDate>
				<guid>https://bits.strawjackal.org/142/</guid>
				<description>&lt;p&gt;I&#39;ve been busting my brains for over two hours trying to accomplish a relatively simple task - changing the username and password of a currently running Windows Service. Should be trivial enough, but the managed ServiceController class doesn&#39;t give me that ability, so I had to resort to more esoteric solutions.&lt;/p&gt; &lt;p&gt;Assuming I wish to avoid direct registry manipulation - an easy enough choice to make - I can either P/Invoke the ChangeServiceConfig method (from advapi32.dll) or use System.Management and call the Win32_Service WMI class. I decided to use as little interop as possible and headed down the WMI path.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Custom ConfigurationSectionHandlers in InstallerClasses</title>
				<link>https://bits.strawjackal.org/143/</link>
				<pubDate>Mon, 07 May 2007 07:02:42 +0200</pubDate>
				<guid>https://bits.strawjackal.org/143/</guid>
				<description>&lt;p&gt;I&#39;m writing an installer class for an MSI Setup Project, and find myself needing to manipulate my web.config containing a custom ConfigurationSection. This should be trivial seeing as my SectionHandler code is bundled with the rest of the application, but fails miserably on my GetSection() call, because the DLL containing it is unavailable to MSIEXEC, which runs from C:WindowsSystem32. What to do, what to do?&lt;/p&gt; &lt;p&gt;Several options:&lt;/p&gt; &lt;p&gt;1) Rather than using the custom ConfigurationSection, I can open my web.config as a standard XmlDocument and do the changes manually. &lt;/p&gt;</description>
			</item>
			<item>
				<title>InstallerClasses and little-known gems.</title>
				<link>https://bits.strawjackal.org/144/</link>
				<pubDate>Sun, 06 May 2007 15:55:06 +0200</pubDate>
				<guid>https://bits.strawjackal.org/144/</guid>
				<description>&lt;p&gt;I&#39;m writing an Installer class for an MSI installer project, and passing a checkbox&#39;s value from the MSI UI. I noticed that when I pass the checkbox&#39;s linked variable into my code, it&#39;s received as a string, and not only a string - the possible values are &#34;1&#34; and &#34;0&#34;.&lt;/p&gt; &lt;p&gt;This is where I started cursing softly, because as well know, the &lt;em&gt;bool.Parse&lt;/em&gt; method can only accept the strings &#34;True&#34; and &#34;False&#34; to parse, and not the commonly-found &#34;1&#34; and &#34;0&#34;. Sure, I can put in a line such as this:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Preventing Outlook from closing with Alt-F4</title>
				<link>https://bits.strawjackal.org/145/</link>
				<pubDate>Sat, 14 Apr 2007 19:39:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/145/</guid>
				<description>&lt;p&gt;I have come to the realization, at some point, that I never want to close Outlook. Really, there&amp;#39;s no reason for me to shut it down except when doing something special, like freeing every available byte of memory, or when developing add-ins to it. During day-to-day work, I always want it on and minimized. The problem is that there&amp;#39;s no easy keyboard shortcut to minimize Outlook like there is to close it - I don&amp;#39;t like the two-step shortcut of &lt;em&gt;Alt+Space - n&lt;/em&gt;, and I don&amp;#39;t want to define a new non-standard keyboard shortcut that I have to remember in addition to the standard Windows keys.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Customizing MOSS Page Title</title>
				<link>https://bits.strawjackal.org/146/</link>
				<pubDate>Wed, 11 Apr 2007 10:00:33 +0200</pubDate>
				<guid>https://bits.strawjackal.org/146/</guid>
				<description>&lt;p&gt;Another odd client request that came in a while ago. &lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;When we browse our Sharepoint site, IE&#39;s title reads &#34;Home - My Site Name - Windows Internet Explorer&#34;. We can&#39;t find any way to remove the &#34;Home&#34; string, regardless of how we change the site&#39;s name. This is critical for our ISO review tomorrow!&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Now, I&#39;m no ISO reviewer, but it seems a bit excessive even for the strictest ISO test. But hey, I&#39;m just your friendly neighborhood technical solutions provider. &lt;/p&gt;</description>
			</item>
			<item>
				<title>Dependency Injection and a new version of RhinoMocks</title>
				<link>https://bits.strawjackal.org/147/</link>
				<pubDate>Thu, 05 Apr 2007 21:49:18 +0200</pubDate>
				<guid>https://bits.strawjackal.org/147/</guid>
				<description>&lt;p&gt;I&#39;m a relative latecomer to the unit-testing business, and only got to play with Mocking frameworks in my last project.&lt;/p&gt; &lt;p&gt;After testing several frameworks, we opted on &lt;a href=&#34;http://www.ayende.com/projects/rhino-mocks/downloads.aspx&#34;&gt;RhinoMocks&lt;/a&gt; for emulating our classes during testing. This, coupled with a lot of &lt;a href=&#34;http://www.martinfowler.com/articles/injection.html&#34;&gt;IOC and dependency injection&lt;/a&gt;, made our rather complex, distributed system much easier to test. Code everything to interfaces, feed them in via constructors or whatnot, and you can now slip in a fake cache or project-data service and test only the issue at hand.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Reflecting over an Event</title>
				<link>https://bits.strawjackal.org/148/</link>
				<pubDate>Thu, 29 Mar 2007 14:03:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/148/</guid>
				<description>&lt;p&gt;A coworker (Hey, Evgeny!) came to me with a puzzler today. He has an object that exposes an event, and he wants to know whether he&amp;#39;s already subscribed to that event. &lt;/p&gt;&lt;p&gt;Two things immediately came to mind - the first was that he really shouldn&amp;#39;t be doing that, and the second was to suggest that if the reason for this is to avoid multiple registrations, he can always call -= and then += afterwards, thus making sure he&amp;#39;s subscribed only once. Having established that, I got down to thinking about it.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Sharepoint Extensions for Visual Studio - released!</title>
				<link>https://bits.strawjackal.org/149/</link>
				<pubDate>Wed, 28 Mar 2007 20:04:05 +0200</pubDate>
				<guid>https://bits.strawjackal.org/149/</guid>
				<description>&lt;p&gt;Finally, we have a full, RTM version of the Visual Studio extensions! &lt;br&gt;The download page says March 15th, but I haven&#39;t seen anyone mention it around yet - could it be just me that missed the boat? &lt;br&gt;I got it from Mark Bower&#39;s &lt;a href=&#34;http://blogs.msdn.com/bowerm/archive/2007/03/28/last-piece-in-the-jigsaw.aspx&#34;&gt;blog&lt;/a&gt;, but haven&#39;t seen it mentioned anywhere else.&lt;/p&gt; &lt;p&gt;On one hand, this is great – the last version was from November ’06, and crashed &lt;a href=&#34;http://weblogs.asp.net/avnerk/archive/2007/02/21/sharepoint-extensions-for-visual-studio-2005.aspx&#34;&gt;often&lt;/a&gt;. Deployment seemed to work only for empty web-part projects and the Solution Generator crashed when trying to dump a whole site.  &lt;p&gt;On the other hand, there are still many basic scenarios not covered by the tools – we can’t export a Publishing site into a site definition, or any list with a Lookup field. This is a &lt;i&gt;huge&lt;/i&gt; drawback.  I hope they release a newer version soon, or perhaps a set of MOSS extensions (rather than WSS) that supports these scenarios.  &lt;p&gt;Regardless, congrats to the team for releasing it for us, and keep up the good work.  &lt;p&gt;Get it here:  &lt;p&gt;&lt;a href=&#34;http://www.microsoft.com/downloads/details.aspx?FamilyID=19f21e5e-b715-4f0c-b959-8c6dcbdc1057&amp;DisplayLang=en&#34;&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=19f21e5e-b715-4f0c-b959-8c6dcbdc1057&amp;DisplayLang=en&lt;/a&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Session Error with Reports Center under MOSS 2007 - Not what you expect</title>
				<link>https://bits.strawjackal.org/150/</link>
				<pubDate>Sun, 18 Mar 2007 10:37:15 +0200</pubDate>
				<guid>https://bits.strawjackal.org/150/</guid>
				<description>&lt;p&gt; Ran into a problem with a client today. They installed MOSS 2007 and created a publishing portal, but then decided to erase the Reports Center, since they had no use for it. A few days later, of course, they figured they DID want it after all, and recreated a new site, called Reports, using the Reporting Center template. &lt;/p&gt; &lt;p&gt;However, when trying to access it, they received this error: (click for full-sized image).&lt;/p&gt;</description>
			</item>
			<item>
				<title>Sharepoint Extensions for Visual Studio 2005</title>
				<link>https://bits.strawjackal.org/151/</link>
				<pubDate>Wed, 21 Feb 2007 16:53:34 +0200</pubDate>
				<guid>https://bits.strawjackal.org/151/</guid>
				<description>&lt;p&gt;Any news on when a new release of the extensions are due? The state of the current tools is downright abyssmal. Even ignoring the requirement to run VS on the Sharepoint server machine, half the things don&#39;t work or are horribly slow. The Sharepoint Solution Generator doesn&#39;t support the most important sites I want to create a definition of (Portals, Publishing sites) and crashes randomly throughout, the WSP generator scripts take almost 5 minutes for a simple list definition, and the Sharepoint Workflow Designer is simply a mess, hard to understand what&#39;s going on and how to match a correlationToken between tasks and workflows.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Word 2007 and Sharepoint Workflows</title>
				<link>https://bits.strawjackal.org/152/</link>
				<pubDate>Tue, 20 Feb 2007 22:22:31 +0200</pubDate>
				<guid>https://bits.strawjackal.org/152/</guid>
				<description>&lt;p&gt;I&#39;ve got a couple of questions about Word 2007 integration with Sharepoint 2007, and several problems that occur because of it:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;The Mysterious Checked-Out Error&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Let&#39;s say I have a workflow attached to a document library which creates a data collection task, and when that task is completed updates the document metadata with the task data (say, &#34;Ask for Comments&#34;). For some reason if I leave the document open in Word and complete the task, I get an error in the workflow claiming the document is checked out and can&#39;t be updated.&lt;/p&gt;</description>
			</item>
			<item>
				<title>&#34;Trial Expired&#34; errors in unexpected places.</title>
				<link>https://bits.strawjackal.org/153/</link>
				<pubDate>Tue, 20 Feb 2007 19:16:12 +0200</pubDate>
				<guid>https://bits.strawjackal.org/153/</guid>
				<description>&lt;p&gt;I&#39;ve installed MOSS 2007 RTM on a couple of test VPCs here, using the 180-day trial version. Everything worked fine until I tried to create a new page in my Publishing Portal - suddenly received a &#34;The trial period for this product has expired&#34; message and it won&#39;t let me create it. This is strange, since I got this key from Microsoft Downloads 3 days ago. Switching the server to an MSDN key didn&#39;t help either, so it wasn&#39;t a licensing issue.&lt;/p&gt;</description>
			</item>
			<item>
				<title>MOSS Workflows are versioned</title>
				<link>https://bits.strawjackal.org/154/</link>
				<pubDate>Tue, 20 Feb 2007 19:04:37 +0200</pubDate>
				<guid>https://bits.strawjackal.org/154/</guid>
				<description>&lt;p&gt;I was asked today about MOSS&#39;s behavior when workflows are changed midstream. Say I have a document library with a Workflow attached to it, start a few long-running (non-immediate) workflows, then change the workflow before they&#39;re completed - will they keep running? Will they use the new workflow or the old, from that point on?&lt;/p&gt; &lt;p&gt;I had hoped for the former, but expected the latter. You can&#39;t switch flow in midstream (if you&#39;ll pardon my mishmash of similar metaphors), since a newer activity might rely on a variable created by a previous action - one that never took place.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Screencasts vs. Whitepapers</title>
				<link>https://bits.strawjackal.org/155/</link>
				<pubDate>Thu, 15 Feb 2007 14:10:35 +0200</pubDate>
				<guid>https://bits.strawjackal.org/155/</guid>
				<description>&lt;p&gt;A few weeks ago, &lt;a href=&#34;http://blogs.technet.com/lliu/archive/2006/11/15/4-new-screencast-based-demos-for-moss-more-hints-about-sharepointpedia.aspx&#34;&gt;Lawrence Liu&lt;/a&gt; (a senior technical PM and community lead for Sharepoint at Microsoft) linked to a few screencasts for learning how to use various features in MOSS2007. In that entry, he mentioned how screecasts are more effective and efficient in training and learning to use a new piece of software. Me, I&#39;m a bit divided about them:&lt;/p&gt; &lt;p&gt;1) Screencasts are great for getting a hands-on view of the system, that&#39;s true. A picture is worth a thousand words, and a movie is worth about 30 frames per second. I know &lt;a href=&#34;http://tools.osherove.com/Default.aspx?tabid=182&#34;&gt;software authors&lt;/a&gt; that have replaced the help file completely with a small Camtasia screencast. This, of course, only works for simple programs with few use-cases.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Bad naming - Sharepoint Features</title>
				<link>https://bits.strawjackal.org/156/</link>
				<pubDate>Thu, 08 Feb 2007 07:51:39 +0200</pubDate>
				<guid>https://bits.strawjackal.org/156/</guid>
				<description>&lt;p&gt;Gaaah! Who, in the name of all that is holy, thought that naming a feature in Sharepoint &#34;Features&#34; would be a good idea? Sure, it describes it, but it also describes practically everything else. It&#39;s impossible to find on Google and makes conversation sound more like a Marx Brothers sketch then a technical conversation.&lt;/p&gt; &lt;p&gt;Why? Why? Why?&lt;/p&gt;</description>
			</item>
			<item>
				<title>Outlook Calendar as your Windows Desktop</title>
				<link>https://bits.strawjackal.org/157/</link>
				<pubDate>Thu, 01 Feb 2007 14:29:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/157/</guid>
				<description>&lt;p&gt;In a Channel 9 conversation, user &lt;a href=&#34;http://channel9.msdn.com/ShowPost.aspx?PostID=278122#278122&#34;&gt;Dr. Herbie&lt;/a&gt; expressed his long-standing desire to see his Outlook calendar as a desktop wallpaper. This, I admit, has never once occured to me. The nice thing about it is that it&amp;#39;s so amazingly simple to implement.&lt;/p&gt;&lt;p&gt;Ever since Windows 98 and the Active Desktop, you could use HTML as the desktop wallpaper and embed anything you want in it. For the last 4 versions at least, Outlook comes with an ActiveX control that lets you display the contents of any Outlook folder in your application. Mix the two - and you have an HTML page that embeds the Outlook View Control maximized to fullscreen, defaulting to today&amp;#39;s date, and add two simple Javascript buttons to move back and forward in the days.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Exposing add-in errors in VSTO for Word 2007</title>
				<link>https://bits.strawjackal.org/158/</link>
				<pubDate>Sun, 21 Jan 2007 16:10:40 +0200</pubDate>
				<guid>https://bits.strawjackal.org/158/</guid>
				<description>&lt;p&gt;One of the most annoying things about writing add-ins for Office is that it tends to swallow any and all errors that occur. All exceptions are silently thrown into the trash heap without even a statusbar flag. Nothing. This meant that we often had to add messageboxes for debugging, or Debugger.Launch to see what&#39;s going on.&lt;/p&gt; &lt;p&gt;At first I thought that Word 2007 was no different, but then I was idly browsing through the Word Options dialog and discovered a wonderful prize - a checkbox called &#34;Show add-in user interface errors&#34;. Quickly checked and lo and behold - exceptions in my code are shown by Word! Life is good again!&lt;/p&gt;</description>
			</item>
			<item>
				<title>Zune Desktop Theme - A Warning</title>
				<link>https://bits.strawjackal.org/159/</link>
				<pubDate>Mon, 08 Jan 2007 11:09:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/159/</guid>
				<description>&lt;P mce_keep=&#34;true&#34;&gt; &lt;/P&gt;&#xD;&#xA;&lt;P&gt;A few days ago, Microsoft released a new Desktop Theme for Windows XP named the &#34;Zune Desktop Theme&#34; – even though it looks a lot like Vista, all in black and orange. It fits in with Office 2007&#39;s Black skin, so I gleefully installed it. &#xD;&#xA;&lt;P&gt;Everything was fine for a few days until the first time I had to reboot (rather than Standby/Hibernate) – late last night. From that moment on, my Windows Explorer would crash every time you tried to do anything. Windows loaded? Explorer crashed. Tried to open a folder? Expolrer crashed. Save As from Word? You guessed it. &#xD;&#xA;&lt;P&gt;Took me a while to put two and two together since there were a few days between the two, but the solution is to: &#xD;&#xA;&lt;P&gt;a) Uninstall the Zune Desktop Theme. &#xD;&#xA;&lt;P&gt;b) Choose a different desktop theme (Luna, for instance). &#xD;&#xA;&lt;P&gt;c) Reboot. &#xD;&#xA;&lt;P&gt;This solved the problem for me. Even though I&#39;d gotten used to the gloomy Vista-ish look, I won&#39;t be reinstalling it any time soon. Your experience might be different, but beware. If you&#39;re feeling curious or suicidal, here&#39;s the download link: &#xD;&#xA;&lt;P&gt;&lt;A title=&#34;Zune XP Desktop Theme&#34; href=&#34;http://go.microsoft.com/fwlink/?LinkID=75078&#34; mce_href=&#34;http://go.microsoft.com/fwlink/?LinkID=75078&#34;&gt;Zune XP Desktop Theme&lt;/A&gt;&lt;/P&gt;</description>
			</item>
			<item>
				<title>VSTO for Outlook 2007 - Building the Add-in (part 2)</title>
				<link>https://bits.strawjackal.org/160/</link>
				<pubDate>Wed, 03 Jan 2007 13:00:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/160/</guid>
				<description>&lt;p&gt;Writing the Outlook add-in described in &lt;a href=&#34;./avnerk/archive/2007/01/03/vsto-for-outlook-2007-new-features-more-fun-part-1.aspx&#34;&gt;my previous post&lt;/a&gt; was composed of the following steps:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;1) Creating the project&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Ah, the wonders of VSTO. Saving us all the unnecessary hassle of adding COM references, implementing interfaces and working too hard. After installing &lt;a href=&#34;http://msdn.microsoft.com/en-us/office/aa905543.aspx&#34;&gt;VSTO 2005 SE&lt;/a&gt; we can create a new Outlook 2007 Add-in project that creates both the add-in project and the MSI Setup project that can be used to install it. &lt;/p&gt;</description>
			</item>
			<item>
				<title>VSTO for Outlook 2007 - New Features, More Fun (part 1)</title>
				<link>https://bits.strawjackal.org/161/</link>
				<pubDate>Wed, 03 Jan 2007 12:59:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/161/</guid>
				<description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Outlook has always been a bit of a latecomer to the VSTO game, being a step behind and a version later than Word and Excel. I&amp;#39;m glad to see that with Outlook 2007 and VSTO 2005SE it&amp;#39;s gotten simpler and easier to write add-ins for it. So I did.&lt;/p&gt;&lt;p&gt;The basic premise of this was an exercise to know more of the new Object Model enhancements in Outlook 2007, but it best serves as an example of a add-in for Outlook that uses the VSTO environment and the abilities of the new version.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Wrapping the RAS</title>
				<link>https://bits.strawjackal.org/162/</link>
				<pubDate>Wed, 13 Dec 2006 14:27:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/162/</guid>
				<description>&lt;p&gt;A couple of years ago I had a need to automate dialing a RAS connection and retrieving the IP address allocated by the server. I found myself writing a small, rather limited wrapper around the RAS P/Invoke calls. Far from complete, it only covered the functionality I needed for that project. But it was useful, and I kept it around. &lt;/p&gt;&lt;p&gt;Over the years I&amp;#39;ve had several people contact me to get a copy of that wrapper to save them time and effort, so to simplify matters, I&amp;#39;ll simply attach my RasWrap project here and let google lead people to my blog, rather than to an ancient post on Channel9 where I last mentioned it.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Crossing the line - Reflection and Reality</title>
				<link>https://bits.strawjackal.org/163/</link>
				<pubDate>Tue, 12 Dec 2006 18:42:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/163/</guid>
				<description>&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Trebuchet MS&#34;&gt;When we&#39;re working Reflection, we tend to think in different terms than we do when we&#39;re actually calling methods. There&#39;s an extra level of abstraction in everything we do. Translating between these levels of abstraction isn&#39;t always easy or intuitive, so I&#39;ll try to go over some common paths, using this following class definition for my examples: &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;COLOR: blue&#34;&gt;using &lt;/SPAN&gt;System.Reflection;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;COLOR: blue&#34;&gt;public&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: blue&#34;&gt;delegate&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: blue&#34;&gt;void&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyDelegate&lt;/SPAN&gt;(); &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;COLOR: blue&#34;&gt;public&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: blue&#34;&gt;class&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyClass &lt;BR&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;{ &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;    &lt;SPAN style=&#34;COLOR: blue&#34;&gt;public&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: blue&#34;&gt;void&lt;/SPAN&gt; MyMethod() { } &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;    &lt;SPAN style=&#34;COLOR: blue&#34;&gt;private&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: blue&#34;&gt;void&lt;/SPAN&gt; MyPrivateMethod() { } &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;    &lt;SPAN style=&#34;COLOR: blue&#34;&gt;public&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: blue&#34;&gt;static&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: blue&#34;&gt;void&lt;/SPAN&gt; MyStaticMethod() { } &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;    &lt;SPAN style=&#34;COLOR: blue&#34;&gt;public&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: blue&#34;&gt;int&lt;/SPAN&gt; MyField; &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;    &lt;SPAN style=&#34;COLOR: blue&#34;&gt;public&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: blue&#34;&gt;int&lt;/SPAN&gt; MyProperty &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;    { &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;        &lt;SPAN style=&#34;COLOR: blue&#34;&gt;get&lt;/SPAN&gt; { &lt;SPAN style=&#34;COLOR: blue&#34;&gt;return&lt;/SPAN&gt; MyField; } &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;        &lt;SPAN style=&#34;COLOR: blue&#34;&gt;set&lt;/SPAN&gt; { MyField = &lt;SPAN style=&#34;COLOR: blue&#34;&gt;value&lt;/SPAN&gt;; }&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;    } &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;}&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 13pt&#34;&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 13pt; FONT-FAMILY: Trebuchet MS&#34;&gt;Concrete -&gt; Reflection &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt; FONT-FAMILY: Trebuchet MS&#34;&gt;1. Objects &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyClass&lt;/SPAN&gt; myObject = &lt;SPAN style=&#34;COLOR: blue&#34;&gt;new&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyClass&lt;/SPAN&gt;();&lt;BR&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;Type&lt;/SPAN&gt; myType = myObject.GetType(); &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt; FONT-FAMILY: Trebuchet MS&#34;&gt;2. Classes &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;Type&lt;/SPAN&gt; myType = &lt;SPAN style=&#34;COLOR: blue&#34;&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyClass&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt&#34;&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Verdana&#34;&gt;&lt;STRONG&gt;Note: The examples from now on will assume we have the myObject and myType variables as defined above. &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt; FONT-FAMILY: Trebuchet MS&#34;&gt;3. Public Instance Methods &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MethodInfo&lt;/SPAN&gt; method = myType.GetMethod(&lt;SPAN style=&#34;COLOR: maroon&#34;&gt;&#34;MyMethod&#34;&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt; FONT-FAMILY: Trebuchet MS&#34;&gt;4. Private Instance Methods &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MethodInfo&lt;/SPAN&gt; privMethod = myType.GetMethod(&lt;SPAN style=&#34;COLOR: maroon&#34;&gt;&#34;MyPrivateMethod&#34;&lt;/SPAN&gt;, &lt;SPAN style=&#34;COLOR: teal&#34;&gt;BindingFlags&lt;/SPAN&gt;.NonPublic | &lt;SPAN style=&#34;COLOR: teal&#34;&gt;BindingFlags&lt;FONT color=#000000&gt;.Instance &lt;/FONT&gt;&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt; FONT-FAMILY: Trebuchet MS&#34;&gt;5. Static Methods &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MethodInfo&lt;/SPAN&gt; statMethod = myType.GetMethod(&lt;SPAN style=&#34;COLOR: maroon&#34;&gt;&#34;MyStaticMethod&#34;&lt;/SPAN&gt;, &lt;SPAN style=&#34;COLOR: teal&#34;&gt;BindingFlags&lt;/SPAN&gt;.Public | &lt;SPAN style=&#34;COLOR: teal&#34;&gt;BindingFlags&lt;/SPAN&gt;.Static);&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt&#34;&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt; FONT-FAMILY: Trebuchet MS&#34;&gt;6. Fields &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;FieldInfo&lt;/SPAN&gt; fi = myType.GetField(&lt;SPAN style=&#34;COLOR: maroon&#34;&gt;&#34;MyField&#34;&lt;/SPAN&gt;);&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Verdana&#34;&gt;&lt;STRONG&gt;Note: For static or non-public fields, overloads exist similar to those for methods above.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Trebuchet MS&#34;&gt; &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt; FONT-FAMILY: Trebuchet MS&#34;&gt;7. Properties (with their associated Get/Set methods) &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;PropertyInfo&lt;/SPAN&gt; pi = myType.GetProperty(&lt;SPAN style=&#34;COLOR: maroon&#34;&gt;&#34;MyProperty&#34;&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MethodInfo&lt;/SPAN&gt; getMethod = pi.GetGetMethod();&lt;BR&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MethodInfo&lt;/SPAN&gt; setMethod = pi.GetSetMethod(); &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Verdana&#34;&gt;&lt;STRONG&gt;Note: For static or non-public properties, overloads exist similar to those for methods above.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Trebuchet MS&#34;&gt; &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt; FONT-FAMILY: Trebuchet MS&#34;&gt;8. Delegates &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyDelegate&lt;/SPAN&gt; del = myObject.MyMethod;&lt;BR&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MethodInfo&lt;/SPAN&gt; mi = d.Method;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;  &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;   &lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 13pt; FONT-FAMILY: Trebuchet MS&#34;&gt;Reflection -&gt; Concrete &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-FAMILY: Trebuchet MS&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt&#34;&gt;1. Objects &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 9pt&#34;&gt;&lt;STRONG&gt;(note the cast)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt&#34;&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyClass&lt;/SPAN&gt; myObj = &lt;SPAN style=&#34;COLOR: teal&#34;&gt;Activator&lt;/SPAN&gt;.CreateInstance(myType) &lt;SPAN style=&#34;COLOR: blue&#34;&gt;as&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyClass&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt&#34;&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt; FONT-FAMILY: Trebuchet MS&#34;&gt;2. Methods (invoking) &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Verdana&#34;&gt;For a static method, we will supply &lt;EM&gt;null&lt;/EM&gt; for the first parameter (the instance). &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;mi.Invoke(myObj, &lt;SPAN style=&#34;COLOR: blue&#34;&gt;new&lt;/SPAN&gt; &lt;SPAN style=&#34;COLOR: blue&#34;&gt;object&lt;/SPAN&gt;[] {&lt;SPAN style=&#34;COLOR: blue&#34;&gt;…&lt;/SPAN&gt;} );&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt&#34;&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt; FONT-FAMILY: Trebuchet MS&#34;&gt;3. Fields &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;&lt;SPAN style=&#34;COLOR: blue&#34;&gt;int&lt;/SPAN&gt; value = (&lt;SPAN style=&#34;COLOR: blue&#34;&gt;int&lt;/SPAN&gt;)fi.GetValue(myObj);&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt&#34;&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt; FONT-FAMILY: Trebuchet MS&#34;&gt;4. Properties &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Verdana&#34;&gt;Unlike fields, properties can take a set of parameters. Either parameterized properties in VB or indexers in C#. &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;&lt;SPAN style=&#34;COLOR: blue&#34;&gt;int&lt;/SPAN&gt; value = (&lt;SPAN style=&#34;COLOR: blue&#34;&gt;int&lt;/SPAN&gt;)pi.GetValue(myObj, &lt;SPAN style=&#34;COLOR: blue&#34;&gt;null&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt&#34;&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt; FONT-FAMILY: Trebuchet MS&#34;&gt;5. Delegates &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Verdana&#34;&gt;Delegate to static method: &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyDelegate&lt;/SPAN&gt; del = (&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyDelegate&lt;/SPAN&gt;) &lt;SPAN style=&#34;COLOR: teal&#34;&gt;Delegate&lt;/SPAN&gt;.CreateDelegate(&lt;SPAN style=&#34;COLOR: blue&#34;&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyDelegate&lt;/SPAN&gt;), method);&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 12pt&#34;&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Verdana&#34;&gt;Delegate to instance method: &lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P style=&#34;BACKGROUND: #eeece1&#34;&gt;&lt;SPAN style=&#34;FONT-FAMILY: Courier New&#34;&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt;&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyDelegate&lt;/SPAN&gt; del = (&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyDelegate&lt;/SPAN&gt;)&lt;SPAN style=&#34;COLOR: teal&#34;&gt;Delegate&lt;/SPAN&gt;.CreateDelegate(&lt;SPAN style=&#34;COLOR: blue&#34;&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style=&#34;COLOR: teal&#34;&gt;MyDelegate&lt;/SPAN&gt;), myObj, method.Name);&lt;/SPAN&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt&#34;&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;SPAN style=&#34;FONT-SIZE: 10pt; FONT-FAMILY: Trebuchet MS&#34;&gt;Note that there is no syntax to create an instance delegate from a MethodInfo; for some reason we only have a weakly-typed overload that accepts the method name as a string. Only the first overload, for static methods, receives a strongly typed MethodInfo.&lt;/SPAN&gt;&lt;/P&gt;</description>
			</item>
			<item>
				<title>Code Generation, SharedContracts and The Sneaky Bug</title>
				<link>https://bits.strawjackal.org/164/</link>
				<pubDate>Wed, 16 Aug 2006 15:28:08 +0200</pubDate>
				<guid>https://bits.strawjackal.org/164/</guid>
				<description>&lt;p&gt;A short discussion ensued today on the topic of Code Generation tools like CodeSmith. &lt;/p&gt; &lt;p&gt;Like Unit Testing, code generation is a topic that some people swear by and some reject out of hand. I&#39;m sure this is mostly a question of getting used to the concept. Only after I had used unit tests extensively in a real project could I appreciate the real value of having them - not just occasionally running some tests, or writing some cases beforehand. I&#39;m talking a full suite of automated tests that could be run nightly or as part of a continuous integration setup. But I digress.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Creating CustomBindings programatically</title>
				<link>https://bits.strawjackal.org/165/</link>
				<pubDate>Thu, 10 Aug 2006 21:49:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/165/</guid>
				<description>&lt;p&gt;I had another revelation earlier, when going over Nicholas Allen&amp;#39;s explanation of the GetProperty&lt;T&gt; method and BindingContexts:&lt;/p&gt;&lt;p&gt;The Binding objects supplied by the WCF framework are only a wrapper. They have no logic in them. They mean nothing. They do nothing except allow access to the internal properties of their BindingElements. The BindingElements are the ones who do the real work.&lt;/p&gt;&lt;p&gt;There. It&amp;#39;s a bit harsh, but it had to be said. Took me a while to wrap my head around it. It&amp;#39;s syntactic sugar, since it&amp;#39;s easier to do this:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Aggregated Interface Implementation</title>
				<link>https://bits.strawjackal.org/166/</link>
				<pubDate>Tue, 08 Aug 2006 06:01:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/166/</guid>
				<description>&lt;p&gt;I&#39;ve been struggling around the aggregation used in WCF&#39;s Binding object model, as implemented in the GetProperty&lt;T&gt; method (see relevant discussions with Nicholas Allen from the WCF team &lt;a href=&#34;./avnerk/archive/2006/08/07/WCF_3A00_-Navigating-the-Binding-maze.aspx#465122&#34;&gt;here&lt;/a&gt; and &lt;a href=&#34;http://blogs.msdn.com/drnick/archive/2006/08/04/688372.aspx#comments&#34;&gt;here&lt;/a&gt;), and I&#39;m struck by how the need for a flexible, late-bound way of extracting information from a composite object forces us to write ugly code. &lt;/p&gt;  &lt;p&gt;Let&#39;s say I have an object myObject. myObject doesn&#39;t implement any interfaces, but it contains a list called &lt;em&gt;elements&lt;/em&gt; that contain various other objects, each of which might implement those interfaces. Now lets say I want to get a handle to one of those interfaces - to make things more concrete, let&#39;s say we want the ISecurityProvider interface. Using the current WCF model, we would do something like this:&lt;/p&gt;</description>
			</item>
			<item>
				<title>WCF: Navigating the Binding maze</title>
				<link>https://bits.strawjackal.org/167/</link>
				<pubDate>Mon, 07 Aug 2006 07:24:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/167/</guid>
				<description>&lt;p&gt;A few days ago I &lt;a href=&#34;./avnerk/archive/2006/07/31/WCF-and-Non_2D00_polymorphic-bindings_2C00_-_3C00_small_3E00_or-How-to-write-an-incomprehensible-post-title_3C002F00_small_3E00_.aspx&#34;&gt;ranted&lt;/a&gt; a bit about the Binding object model in WCF and how restrictive it feels when I want to imperatively describe my service bindings without being tied down to a specific transport. If I want to disable security or set the maximum allowed size per field in a message, I have to write identical-looking code for each different binding - something that just begs for refactoring which can&amp;#39;t be done.&lt;/p&gt;</description>
			</item>
			<item>
				<title>WCF Serialization Part 2d: A Solution, a Conclusion and a Contribution</title>
				<link>https://bits.strawjackal.org/168/</link>
				<pubDate>Thu, 03 Aug 2006 13:23:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/168/</guid>
				<description>&lt;p&gt;This is the last part of my continuing saga of serializing dictionaries over WCF and beyond.&lt;/p&gt;&lt;p&gt;Quick recap: While WCF allows me to serialize an IDictionary easily, trying to serialize that dictionary later for other uses fails - specifically, caching it to disk using the Enterprise Library. This is because the Enterprise Library relies on the BinaryFormatter, which in turns relies on the type implementing ISerializable. An alternate solution was to use the NameValueCollection which implements ISerializable, but is incompatible with WCF&amp;#39;s serialization.&lt;/p&gt;</description>
			</item>
			<item>
				<title>WCF Serialization Part 2c: Hacking the NameValueCollection (unsuccesfully)</title>
				<link>https://bits.strawjackal.org/169/</link>
				<pubDate>Wed, 02 Aug 2006 13:28:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/169/</guid>
				<description>&lt;p style=&#34;margin: 0in 0in 0pt; direction: ltr; unicode-bidi: embed; text-align: left&#34; dir=&#34;ltr&#34; class=&#34;MsoNormal&#34;&gt;&lt;span style=&#34;font-family: Verdana&#34;&gt;&lt;font size=&#34;3&#34;&gt;As we mentioned &lt;/font&gt;&lt;a href=&#34;./avnerk/archive/2006/08/02/WCF-Serialization-Part-2_3A00_-NameValueCollection-Denied_2100_.aspx&#34;&gt;&lt;font size=&#34;3&#34;&gt;here&lt;/font&gt;&lt;/a&gt;&lt;font size=&#34;3&#34;&gt; and &lt;/font&gt;&lt;a href=&#34;./avnerk/archive/2006/08/02/WCF-Serialization-Part-2b_3A00_-WCF-Collection-Serialization.aspx&#34;&gt;&lt;font size=&#34;3&#34;&gt;here&lt;/font&gt;&lt;/a&gt;&lt;font size=&#34;3&#34;&gt;, I&amp;#39;ve been struggling to get the NameValueCollection object to pass through WCF serialization. Please read the first two posts first for some context.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#34;margin: 0in 0in 0pt; direction: ltr; unicode-bidi: embed; text-align: left&#34; dir=&#34;ltr&#34; class=&#34;MsoNormal&#34;&gt;&lt;span style=&#34;font-family: Verdana&#34;&gt;&lt;font size=&#34;3&#34;&gt; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#34;margin: 0in 0in 0pt; direction: ltr; unicode-bidi: embed; text-align: left&#34; dir=&#34;ltr&#34; class=&#34;MsoNormal&#34;&gt;&lt;span style=&#34;font-family: Verdana&#34;&gt;&lt;font size=&#34;3&#34;&gt;In the previous episodes, we saw that we can&amp;#39;t get WCF to serialize the NameValueCollection (NVC, from now on) because it incorrectly marked for its CollectionDataContract serialization, but then choked because it had no Add(object) method.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>WCF Serialization Part 2b: WCF Collection Serialization</title>
				<link>https://bits.strawjackal.org/170/</link>
				<pubDate>Wed, 02 Aug 2006 13:25:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/170/</guid>
				<description>&lt;p style=&#34;margin: 0in 0in 0pt; direction: ltr; unicode-bidi: embed; text-align: left&#34; class=&#34;MsoNormal&#34;&gt;&lt;span style=&#34;font-family: Verdana&#34;&gt;&lt;font size=&#34;3&#34;&gt;As we mentioned &lt;/font&gt;&lt;a href=&#34;./avnerk/archive/2006/08/02/WCF-Serialization-Part-2_3A00_-NameValueCollection-Denied_2100_.aspx&#34;&gt;&lt;font size=&#34;3&#34;&gt;here&lt;/font&gt;&lt;/a&gt;&lt;font size=&#34;3&#34;&gt;, I&amp;#39;m currently struggling with getting WCF to serialize my NameValueCollection object on a service operation. The previous post goes over the general details, while here I&amp;#39;ll dive a bit deeper. It&amp;#39;s recommended to read the first part before continuing.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#34;margin: 0in 0in 0pt; direction: ltr; unicode-bidi: embed; text-align: left&#34; class=&#34;MsoNormal&#34;&gt;&lt;span style=&#34;font-family: Verdana&#34;&gt;&lt;font size=&#34;3&#34;&gt; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#34;margin: 0in 0in 0pt; direction: ltr; unicode-bidi: embed; text-align: left&#34; class=&#34;MsoNormal&#34;&gt;&lt;span style=&#34;font-family: Verdana&#34;&gt;&lt;font size=&#34;3&#34;&gt;I don&amp;#39;t know exactly the logic that goes in the WCF serialization engine to determine what data contract will be selected for serialization.. I tried wading in with Reflector but got a bit lost. I managed to track down some interesting places, though. Both in the System.Runtime.Serialization assembly:&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>WCF Serialization Part 2a: NameValueCollection Denied!</title>
				<link>https://bits.strawjackal.org/171/</link>
				<pubDate>Wed, 02 Aug 2006 12:40:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/171/</guid>
				<description>&lt;div style=&#34;font-size: 12pt; font-family: Verdana&#34;&gt;&lt;p&gt;As we all &lt;a href=&#34;./avnerk/archive/2006/05/23/Serilalizing-Dictionaries.aspx&#34;&gt;know&lt;/a&gt;, IDictionaries aren&amp;#39;t serializable. This is has been a cause of much concern and consternation throughout the years. Throughout these trying times, however, we had one shining beacon in the night - the NameValueCollection in the System.Collections.Specialized namespace was a completely serializable implementation of a string/string dictionary. Used by the framework for everything from configuration settings to ASP query strings.&lt;/p&gt;&lt;p&gt;Now WCF comes along, and with it much &lt;a href=&#34;http://blogs.msdn.com/sowmy/archive/2006/02/22/536747.aspx&#34;&gt;serialization goodness&lt;/a&gt;, including the ability to easily serialize IDictionaries over the wire. While this is extremely convenient, we have to remember that IDictionaries are still not really serializable - they&amp;#39;re just special-cased in WCF. This means that if we want to transfer a dictionary over the wire and then persist it to disk (using the Caching Application Block, for instance) we&amp;#39;re still out of luck. &lt;/p&gt;</description>
			</item>
			<item>
				<title>WCF Serialization part 1: Interfaces, Base classes and the NetDataContractFormatSerializer</title>
				<link>https://bits.strawjackal.org/172/</link>
				<pubDate>Mon, 31 Jul 2006 14:46:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/172/</guid>
				<description>&lt;p&gt;One of WCF&amp;#39;s goals is interoperability with standard protocol stacks, like WSE or other WS-* implementations. This led, I am told, to the design of WCF&amp;#39;s default object serializer - the DataContractFormatSerializer. This &lt;a href=&#34;http://blogs.msdn.com/sowmy/archive/2006/02/22/536747.aspx&#34;&gt;handy little engine&lt;/a&gt; serializes primitive types, common objects, enums, Collections and anything that implements IXmlSerializable or ISerializable, giving us a much nicer out-of-the-box-and-over-the-wire experience for our objects. &lt;/p&gt;&#xD;&#xA;&lt;p&gt;Because of the aforementioned design goal, however, it has one little problem - the serialized data it generates does not contain information about the .NET CLR type from which this data was serialized. This makes sense when you have interoperability in mind - the datatypes you pass should be described in your service metadata, such as WSDL, and not rely on an implementation detail like the CLR type itself.&lt;/p&gt;</description>
			</item>
			<item>
				<title>WCF and Non-polymorphic bindings</title>
				<link>https://bits.strawjackal.org/173/</link>
				<pubDate>Mon, 31 Jul 2006 06:06:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/173/</guid>
				<description>&lt;p style=&#34;margin: 0in 0in 0pt; direction: ltr; unicode-bidi: embed; text-align: left&#34; dir=&#34;ltr&#34; class=&#34;MsoNormal&#34;&gt;&lt;span style=&#34;font-size: 10pt; font-family: Arial&#34;&gt;I&amp;#39;ve been using WCF for the past few months and on the whole, I think the programming model works. I&amp;#39;m getting to really like the &lt;a href=&#34;./avnerk/archive/2006/04/26/444013.aspx&#34; target=&#34;_blank&#34;&gt;&lt;span&gt;extensibility model&lt;/span&gt;&lt;/a&gt; and the whole deal seems to click rather well. One place where I feel it&amp;#39;s a bit broken, though, is around the object model for Bindings. &lt;/span&gt;&lt;/p&gt;&lt;p style=&#34;margin: 0in 0in 0pt; direction: ltr; unicode-bidi: embed; text-align: left&#34; dir=&#34;ltr&#34; class=&#34;MsoNormal&#34;&gt; &lt;/p&gt;</description>
			</item>
			<item>
				<title>UI Usability - case studies and recommendations?</title>
				<link>https://bits.strawjackal.org/174/</link>
				<pubDate>Tue, 18 Jul 2006 15:24:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/174/</guid>
				<description>&lt;p&gt;Doing work on our WinForm application, we find ourselves having to make choices - too many choices - about the UI. We don&amp;#39;t have access to professional UI engineers, unfortunately, and we make uneducated guesses on too many issues - should we use a treeview or a filtered list? Should we use opacity in our floating toolbox windows? &lt;/p&gt;&lt;p&gt; Lots of people have very strong opinions about these issues, but very few of us have anything to back them up except &#34;In my experience...&#34;. What I&amp;#39;d love to have is some sort of good web-site that has white-papers, recommendations or analysis of different common UI widgets or patterns and how they translate to end-user usability.&lt;/p&gt;</description>
			</item>
			<item>
				<title>A silly little C# language feature request: .! operator</title>
				<link>https://bits.strawjackal.org/175/</link>
				<pubDate>Thu, 13 Jul 2006 16:17:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/175/</guid>
				<description>&lt;p&gt;When we step back for a moment from our SOAs and Factories and Polymorphism, we have to admit that at the root of much of our code lie a hell of a lot of simple if/else statements. Like it or not, they&amp;#39;re what makes our program logic tick.&lt;/p&gt;&lt;p&gt;All too often, though, our &lt;em&gt;if&lt;/em&gt; logic is reversed - rather than checking for a true condition, we check for false:&lt;/p&gt;&lt;p style=&#34;font-family: courier new&#34;&gt;if (!myDictionary.Contains(key))&lt;br /&gt;{ } &lt;/p&gt;</description>
			</item>
			<item>
				<title>File Properties in Word 2007</title>
				<link>https://bits.strawjackal.org/176/</link>
				<pubDate>Wed, 12 Jul 2006 09:13:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/176/</guid>
				<description>&lt;p&gt;&lt;span&gt;&lt;font size=&#34;3&#34;&gt;A client asked me the other day what happened to File-&gt;Properties in Word 2007. &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font size=&#34;3&#34;&gt;They simply couldn&amp;#39;t find it.&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font size=&#34;3&#34;&gt;In the Beta1 TR, I remember it was confusingly located on the Status Bar (!) – right-click, pick View and View Properties. Very annoying.&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font size=&#34;3&#34;&gt;In Beta 2 it took me a minute to find it, and I have to say the new location isn&amp;#39;t much better – it&amp;#39;s under File/Office/Orb -&gt; Finish:&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font size=&#34;3&#34;&gt; &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;font size=&#34;3&#34;&gt; &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font size=&#34;3&#34;&gt; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>A Better Obfuscation, or How To Write Code That Will Make Someone Kill You</title>
				<link>https://bits.strawjackal.org/177/</link>
				<pubDate>Tue, 11 Jul 2006 08:48:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/177/</guid>
				<description>&lt;P&gt;The following code is perfectly valid C#, and compiles without errors:&lt;/P&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff size=2&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;int&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt; _;&lt;BR&gt;_ = 5;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT size=3&gt;If we take it a bit further, we can do something like this:&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/FONT&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34; color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face=&#34;Courier New&#34;&gt; _, __, ___, ____;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;_ = 5; __ = 10; ___ = 15; ____ = 20;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;_ = __ - _ * ____ / ___;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT size=3&gt;Now I feel like I&#39;m playing Hangman. I feel I should be filling in the blanks.&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT size=3&gt;I&#39;ve never run into anything like this in real code, I&#39;m glad to say. But if Dotfuscator or any other obfuscating tool want to make their obfuscated code even harder to read, they should stop using the easy-to-remember &#34;a&#34;, &#34;b&#34; .. &#34;aa&#34;, &#34;ab&#34; variable names and switch to underscores. It&#39;s horrible.&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;</description>
			</item>
			<item>
				<title>Ping Notifier!</title>
				<link>https://bits.strawjackal.org/178/</link>
				<pubDate>Mon, 03 Jul 2006 06:54:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/178/</guid>
				<description>&lt;P&gt;How many times have you connected to a server via Remote Desktop to install some components?&lt;BR&gt;How many have you rebooted a remote server and sat around waiting for it to go up?&lt;BR&gt;How many times have you opened a command prompt and ran &lt;EM&gt;ping -t&lt;/EM&gt; until the server started responding?&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Well, your days of manual pinging have come to an end! &lt;BR&gt;The PingNotifier comes to the rescue!&lt;/P&gt;&#xD;&#xA;&lt;P&gt;With one small click, you will be able to start pinging a server, and receive a systray notification when the ping is successful, or if an error occurs:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;IMG src=&#34;http://corky.net/~merlin/pingnotifier.png&#34;&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;I&#39;ve attached the full source to this blog post.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;EM&gt;&lt;FONT size=1&gt;(Disclaimer: Code is neither secret nor safe. Does not check validity. Does not care about network load. Does not floss regularly. Does not do tracerouting, change TTLs to try alternate packets sizes. Does not care about the environment. Do not trust the code. Do not trust the code.)&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;</description>
			</item>
			<item>
				<title>Visual Studio obstructing DebugView</title>
				<link>https://bits.strawjackal.org/179/</link>
				<pubDate>Tue, 20 Jun 2006 07:43:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/179/</guid>
				<description>&lt;P&gt;I&#39;ve mentioned it before, but &lt;A href=&#34;http://www.sysinternals.com/&#34;&gt;SysInternal&lt;/A&gt;&#39;s &lt;A href=&#34;http://www.sysinternals.com/Utilities/DebugView.html&#34;&gt;DebugView&lt;/A&gt; is a great utility. It allows you to get the Debug.WriteLine() strings from your application even when you&#39;re not attached with a debugger, as long as it was compiled in Debug mode. Very convenient.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Unfortunately, it&#39;s a bit hard to use when I&#39;m also actually doing work with Visual Studio. It seems that some bits of VS are also logging calls with the &lt;STRONG&gt;OutputDebugString &lt;/STRONG&gt;API call. I can live with the occasional message like this:&lt;/P&gt;&#xD;&#xA;&lt;BLOCKQUOTE dir=ltr style=&#34;MARGIN-RIGHT: 0px&#34;&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=Verdana&gt;[3448] DllCanUnloadNow called for VSA7.dll&lt;BR&gt;[3448] DllCanUnloadNow returned S_FALSE&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&#xD;&#xA;&lt;P dir=ltr&gt;&lt;FONT face=Verdana&gt;&lt;FONT face=&#34;Times New Roman&#34;&gt;but getting these:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;BLOCKQUOTE dir=ltr style=&#34;MARGIN-RIGHT: 0px&#34;&gt;&#xD;&#xA;&lt;P dir=ltr&gt;&lt;FONT face=Verdana&gt;[3448] Left. Enter HWND 90ea6&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&#xD;&#xA;&lt;P dir=ltr&gt;&lt;FONT face=Verdana&gt;&lt;FONT face=&#34;Times New Roman&#34;&gt;whenever I do &lt;STRONG&gt;anything&lt;/STRONG&gt; in Visual Studio is annoying, and quickly hides any pertinent debug messages I want to see.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&#xD;&#xA;&lt;P dir=ltr&gt;Running  Microsoft Visual Studio 2005 Team Edition for Software Developers&lt;BR&gt;Version 8.0.50727.51  (QFE.050727-5100)&lt;BR&gt;Microsoft .NET Framework&lt;BR&gt;Version 2.0.50727&lt;/P&gt;</description>
			</item>
			<item>
				<title>Some thoughts on uninstalling Sharepoint &#39;12&#39; Beta 1</title>
				<link>https://bits.strawjackal.org/180/</link>
				<pubDate>Mon, 19 Jun 2006 17:52:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/180/</guid>
				<description>&lt;P&gt;I&#39;m uninstalling an old beta of the Sharepoint servers from a VPC I have on my computer to make room for the newer Beta 2 servers, and I noticed several things:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;1) The installation originally required a then-current build of Windows Workflow Foundation to install. However, it appears that it also requires it to UNINSTALL. I had to find the old installation of WWF Beta 1.2 and reinstall it. It is no longer available on Microsoft Downloads except as part of the 100MB package containing the Visual Studio extensions. Actual package size - 2.5Mb.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;2) Uninstallation CRAWLS under VPC (512MB RAM, running on a USB2.0 external harddrive).&lt;/P&gt;&#xD;&#xA;&lt;P&gt;3) Is it my imagination? Does it... is it... &lt;BR&gt;No, it&#39;s true. The progress bar for the uninstallation actually does go BACK a few pixels every once in a while. You probably won&#39;t notice it if it isn&#39;t crawling on a background VPC, but it&#39;s true. It&#39;s rocking back and forth. Weird.&lt;/P&gt;</description>
			</item>
			<item>
				<title>My Singleton is disappearing!</title>
				<link>https://bits.strawjackal.org/181/</link>
				<pubDate>Mon, 19 Jun 2006 14:29:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/181/</guid>
				<description>&lt;P&gt;WCF&#39;s Instance Context model allows me to specify my service&#39;s instantiation behavior - I can get a new instance for every call, have WCF manage a session for me and keep an instance per session, or just get lazy and have my service instantiated as a singleton object and use the same instance forever and ever. Juval Lowy covered the basics of these features &lt;A href=&#34;http://msdn.microsoft.com/msdnmag/issues/06/06/WCFEssentials/default.aspx&#34;&gt;here&lt;/A&gt;. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;I had a Singleton service defined, exposing several Operations through two different endpoints. After some testing, I noticed that every time a call was received on one of the interfaces the constructor would be called again - my singleton was getting dumped and recreated.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;It turns out the operation that was causing the problems was marked like this:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;[&lt;FONT color=#008080 size=2&gt;OperationBehavior&lt;/FONT&gt;&lt;FONT size=2&gt;(TransactionScopeRequired = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true&lt;/FONT&gt;&lt;FONT size=2&gt;, TransactionAutoComplete = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true&lt;/FONT&gt;&lt;FONT size=2&gt;)]&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT size=3&gt;Since the transaction behavior was the only lead I had, I started to look into it and checked out the other properties of the OperationBehavior attributes. I found the following attribute: (Warning: Links point to a local MSDN installation)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;&#xD;&#xA;&lt;P&gt;&#xD;&#xA;&lt;TABLE class=memberListTable cellSpacing=2 cellPadding=5 width=&#34;100%&#34;&gt;&#xD;&#xA;&lt;TBODY&gt;&#xD;&#xA;&lt;TR vAlign=top notSupportedOn=&#34;netcf&#34;&gt;&#xD;&#xA;&lt;TD class=imageCell&gt;&lt;/IMG&gt;&lt;/TD&gt;&#xD;&#xA;&lt;TD&gt;&#xD;&#xA;&lt;BLOCKQUOTE dir=ltr style=&#34;MARGIN-RIGHT: 0px&#34;&gt;&#xD;&#xA;&lt;P&gt;&lt;A href=&#34;ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.WinFX4VS.1033/cpref20/html/P_System_ServiceModel_OperationBehaviorAttribute_ReleaseInstanceMode.htm&#34;&gt;&lt;FONT face=Verdana size=2&gt;ReleaseInstanceMode&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/TD&gt;&#xD;&#xA;&lt;TD&gt;&#xD;&#xA;&lt;BLOCKQUOTE dir=ltr style=&#34;MARGIN-RIGHT: 0px&#34;&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Gets or sets a value that indicates when in the course of an operation invocation to recycle the service object.&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/FONT&gt;This operation allows me to declaratively tell WCF to drop my current instance before, after or before AND after my call. This is to allow stateless service calls to ensure that they will not carry over any state between operations. Unfortunately, the default value for the ReleaseInstanceMode is None - this wasn&#39;t the reason I lost my instance.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;The MSDN documentation for ReleaseInstanceMode, however, mentioned the following tidbit of information:&lt;/P&gt;&#xD;&#xA;&lt;BLOCKQUOTE dir=ltr style=&#34;MARGIN-RIGHT: 0px&#34;&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=Verdana size=2&gt;In transaction scenarios, the &lt;B&gt;ReleaseInstanceMode&lt;/B&gt; property is often used to ensure that old data associated with the service object is cleaned up prior to processing a method call. You can also ensure that service objects associated with transactions are recycled after the transaction successfully completes by setting the &lt;/FONT&gt;&lt;A href=&#34;ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.WinFX4VS.1033/cpref20/html/P_System_ServiceModel_ServiceBehaviorAttribute_ReleaseServiceInstanceOnTransactionComplete.htm&#34;&gt;&lt;FONT face=Verdana size=2&gt;ReleaseServiceInstanceOnTransactionComplete&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; property to &lt;B&gt;true&lt;/B&gt;.&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&#xD;&#xA;&lt;P dir=ltr&gt;This led me to the ServiceBehavior&#39;s ReleaseServiceInstanceOnTransactionComplete property which set a more general setting that automatically recycled my service instance whenever a transaction completed successfully. Unlike the ReleaseInstanceMode property, this one is by default set to True, meaning that my transactional operation always released my Singleton instance after each successful run.&lt;/P&gt;&#xD;&#xA;&lt;P dir=ltr&gt;The moral of the story? The usual. Always check default values, especially on WCF&#39;s Behavior attributes that have lots and lots of properties. Good luck.&lt;/P&gt;</description>
			</item>
			<item>
				<title>Hiding properties from the Property Grid</title>
				<link>https://bits.strawjackal.org/182/</link>
				<pubDate>Mon, 12 Jun 2006 06:50:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/182/</guid>
				<description>&lt;P&gt;Taking a break from the main components, I decided to get around to writing a small configuration editor using .NET 2.0&#39;s lovely ability to edit .config files from code.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;I have a custom Section Handler defined for my data, and decided the simplest thing to do would be to stick my custom ConfigurationElement objects onto a PropertyGrid and let the user edit the values directly.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;The problem with that is that ConfigurationElement has several public properties that I inherit, and they show up in the grid:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;IMG src=&#34;http://corky.net/~merlin/PropertyGridBad.png&#34;&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;My first instinct to hide them was to implement ICustomTypeDescriptor on my ConfigurationElement and implement GetProperties() so it only returns the properties I want. This turned out to be a ridiculously complicated endeavor, requiring me to implement many methods I don&#39;t care about just so I could get to GetProperties, which in turn required me to subclass the PropertyDescriptor class and override lots of properties that I didn&#39;t care about either. This whole design-time framework really needs an overhaul - it&#39;s way too complicated and the documentation is vague at best.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;So I abandoned that approach and immediately set off on achieving my goal in the ugliest, hackiest way I could find. The easiest way to hide a property from the propertygrid is using the [Browsable(false)] attribute. Since the properties are unfortunately non-virtual, I had to hide them in order to override their attributes:&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&#xD;&#xA;&lt;P&gt;#region&lt;/FONT&gt;&lt;FONT size=2&gt; Shadow unneeded properties.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Browsable&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;bool&lt;/FONT&gt;&lt;FONT size=2&gt; LockItem { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;get&lt;/FONT&gt;&lt;FONT size=2&gt; { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;base&lt;/FONT&gt;&lt;FONT size=2&gt;.LockItem; } &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;set&lt;/FONT&gt;&lt;FONT size=2&gt; { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;base&lt;/FONT&gt;&lt;FONT size=2&gt;.LockItem = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;value&lt;/FONT&gt;&lt;FONT size=2&gt;; } }&lt;/P&gt;&#xD;&#xA;&lt;P&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Browsable&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ElementInformation&lt;/FONT&gt;&lt;FONT size=2&gt; ElementInformation { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;get&lt;/FONT&gt;&lt;FONT size=2&gt; { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;base&lt;/FONT&gt;&lt;FONT size=2&gt;.ElementInformation; } }&lt;/P&gt;&#xD;&#xA;&lt;P&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Browsable&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ConfigurationLockCollection&lt;/FONT&gt;&lt;FONT size=2&gt; LockAllAttributesExcept { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;get&lt;/FONT&gt;&lt;FONT size=2&gt; { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;base&lt;/FONT&gt;&lt;FONT size=2&gt;.LockAllAttributesExcept; } }&lt;/P&gt;&#xD;&#xA;&lt;P&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Browsable&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ConfigurationLockCollection&lt;/FONT&gt;&lt;FONT size=2&gt; LockAllElementsExcept { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;get&lt;/FONT&gt;&lt;FONT size=2&gt; { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;base&lt;/FONT&gt;&lt;FONT size=2&gt;.LockAllElementsExcept; } }&lt;/P&gt;&#xD;&#xA;&lt;P&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Browsable&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ConfigurationLockCollection&lt;/FONT&gt;&lt;FONT size=2&gt; LockAttributes { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;get&lt;/FONT&gt;&lt;FONT size=2&gt; { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;base&lt;/FONT&gt;&lt;FONT size=2&gt;.LockAttributes; } }&lt;/P&gt;&#xD;&#xA;&lt;P&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Browsable&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ConfigurationLockCollection&lt;/FONT&gt;&lt;FONT size=2&gt; LockElements { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;get&lt;/FONT&gt;&lt;FONT size=2&gt; { &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;base&lt;/FONT&gt;&lt;FONT size=2&gt;.LockElements; } }&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;#endregion&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#000000 size=3&gt;I simply hide them behind my new properties, and have those call the base&#39;s implementation in case they&#39;re actually used for anything.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#000000 size=3&gt;Result? Works perfectly. Hardly clean, but it works:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;IMG src=&#34;http://corky.net/~merlin/PropertyGridGood.png&#34;&gt;&lt;/FONT&gt; &lt;/P&gt;&lt;/FONT&gt;&#xD;&#xA;&lt;P&gt; &lt;/P&gt;&#xD;&#xA;&lt;P&gt; &lt;/P&gt;</description>
			</item>
			<item>
				<title>URIs are not local paths.</title>
				<link>https://bits.strawjackal.org/183/</link>
				<pubDate>Tue, 06 Jun 2006 14:30:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/183/</guid>
				<description>&lt;P&gt;It&#39;s easy to forget that even though a local filesystem path (&#34;C:MyDirMyFile.dll&#34;) can be represented as a Uri (&lt;A href=&#34;file:///C:/MyDir/MyFile.dll&#34;&gt;file://C:/MyDir/MyFile.dll&lt;/A&gt;), these two entities are different, and have different rules for validations.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;The problem &lt;EM&gt;du jour&lt;/EM&gt;, the reason I even got into this, was a simple piece of code that was to set the Current Directory to that of the currently executing assembly:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;&lt;FONT color=#008080&gt;Uri&lt;/FONT&gt; assemblyPath = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;Uri&lt;/FONT&gt;(&lt;FONT color=#008080&gt;Assembly&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;.GetExecutingAssembly().CodeBase);&lt;BR&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (assemblyPath.Scheme == &lt;FONT color=#008080&gt;Uri&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;.UriSchemeFile)&lt;BR&gt;{&lt;BR&gt;&lt;FONT color=#0000ff&gt;   string&lt;/FONT&gt; dllPath = &lt;FONT color=#008080&gt;Path&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;.GetDirectoryName(assemblyPath.PathAndQuery);&lt;BR&gt;&lt;FONT color=#008080&gt;   Directory&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;.SetCurrentDirectory(dllPath);&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;The CodeBase property of the Assembly class gives us the path as a Uri, since assemblies can also be loaded from HTTP paths.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT size=3&gt;This worked fine on most machines, but seemed to break on one. The reason? His path was a valid file system path, but not a valid URI: &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face=&#34;Courier New&#34; size=3&gt;G:C#_ProjectsMyFile.dll&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face=&#34;Courier New&#34; size=3&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT size=3&gt;The problem is that the # sign is a valid path, but a delimiter for URIs - it marks the start of a URI fragment, like a named anchor in an HTML file.  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT size=3&gt;Getting PathAndQuery for the URI simply returned &#34;G:/C&#34;, and dropped everything after the #. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT size=3&gt;The simple solution - rather than attempting to join the URI&#39;s Fragment and Path together, is to remove the scheme (file://) from the beginning and consider that a local path:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#008080&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;Uri&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt; assemblyPath = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;Uri&lt;/FONT&gt;(&#34;&lt;FONT color=#800000&gt;&lt;A href=&#34;file://c:/c#_path/file.dll&#34;&gt;file://c:/c#_path/file.dll&lt;/A&gt;&#34;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;);&lt;BR&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (assemblyPath.Scheme == &lt;FONT color=#008080&gt;Uri&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;.UriSchemeFile)&lt;BR&gt;{&lt;BR&gt;   &lt;FONT color=#006400&gt;// This gives us &#34;c:/c#_path/file.dll&#34;.&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;   string&lt;/FONT&gt; dllPath = assemblyPath.OriginalString.Replace(assemblyPath.Scheme + &lt;FONT color=#008080&gt;Uri&lt;/FONT&gt;.SchemeDelimiter, &lt;FONT color=#800000&gt;&#34;&#34;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;);&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#006400&gt;   // This gives us &#34;c:c#_path&#34;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;      &lt;BR&gt;   dllPath = &lt;FONT color=#008080&gt;Path&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;.GetDirectoryName(dllPath);&lt;BR&gt;&lt;FONT color=#008080&gt;   Directory&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;.SetCurrentDirectory(dllPath);&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;</description>
			</item>
			<item>
				<title>ParamArrays and CLS-compliance.</title>
				<link>https://bits.strawjackal.org/184/</link>
				<pubDate>Mon, 05 Jun 2006 13:54:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/184/</guid>
				<description>&lt;P&gt;In my &lt;A href=&#34;./avnerk/archive/2006/06/05/Problems-with-params-array_3F00_.aspx&#34;&gt;previous&lt;/A&gt; post, I noted that when I write this code in C#:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;public void MyMethod (params object[] args) { ... }&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;What I actually get in my IL is this:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;public void MyMethod ([System.ParamArray]object[] args) { ... }&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;I have this suspicion due to:&lt;BR&gt;1) The fact that the C# compiler tells me to use &lt;EM&gt;params&lt;/EM&gt; instead of the attribute&lt;BR&gt;2) The fact that a function with the same signature except for the &lt;EM&gt;params &lt;/EM&gt;keyword results in a duplicate signature&lt;BR&gt;3) Because I opened up Reflector and saw it happening in the IL.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;The &lt;EM&gt;params&lt;/EM&gt; keyword in C# (and the ParamArray keyword in VB.NET) is a shorthand for applying the ParamArray attribute to the method. I assume the sole reason for the existence of the attribute is to notify the relevant compiler that when parsing a call to that function it should wrap the arguments in an array - nothing happens at runtime at all. It&#39;s a language feature of C# and VB that is backed up by an attribute in the BCL, but does not have any representation in the CLR.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;In the comments to that post, &lt;A id=_ctl0____ctl0____ctl1___Comments___Comments__ctl2_NameLink title=&#34;Thomas Tomiczek&#34; href=&#34;./utility/Redirect.aspx?U=http%3a%2f%2fwww.powernodes.com%2f&#34; target=_blank rel=nofollow&gt;Thomas Tomiczek&lt;/A&gt; disagreed:&lt;BR&gt;&#xD;&#xA;&lt;BLOCKQUOTE&gt;&lt;EM&gt;&#34;Given that the ParamArrayAttribute is defined in System and HAS to be supported by the langauge compilers, basically, it is not a choice of the language. As such, it is not a language feature. It is a requirement. &lt;BR&gt;WIth the same logic you could say that support for a lot of other things is optional - it is not. &#34;&lt;/EM&gt;&lt;/BLOCKQUOTE&gt;&#xD;&#xA;&lt;P&gt;I am not sure I agree with this logic. Any .NET language has to support decorating the parameter with the ParamArray attribute of course, but I&#39;m not sure that it&#39;s required to be supported by all .NET languages.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;I had a brief glance at the CLS specification and found this &lt;A href=&#34;http://msdn.microsoft.com/en-us/library/12a7a7h3.aspx&#34;&gt;paragraph&lt;/A&gt;:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&#xD;&#xA;&lt;TABLE cellSpacing=2 cellPadding=5 width=&#34;100%&#34;&gt;&#xD;&#xA;&lt;TBODY&gt;&#xD;&#xA;&lt;TR&gt;&#xD;&#xA;&lt;TD&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Argument lists&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&#xD;&#xA;&lt;TD&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=Verdana size=2&gt;All&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&#xD;&#xA;&lt;TD&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The only calling convention supported by the CLS is the standard managed calling convention; variable length argument lists are not allowed. (Use the &lt;B&gt;ParamArray&lt;/B&gt; keyword in Microsoft Visual Basic and the &lt;B&gt;params&lt;/B&gt; keyword in C# for variable number of arguments support.)&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;What this seems to mean is that the concept of variable length argument lists do &lt;STRONG&gt;not&lt;/STRONG&gt; exist in the CLR, and the only way to pass a variable number of arguments is through arrays. VB.NET and C#, to name particular examples, provide us with language features (in the form of the &lt;EM&gt;params&lt;/EM&gt; and &lt;EM&gt;ParamArray &lt;/EM&gt;keywords) that save us the effort of creating arrays and do the wrapping-up for us. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;The way I see it, the fact that it uses an attribute that&#39;s defined in the System namespace, rather than language-specific namespaces (assuming one such would exist for C#) is just a result of the C# and VB teams working closely with the BCL designers.&lt;/P&gt;</description>
			</item>
			<item>
				<title>Problems with params array?</title>
				<link>https://bits.strawjackal.org/185/</link>
				<pubDate>Mon, 05 Jun 2006 11:45:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/185/</guid>
				<description>&lt;P&gt;I noticed today that the ever-popular String.Format() method has several overloads - in addition to the Format(string format, params object[] args) overload I was expecting, it seems there are three special-case overloads for one, two or three parameters. A glance with Reflector shows that these three overloads simply instantiate a new object[] with the given args and pass them on to the main overload.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Does anyone have any idea why it&#39;s doing that? Is there some sort of performance penalty involved with using params array that the BCL team decided to bypass by special-casing the most common instances?&lt;/P&gt;&#xD;&#xA;&lt;P&gt;I was given to understand that that &lt;EM&gt;params&lt;/EM&gt; token is a compile-time only feature of the C# language, and shouldn&#39;t have any effect after compilation.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Interesting.&lt;/P&gt;</description>
			</item>
			<item>
				<title>Query SUBST information</title>
				<link>https://bits.strawjackal.org/186/</link>
				<pubDate>Sun, 04 Jun 2006 11:48:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/186/</guid>
				<description>&lt;P&gt;For various reasons involving out testing framework, I found myself needing to get the full command-line of the current executing assembly. However, our development environment uses the DOS SUBST command to map a virtual drive letter for our dev files, so we have a consistent environment for all development machines. This is problematic, since I need this command-line to be launched in a different user context, where this SUBST mapping doesn&#39;t exist. In short, I needed a way to get the real path to a file beyond the SUBST illusion.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;The answer turned out to be surprisingly easy, and required only a tiny bit of P/Invoking. I&#39;ve included the signature here and also updated it on pinvoke.net, where it was using a more complicated signature using IntPtr that is only required if we want more than one return value for the function.&lt;BR&gt;Make sure the &lt;EM&gt;ucchMax&lt;/EM&gt; parameter you pass the function is the same size as you initialize the StringBuilder&#39;s buffer:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT color=#0000ff size=2&gt;private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;static&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; GetRealPath(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt; path)&lt;BR&gt;{&lt;BR&gt;   &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt; realPath = path;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;   &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;StringBuilder&lt;/FONT&gt;&lt;FONT size=2&gt; pathInformation = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;StringBuilder&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;(250);&lt;BR&gt;   &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; driveLetter = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Path&lt;/FONT&gt;&lt;FONT size=2&gt;.GetPathRoot(realPath).Replace(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;&#34;&#34;&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;&#34;&#34;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;);&lt;BR&gt;   QueryDosDevice(driveLetter, pathInformation, 250);&lt;BR&gt;   &lt;BR&gt;   &lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT color=#008000 size=2&gt;// If drive is substed, the result will be in the format of &#34;??C:RealPath&#34;.&lt;BR&gt;   &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (pathInformation.ToString().Contains(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;&lt;A href=&#34;file://??&#34;&gt;??&lt;/A&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;))&lt;BR&gt;   {&lt;BR&gt;      &lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT color=#008000 size=2&gt;// Strip the ?? prefix.&lt;BR&gt;      &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt; realRoot = pathInformation.ToString().Remove(0, 4);&lt;BR&gt;      &lt;BR&gt;      &lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT color=#008000 size=2&gt;//Combine the paths.&lt;BR&gt;      &lt;/FONT&gt;&lt;FONT size=2&gt;realPath = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Path&lt;/FONT&gt;&lt;FONT size=2&gt;.Combine(realRoot, realPath.Replace(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Path&lt;/FONT&gt;&lt;FONT size=2&gt;.GetPathRoot(realPath), &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;&#34;&#34;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;));&lt;BR&gt;   }&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face=&#34;Courier New&#34;&gt; realPath;&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;[&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT color=#008080 size=2&gt;DllImport&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;&#34;kernel32.dll&#34;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;static&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;extern&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;uint&lt;/FONT&gt;&lt;FONT size=2&gt; QueryDosDevice(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; lpDeviceName, &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;StringBuilder&lt;/FONT&gt;&lt;FONT size=2&gt; lpTargetPath, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; ucchMax);&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&#xD;&#xA;&lt;P&gt; &lt;/P&gt;</description>
			</item>
			<item>
				<title>From Accessors to Properties</title>
				<link>https://bits.strawjackal.org/187/</link>
				<pubDate>Wed, 31 May 2006 12:02:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/187/</guid>
				<description>&lt;P&gt;For various debugging processes, I find myself needing to find several bits of runtime information for my properties. This means I want to get the property&#39;s PropertyInfo object by Reflection when that property&#39;s code is running.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;The problem is that Properties are C# constructs, not IL constructs. My property&#39;s &lt;EM&gt;get&lt;/EM&gt; accessor is actually compiled into a &lt;EM&gt;get_MyProp()&lt;/EM&gt; method. This means that while I can easily get the MethodInfo for the current accessor, there doesn&#39;t appear to be any easy way of getting the PropertyInfo from the MethodInfo.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;The ugly way, of course, is to take the method&#39;s name, strip the first four characters from it and do a GetProperty() with that name - and that works, of course, but causes me actual physical pain to use:&lt;FONT color=#008080 size=2&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;PropertyInfo&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face=&#34;Courier New&#34;&gt; prop = accessorMethod.ReflectedType.GetProperty(accessorMethod.Name.Remove(0, 4));&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&#xD;&#xA;&lt;P&gt;Is there a better, simpler way I&#39;m missing?&lt;/P&gt;</description>
			</item>
			<item>
				<title>Serializing Dictionaries</title>
				<link>https://bits.strawjackal.org/188/</link>
				<pubDate>Tue, 23 May 2006 11:18:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/188/</guid>
				<description>&lt;P&gt;Dictionaries have been an annoyance when serializing for a while now. IDictionary in v1.1 and now IDictionary&lt;K,V&gt; in v2.0 are both non-serializable, forcing us to find workarounds or use DataTables or any number of unsatisfactory solutions.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;My guess is that is has something to do with the whole buckets/hashcode implementation. If we serialize a dictionary and then deserialize it on a different machine or process, the keys might have a different hashcode - the default hashcode for a reference type is its reference pointer, AFAIK - and the dictionary will be corrupted. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;A quick solution for this is to transform the dictionary into a collection of KeyValuePairs, which is a non-hashed straightforward array, and serialize and deserialize that. This means the hashing algorithm runs again when we deserialize, building the new dictionary from scratch.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Usage is then simple:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;DictionarySerializer&lt;string, int&gt; serializer = new DictionarySerializer&lt;string,int&gt;();&lt;BR&gt;serializer.Serialize(myDictionary, myStreamWriter);&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;When implementing this, it turned out that while KeyValuePair&lt;K,V&gt; is marked as Serializable, it actually isn&#39;t possible to meaningfully serialize it. This is due to its Key and Value members being read-only, and the XmlSerializer only serializing public members. (More information &lt;A href=&#34;http://blogs.msdn.com/seshadripv/comments/488273.aspx&#34;&gt;here&lt;/A&gt;).&lt;BR&gt;Due to this, I simply implemented my own internal SerializableKeyValuePair&lt;K,V&gt; struct and use that instead.&lt;BR&gt;The Serialize method now looks something like this:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;public void Serialize (IDictionary&lt;K,V&gt; dictionary, StreamWriter serializationStream)&lt;BR&gt;{&lt;BR&gt;   List&lt;SerializableKeyValuePair&lt;K,V&gt;&gt; dictionaryItems = GetKeyValueList(dictionary);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;   XmlSerializer ser = new XmlSerializer(typeof(List&lt;SerializableKeyValuePair&lt;K,V&gt;&gt;));&lt;BR&gt;   ser.Serialize(serializationStream, dictionaryItems);&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Deserialization will follow logically:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;public IDictionary&lt;K,V&gt; Deserialize (StreamReader serializationStream)&lt;BR&gt;{&lt;BR&gt;   XmlSerializer ser = new XmlSerializer(typeof(List&lt;SerializableKeyValuePair&lt;K,V&gt;&gt;));&lt;BR&gt;   List&lt;SerializableKeyValuePair&lt;K,V&gt;&gt; dictionaryItems = ser.Deserialize(serializationStream) as List&lt;SerializableKeyValuePair&lt;K,V&gt;&gt;;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;   IDictionary&lt;K,V&gt; dictionary = new Dictionary&lt;K,V&gt;(dictionaryItems.Count);&lt;BR&gt;   foreach (SerializableKeyValuePair&lt;K,V&gt; item in dictionaryItems)&lt;BR&gt;   {&lt;BR&gt;      dictionary.Add(item.Key, item.Value);&lt;BR&gt;   }&lt;BR&gt;   &lt;BR&gt;   return dictionary;&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;The problem with making this totally generic is that the serializer can receive a Stream, a TextWriter or an XmlWriter - three classes that do not share any common ancestor. This means we have several overloads doing exactly the same only with different types. A shame.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;I&#39;ve attache the full class for this, slightly more refactored than what I have here. Enjoy.&lt;/P&gt;</description>
			</item>
			<item>
				<title>Bad compiler warnings when using anonymous methods for Predicate&lt;T&gt;</title>
				<link>https://bits.strawjackal.org/189/</link>
				<pubDate>Mon, 22 May 2006 18:33:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/189/</guid>
				<description>&lt;P&gt;I was sitting around munching some code, and needed to filter a list I had:&lt;/P&gt;&lt;FONT color=#008080 size=2&gt;&#xD;&#xA;&lt;P&gt;List&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Whatever&lt;/FONT&gt;&lt;FONT size=2&gt;&gt; list = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;// get list&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT size=2&gt;outputList = list.FindAll(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;delegate&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Whatever &lt;/FONT&gt;&lt;FONT size=2&gt;item)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;   if&lt;/FONT&gt;&lt;FONT size=2&gt; (// blah blah)&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;   {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;      return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;BR&gt;   }&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;FONT color=#d3d3d3&gt;  else&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#d3d3d3&gt;&lt;FONT size=2&gt;   {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;   return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT size=2&gt;false&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#d3d3d3&gt;;&lt;BR&gt;   }&lt;BR&gt;&lt;/FONT&gt;}&lt;BR&gt;);&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT size=2&gt;(Ignore the greyed-out text for now).&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT size=2&gt;When compiling, I got a strange error message:&lt;BR&gt;&lt;EM&gt;&#34;cannot convert from &#39;anonymous method&#39; to &#39;System.Predicate&lt;Whatever&gt;&#39;&#34;.&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;This put me off for a few minutes while I tried checking code samples and such to make sure that this really SHOULD work. Only when I tried explicitly casting the anonymous delegate to a Predicate&lt;Whatever&gt; did I get a proper compiler error: &lt;BR&gt;&lt;EM&gt;&#39;System.Predicate&lt;Whatever&gt;&#39;: not all code paths return a value&#39;&lt;/EM&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Turns out my actual syntax error was being caught by the compiler and incorrectly reported. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;Just a heads-up, in case it happens to anyone else. &lt;BR&gt;Ladybug bug ID is FDBK50271, if anyone cares.&lt;/P&gt;</description>
			</item>
			<item>
				<title>Creating nested directories</title>
				<link>https://bits.strawjackal.org/190/</link>
				<pubDate>Mon, 22 May 2006 10:30:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/190/</guid>
				<description>&lt;P&gt;Just a quick tip to prevent others from feeling as foolish as I do:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;The static CreateDirectory() method of the System.IO.Directory class will create the entire directory tree passed to it. There&#39;s no need to write an EnsurePathExists() method that recursively creates the folders. Absolutely no need. Not even just to be safe. It works. Trust me. Trust the framework. The framework is your friend.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;[This has been a public service announcement by the Society for the Reinvention of the Wheel]&lt;/P&gt;</description>
			</item>
			<item>
				<title>Non-generic default values in C#? Why not?!</title>
				<link>https://bits.strawjackal.org/191/</link>
				<pubDate>Sun, 21 May 2006 08:58:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/191/</guid>
				<description>&lt;p&gt;A relatively obscure new keyword in C# 2.0 is the default(T) keyword. &lt;br /&gt;It&#39;s shorthand for checking if the given generic parameter T is a value type or reference type. If it&#39;s a reference type, it returns null. Otherwise it returns 0/false/0.0 or whatever the default value for the type is.&lt;/p&gt; &lt;p&gt;For some reason, though, it can only be used on generic parameters. Why can&#39;t I use default(typeof(int)) to get 0? Or, more realistically, default(myUnknownType) to return the default value?&lt;/p&gt;</description>
			</item>
			<item>
				<title>Context-Bound Thread Queuer - FunFun.</title>
				<link>https://bits.strawjackal.org/192/</link>
				<pubDate>Fri, 19 May 2006 16:12:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/192/</guid>
				<description>&lt;p class=&#34;MsoNormal&#34; dir=&#34;ltr&#34; style=&#34;text-align: left; direction: ltr; unicode-bidi: embed;&#34;&gt;As I mentioned in my previous post, I have a need to consistently pass an operation context to any thread I choose to spin. Doing so manually, as I did here, involves a lot of ugly, repetitive code for every thread. A lot of room for mistakes and bugs. &lt;br /&gt;So using the power that .NET delegates give us, I&#39;ve built a generic Context-bound threadpool queue class to wrap this logic for me.&lt;o:p&gt; &lt;br /&gt;&lt;/o:p&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>OperationContext is ThreadStatic</title>
				<link>https://bits.strawjackal.org/193/</link>
				<pubDate>Thu, 18 May 2006 14:29:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/193/</guid>
				<description>&lt;p&gt;WCF Services tend to be big, heavy duty things. When I write a service I often want it to do a lot of work for a lot of clients, and it should do it efficiently. This usually means that I will use multithreaded code to get things done concurrently. Whether using the ThreadPool or instantiating a thread of my own, I expect this is a common scenario for WCF service writers. &lt;br /&gt;&lt;br /&gt;That&amp;rsquo;s why I was suprised today to find out that the OperationContext of the current service call, our entry point for getting context information about the current call, its headers and so forth - is marked as [ThreadStatic]. This means that the moment I fork off to another thread, I lose all context information. If I want it available, I have to do it myself. &lt;br /&gt;&lt;br /&gt;I don&amp;rsquo;t know how ASP.NET deals with this problem. If I spin a new thread under ASP.NET, I don&amp;rsquo;t lose my current HttpContext. A quick glance with Reflector shows that there&amp;rsquo;s no [ThreadStatic] anywhere. Whatever features of IIS they use there, it&amp;rsquo;s probably unavailable for WCF, so we have to do it manually. &lt;br /&gt;&lt;br /&gt;The simplest way to pass the context to a thread is just to send it as a parameter: &lt;br /&gt;&lt;br /&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;void Method () &lt;br /&gt;{ &lt;br /&gt;    ThreadPool.QueueUserWorkItem(ThreadMethod, OperationContext.Current); &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void ThreadMethod(object state) &lt;br /&gt;{ &lt;br /&gt;    OperationContext.Current = state as OperationContext; &lt;br /&gt;    // Do whatever. &lt;br /&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Side note: Note the automatic delegate inference that .NET 2.0 does, rather than forcing me to manually create a WaitCallback delegate: &lt;br /&gt;&lt;font face=&#34;&#39;Courier New&#39;,Courier,monospace&#34;&gt;ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadMethod), OperationContext.Current);&lt;/font&gt; &lt;br /&gt;I don&amp;rsquo;t think this was possible in v1.1.&lt;/i&gt; &lt;br /&gt;&lt;br /&gt;If we want to spin a thread of our own, we can use the ParameterizedThreadStart delegate: &lt;br /&gt;&lt;br /&gt;&lt;font face=&#34;Courier New&#34;&gt;void Method () &lt;br /&gt;{ &lt;br /&gt;    Thread t = new Thread(new ParameterizedThreadStart(ThreadMethod), OperationContext.Current); &lt;br /&gt;    t.Start(); &lt;br /&gt;} &lt;/font&gt;&lt;br /&gt;&lt;br /&gt; If we have parameters to pass to our method, though, we need to be even hackier - maybe define a struct or class to hold our OperationContext as well as the custom parameters, and pass that on to the ThreadMethod and have it disassemble it. &lt;br /&gt;&lt;br /&gt;There is a better way to build a Thread Launcher than can pass the ObjectContext. I&amp;rsquo;ll elaborate on that in my next post.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Share your interfaces - avoid static proxies.</title>
				<link>https://bits.strawjackal.org/194/</link>
				<pubDate>Wed, 17 May 2006 12:24:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/194/</guid>
				<description>&lt;p&gt;When using WCF services, we have several options for creating the proxies. We can create them statically using SVCUTIL or the build-in IDE support (Add Service Reference&amp;hellip;), or we can generate them dynamically using the ChannelFactory&lt;T&gt; or &lt;a href=&#34;http://blogs.microsoft.co.il/blogs/bursteg/archive/2006/04/17/103.aspx&#34;&gt;GenericProxy&lt;T&gt;&lt;/a&gt; approaches.&lt;br /&gt;&lt;br /&gt;The advantage of the static proxy approach is that it we local code for us based on remote metadata (WSDL). Even if the service is somewhere out of our reach and control, all we need is for it to expose metadata for us to access it. We get a copy of the service contract and interfaces and we&amp;rsquo;re good to go. &lt;br /&gt;The problems with it is that I have to maintain that proxy. If the service changes, our proxy needs to adapt too. I&amp;rsquo;m not referring to versioning issues and new methods added, but to big changes in the service contract itself. This may not be an issue when accessing stable services, but certainly happens a lot during development.&lt;br /&gt;&lt;br /&gt;The second approach is much more limited - for it to work we need to have a reference to a shared assembly containing the contracts. It means our services and contracts are .NET classes using the WCF framework, rather than generic WS-* services that can have any implementation. This approach is only useful when we have access to the our services&amp;rsquo; code or assemblies, so it&amp;rsquo;s out of the question for public services. &lt;br /&gt;In short, the dynamic proxy approach is only for use when we control both client and server in the scope of a single application (or group of familiar applications).&lt;br /&gt;&lt;br /&gt;But in this context, this is &lt;b&gt;the&lt;/b&gt; best way to work. I&amp;rsquo;ll stress the point again - if we meet all the criteria above for using dynamic proxies, we should use them without hesitation.&lt;br /&gt;The amount of work that goes into maintaining the static proxies, making sure that the client and server copies of the contracts are identical, hours of debugging mysterious errors caused by contract mismatches - all with perplexing error messages and little documentation - all these things are simply not worth it.&lt;br /&gt;&lt;br /&gt;I&amp;rsquo;ll say it again - if you&amp;rsquo;re writing an N-tier application that uses WCF for communication, have the contracts shared by both client and server and use the GenericProxy&lt;T&gt; class to access it rather than relying on generated proxies and SVCUTIL. Trust me. Your deadline will thank you for it.&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Deperplexing WCF errors pt. 3 - Interfaces and KnownTypes</title>
				<link>https://bits.strawjackal.org/195/</link>
				<pubDate>Tue, 16 May 2006 13:40:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/195/</guid>
				<description>&lt;p&gt;Another error message that stumped me today (after I had removed the &lt;A href=&#34;http://weblogs.asp.net/avnerk/archive/2006/05/16/446673.aspx&#34;&gt;IsOneWay&lt;/a&gt; parameter and actually got to see it) was the following exception:&lt;br /&gt;&lt;font size=&#34;2&#34;&gt;&lt;b&gt;&lt;br /&gt;&lt;font face=&#34;Verdana&#34;&gt;System.ServiceModel.CommunicationException&lt;br /&gt;&lt;/font&gt;&lt;/b&gt;&lt;/font&gt;&lt;span style=&#34;font-size: 12pt; font-family: &#34; new=&#34;&#34; roman=&#34;&#34;&gt;&lt;font face=&#34;Verdana&#34; size=&#34;2&#34;&gt;The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;This little gem was caused when calling a method on a service with an interface as a parameter, something like this:&lt;br /&gt;&lt;br /&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;[OperationContract]&lt;br /&gt;void DoSomething (IMessage message)&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;When deserializing the IMessage, WCF had no way of knowing what type to deserialize it as, so it through the charming message above.&lt;br /&gt;I don&amp;rsquo;t know how this situation came to be, since the proxy generated by svcutil seems to create the message as DoSomething(object message) and not IMessage, but the principle should be the same.&lt;br /&gt;&lt;br /&gt;The immediate solution that fixed this was adding the [KnownType(typeof(myMessage))] attribute to the method. This allows the deserialization engine to understand the message and do something constructive with it rather than crashing.&lt;br /&gt;&lt;br /&gt;Naturally, I am less than pleased with this solution. The whole purpose of using interfaces is that I won&amp;rsquo;t have to know, when coding, what objects will be passed to my service. I just want to expose the interface.&lt;br /&gt;&lt;br /&gt;One way to keep this flexibility can be found in the very last paragraph of the long and detailed &lt;a href=&#34;http://windowssdk.msdn.microsoft.com/library/default.asp?url=./library/en-us/wcf_con/html/1a0baea1-27b7-470d-9136-5bbad86c4337.asp&#34;&gt;Data Contract Known Types&lt;/a&gt; article on MSDN - it seems that the list of Known Types can be defined globally in the system using the &amp;lt;system.runtime.serialization&amp;gt; section in the config file. Details about that are also sparse, and I&amp;rsquo;m not at all sure if it&amp;rsquo;s possible in the January CTP - the section names seem to have changed from &lt;xmlformatter&gt; to &lt;datacontractserializer&gt; between January and February, and there are no samples to explain the proper structure for the January version. I hope this gets clearer with the next beta.&lt;br /&gt;&lt;/span&gt;&lt;span style=&#34;font-size: 12pt; font-family: &#34; new=&#34;&#34; roman=&#34;&#34;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Deperplexing WCF errors pt. 2 - IsOneWay swallowing exceptions</title>
				<link>https://bits.strawjackal.org/196/</link>
				<pubDate>Tue, 16 May 2006 12:28:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/196/</guid>
				<description>&lt;p&gt;The first step in understanding WCF error messages is making sure you actually get them.&lt;br /&gt;&lt;br /&gt;You can have an OperationContract defined with the IsOneWay parameter set to True, thus optimizing it by not requiring a reply message. &lt;br /&gt;Since faults and exceptions are represented as replies to the message sent, however, setting IsOneWay to true will cause WCF to simply swallow the exception and not report it - as far as the framework is concerned the message was sent successfully and that&amp;rsquo;s it.&lt;br /&gt;&lt;br /&gt;If you want to use the IsOneWay optimization, it&amp;rsquo;s best to save it for later parts of development, after the basic debugging work is done.&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Deperplexing WCF errors pt. 1 - CommunicationObjectAbortedException for security mismatch</title>
				<link>https://bits.strawjackal.org/197/</link>
				<pubDate>Mon, 15 May 2006 10:03:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/197/</guid>
				<description>&lt;p&gt;As a follow-up to this &lt;A href=&#34;http://weblogs.asp.net/avnerk/archive/2006/05/08/445599.aspx&#34;&gt;post&lt;/a&gt;: another reason why we get CommunicationObjectAbortedExceptions is because our client channel definition does not send any credentials (using a binding that has the SecurityMode set to None) while the service is still set to the default settings, expecting Windows authentication. Rather than throwing some sort of SecurityException, the exception is raised. &lt;br /&gt;Just a heads up.&lt;br /&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>System.Reflection.Omit</title>
				<link>https://bits.strawjackal.org/198/</link>
				<pubDate>Mon, 15 May 2006 06:45:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/198/</guid>
				<description>&lt;p&gt;In TechEd Israel 2006, I listened to &lt;A href=&#34;http://weblogs.asp.net/rosherove&#34;&gt;Roy Osherove&lt;/a&gt;&amp;rsquo;s excellent talk on the new &lt;A href=&#34;http://weblogs.asp.net/rosherove/archive/2006/05/14/446356.aspx&#34;&gt;reflection features&lt;/a&gt; in .NET 2.0 - a great assortment of topics on things ranging from DynamicMethods to the ReflectionOnly- set of properties.&lt;br /&gt;One of the things he mentioned was that the GetCustomAttributes method that&amp;rsquo;s exposed by various reflection types was unsafe. When the method returns the collection of custom attributes, it has to instantiate each one of them, and this means calling the constructor on each one of them. This could be the &amp;ldquo;crack in the door&amp;rdquo; for an attacker to use an extensible plug-in architecture to slide his own code by inheriting a custom atttribute with malicious constructor code and decorating a class with it.&lt;br /&gt;The solution in .NET 2.0 comes from the CustomAttributeData class, which has a single static method - GetCustomAttributes - which returns the list of attributes without calling their constructors. This seems a cleaner and safer solution, and I couldn&amp;rsquo;t wait to go and fix up my reflection code in the current project with it.&lt;br /&gt;&lt;br /&gt;The problem with this implementation, as always, is in the little details. The GetCustomAttributes method we have on the reflection types are implemented via the ICustomAttributeProvider interface, which is implemented by Type, ParameterInfo, MethodInfo and all those other attribute-supporting constructs. The GetCustomAttribute method of the CustomAttributeData class, though, has several overloads taking MemberInfos, Assemblys, ParameterInfo or Module - the four classes that implement ICustomAttributeProvider. This means that while it is theoretically equivalent to the older method, it does not allow me to cast my member/type/assembly to an ICustomAttributeProvider and perform operations on it - I have several attribute-related functions that take either a Type or a Property, so in this case I can cast them both to MemberInfos and use that as my lowest common denominator. But what if I had needed to handle Assemblies as well?&lt;br /&gt;&lt;br /&gt;A rather annoying ommision. Whenever I&amp;rsquo;m forced to use concrete classes rather than base-classes or interfaces, I get slightly nervous. It may be fine for the time being, but I know that somewhere down the line, I&amp;rsquo;ll try to refactor something and get bitten.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;EDIT: &lt;/b&gt;searching Google, it seems that I am the very first to use the &amp;ldquo;Reflection.Omit&amp;rdquo; pun, or at least to publish it on a Googleable medium. Cool.&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Indigo Errors Perplexing</title>
				<link>https://bits.strawjackal.org/199/</link>
				<pubDate>Mon, 08 May 2006 12:06:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/199/</guid>
				<description>&lt;p&gt;I was writing a very simple WCF service. Nothing fancy - just returning an array of structs via TCP, just like 3 others already implemented. Started testing, stepped through the server code, returned the value from the service interface, then WHAM - a big scary exception:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;System.ServiceModel.CommunicationObjectAbortedException&lt;/b&gt;&lt;br /&gt;The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue.&lt;br /&gt;&lt;br /&gt;Inner Exception: &lt;br /&gt;&lt;b&gt;System.Net.SocketException&lt;/b&gt;&lt;br /&gt;An existing connection was forcibly closed by the remote host&lt;br /&gt;&lt;br /&gt;This rather scary error message is not very helpful. Was it because of a timeout? (Unlikely, as it happened immediately). Underlying network resource issue? Happens too predictably. Error processing your message? What does that mean, anyway? WHAT error processing my message? And anyway, the inner SocketException seems to imply that it&amp;rsquo;s a network error, not a message error.&lt;br /&gt;&lt;br /&gt;But of course it is. WCF didn&amp;rsquo;t really point me towards it, but it seems I had forgotten to mark my struct as a [DataContract] and its members as [DataMember]s. No contract, nothing to serialize, no message. &lt;br /&gt;&lt;br /&gt;Perfectly understandable, once you know what&amp;rsquo;s going on. Totally perplexing until you do.&lt;br /&gt;&lt;font size=&#34;1&#34;&gt;&lt;br /&gt;&lt;/font&gt;&lt;font size=&#34;1&#34;&gt;Now let&amp;rsquo;s give this entry some Googlejuice so people who are experiencing this problem can find it: &lt;br /&gt;&lt;i&gt;WCF, Indigo, CommunicationObjectAbortedException,  SocketException, DataContract.&lt;/i&gt;&lt;br /&gt;There. That should do it. &lt;/font&gt;&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>One-Click Wonder</title>
				<link>https://bits.strawjackal.org/200/</link>
				<pubDate>Sun, 07 May 2006 12:52:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/200/</guid>
				<description>&lt;p&gt;It turns out that you can easily close a tab with one click on the middle mouse button. On most modern mice, this would be the scroll wheel button. No fuss, no right-clicking, no selecting the tab and going to the other end of the screen for the X button. Just a single middle-click.&lt;br /&gt; &lt;br /&gt; This works in Visual Studio 2005, in IE7, Firefox 1.5 and RSSBandit, to go by the applications I&amp;rsquo;ve tested it in. Seems to be a common UI convention that I have been entirely ignorant of. It&amp;rsquo;s probably common knowledge for many people, but I only recently discovered it.&lt;br /&gt;When I shared the discovery with my office-mates, it turned out that quite a few of them weren&amp;rsquo;t aware of this trick either, so I figured I&amp;rsquo;d share it here for all the others who have missed it:&lt;br /&gt;&lt;br /&gt;Enjoy.&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>A new conditional assignment operator??</title>
				<link>https://bits.strawjackal.org/201/</link>
				<pubDate>Thu, 04 May 2006 09:40:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/201/</guid>
				<description>&lt;p&gt;This one may have slipped beneath the radar, with all the new .NET 2.0 and WinFX and other improvements and APIs and language changes. It appears that C# 2.0 adds a new operator to the mix, and I never even knew it was there.&lt;br /&gt;&lt;br /&gt;The operator is ??, and it&amp;rsquo;s a conditional non-null operator. Since that doesn&amp;rsquo;t really mean anything, I&amp;rsquo;ll simply and say that the ?? operator returns the left hand operand if it is non-null, otherwise it returns the righthand operand:&lt;br /&gt;&lt;font face=&#34;Courier New&#34;&gt;&lt;br /&gt;&lt;font size=&#34;2&#34;&gt;string a =  null;&lt;br /&gt;string b = &amp;ldquo;String&amp;rdquo;;&lt;br /&gt;Console.WriteLine (a ?? b); // Will output &amp;ldquo;String&amp;rdquo;.&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;This is shorthand for the common pattern we see using the ternary conditional operator, like this:&lt;br /&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;&lt;br /&gt;Console.WriteLine (a != null ? a : b);&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;which is in turn shorthand for:&lt;br /&gt;&lt;br /&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;if (a != null)&lt;br /&gt;{&lt;br /&gt;   Console.WriteLine(a);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;   Console.WriteLine(b);&lt;br /&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;The ternary conditional is held by many to be a sin against nature and code readability, though I personally find it quite clear and convenient. The non-null conditional is a bit less clear - there&amp;rsquo;s nothing in its syntax to suggest an either/or relation. Perhaps it will clear things up. Perhaps it will lie unused and forgotten . Time will tell.&lt;br /&gt;&lt;br /&gt;Note: For some reason, the MSDN library groups the ?? operator with the Assignment operators, rather than the Conditional operators. Strange.&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Serializing a Binding object - TimeSpan serialization error.</title>
				<link>https://bits.strawjackal.org/202/</link>
				<pubDate>Sun, 30 Apr 2006 16:36:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/202/</guid>
				<description>&lt;p&gt;Seeing as our project is all distributed and stuff, with various services possibly running on different servers, we wanted to have the whole service address business be flexible, and not rely on hardcoded values in app.config files. &lt;br /&gt;We have a Configuration service, which is the only hardcoded address, and it can return the address for any given service.&lt;br /&gt;&lt;br /&gt;The item we&amp;rsquo;re using here is my own ServiceAddress object, which contains an EndpointAddress object and a Binding object for a given service. This way we can easily have a service switch from TCP to HTTP binding if necessary without redeploying. All is well.&lt;br /&gt;&lt;br /&gt;The problem is that this configuration is stored on the Config server as an XML file with the ServiceAddress object serialized to XML. This means that the Binding object is also serialized to XML, and there lies the problem - the TimeSpan structure in .NET 2.0 cannot be serialized to XML. It loses all data and becomes an empty node, recreated as a 0-length TimeSpan when deserialized. &lt;br /&gt;Since the Binding class has several TimeSpan properties for the timeout values, my service agents timeout immediately when attempting to contact the service. &lt;br /&gt;&lt;br /&gt;Apparently the TimeSpan problem is a well-known one (&lt;a href=&#34;http://www.peterprovost.org/archive/2003/05/21/486.aspx&#34;&gt;here&lt;/a&gt;, &lt;a href=&#34;http://codebetter.com/blogs/brendan.tompkins/archive/2004/08/10/21612.aspx&#34;&gt;there&lt;/a&gt; and &lt;a href=&#34;http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=1c655df8-798c-485c-a15f-6c3c5a3f6bee&#34;&gt;everywhere&lt;/a&gt;), but the common workaround (of adding a new property with the TimeSpan&amp;rsquo;s Ticks value) isn&amp;rsquo;t really feasible a WinFX framework class.&lt;br /&gt;&lt;br /&gt;I can extract and store the values manually during the serialization phase, but that seems ridiculously inelegant.&lt;br /&gt;Another idea is to store the configuration files in the same format as they are defined in the app.config, and use the ClientSection class from System.ServiceModel.Configuration namespace to save and load the data. This is probably more complicated since I don&amp;rsquo;t know if I can generate a &lt;client&gt; section from a Binding object. This means I can only read the configuration, not write to it from within my program.&lt;br /&gt;&lt;br /&gt;Anyone have any other ideas?&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>VSS and mapped file locations</title>
				<link>https://bits.strawjackal.org/203/</link>
				<pubDate>Thu, 27 Apr 2006 06:20:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/203/</guid>
				<description>&lt;p&gt;Just a quick tip about the some new problems we&amp;rsquo;re having with VSS:&lt;br /&gt;To ease integration and control, all developers on the team have their local development drive mapped to drive P:, to make sure all file references are consistent between developers. Since it&amp;rsquo;s just a subst-mapping and actually points to the original location, some of us opened the solution from the original location expecting it to work.&lt;br /&gt;It does &lt;b&gt;not&lt;/b&gt; work.&lt;br /&gt;The two locations might be identical on the local disk, but as far as VSS is concerned they are two different locations with different data. If you checked out a file in P: and try to check it in from C:MyProject, VSS will complain that you are checking it in from a different location. This might lead to any number of annoying errors and even loss of data if you&amp;rsquo;re not careful. So be careful, and always open your solution from the same location.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Adding custom headers to every WCF call - a solution</title>
				<link>https://bits.strawjackal.org/204/</link>
				<pubDate>Wed, 26 Apr 2006 08:20:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/204/</guid>
				<description>&lt;p&gt;At last, a solution presented itself. While I must admit that at first I was very skeptical of the extensibilty model for WCF which seemed far too involved and complicated, but after implementing a simple extension I must say it&amp;rsquo;s simple and quite intuitive.&lt;br /&gt;&lt;br /&gt;My goal was to have several custom headers added to each call made through a proxy, rather than manually adding them to each call&amp;rsquo;s OperationContext. With a little help from &lt;a href=&#34;http://blogs.msdn.com/ralph.squillace/&#34;&gt;Ralph Squillace&amp;rsquo;s blog&lt;/a&gt;, I was able to get an extension up and running within minutes, and it Just Works.&lt;br /&gt;&lt;br /&gt;The first item to build is the actual extension logic. In this case, I needed an IProxyMessageInspector object that inspects each outgoing message and adds the custom headers:&lt;br /&gt;&lt;br /&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;public class ContextPusher : IProxyMessageInspector&lt;br /&gt;    {&lt;br /&gt;        public void AfterReceiveReply(ref Message reply, object correlationState)&lt;br /&gt;        {&lt;br /&gt;            // Do nothing.&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public object BeforeSendRequest(ref Message request, IClientChannel channel)&lt;br /&gt;        {&lt;br /&gt;            MessageHeader myHeader = new MessageHeader&lt;string&gt;(&amp;ldquo;HeaderValue&amp;rdquo;).GetUntypedHeader(&amp;ldquo;MyHeader&amp;rdquo;, &amp;ldquo;ns&amp;rdquo;);&lt;br /&gt;            request.Headers.Add(&lt;/font&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;myHeader&lt;/font&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;);&lt;br /&gt;            return null; &lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;Now we want to attach that inspector to proxy. We do that wth Behavior objects. This can be done on an operation-by-operation basis or for all operations on a given channel. We can make the same class implement both behaviors, for flexibility:&lt;br /&gt;&lt;br /&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;public class CallContextAttribute : Attribute, IChannelBehavior, IOperationBehavior&lt;br /&gt;    {&lt;br /&gt;        #region IOperationBehavior Members&lt;br /&gt;&lt;br /&gt;        public void ApplyBehavior(OperationDescription description, ProxyOperation proxy, BindingParameterCollection parameters)&lt;br /&gt;        {       &lt;br /&gt;            // Add my MessageInspector to each message sent by the proxy.&lt;br /&gt;            proxy.Parent.MessageInspectors.Add(new ContextPusher());&lt;br /&gt;   &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void ApplyBehavior(OperationDescription description, DispatchOperation dispatch, BindingParameterCollection parameters)&lt;br /&gt;        {&lt;br /&gt;            // No server-side behaviors for now.&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;                &lt;br /&gt;        #region IChannelBehavior Members&lt;br /&gt;&lt;br /&gt;        public void ApplyBehavior(ChannelDescription description, ProxyBehavior behavior, BindingParameterCollection parameters)&lt;br /&gt;        {&lt;br /&gt;            // Add the MessageInspector to every message sent through the channel.&lt;br /&gt;            behavior.MessageInspectors.Add(new ContextPusher());&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;    }&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;And then simply put it on a Service or Operation.&lt;br /&gt;I think in this case, putting the attribute on both will result in an error when trying to add duplicate headers. But this allows me flexibility in adding the headers only to certain calls.&lt;br /&gt;&lt;br /&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;[ServiceContract]&lt;br /&gt;[CallContext]&lt;br /&gt;public interface ILocalizationServices&lt;br /&gt;{&lt;br /&gt;   [OperationContract]&lt;br /&gt;   [CallContext]&lt;br /&gt;   string DoSomething(string param);&lt;br /&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;I think this is the first time I got really excited by the WCF framework and the ease of using and extending it. This is FUN.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>How do I add a custom header to every WCF message?</title>
				<link>https://bits.strawjackal.org/205/</link>
				<pubDate>Tue, 25 Apr 2006 12:10:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/205/</guid>
				<description>&lt;p&gt;One thing I still haven&amp;rsquo;t managed to do is create my proxy in such a way that a custom header is added to every call that is made through that proxy. &lt;br /&gt;Currently, this is done by instantiating a new OperationContext around each call through the proxy. This can be optimized in several ways:&lt;br /&gt;1) Create a shared OperationContext object and always instatiate the OperationContextScope with it:&lt;br /&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;using (OperationContextScope scope = new     &lt;br /&gt;            OperationContextScope(standardContextObject))&lt;br /&gt;{&lt;br /&gt;   &amp;hellip;&lt;br /&gt;}&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;I don&amp;rsquo;t know if it&amp;rsquo;s a good idea, though. Should OperationContext objects be persisted between calls, or would it have unexpected side effects?&lt;br /&gt;&lt;br /&gt;2) Create a wrapper around the OperationContextScope class that fills the OperationContext with the proper headers:&lt;br /&gt;&lt;br /&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;public class MyOperationContextScope : IDisposable&lt;br /&gt;{&lt;br /&gt;   OperationContextScope contextScope;&lt;br /&gt;&lt;br /&gt;   public MyOperationContextScope ()&lt;br /&gt;   {&lt;br /&gt;      contextScope = new OperationContextScope();&lt;br /&gt;      MessageHeader standardHeader = new    &lt;br /&gt;      MessageHeader&lt;string&gt;(&amp;ldquo;StringHeaderValue&amp;rdquo;).GetUntypedHeader(&amp;ldquo;StringHeader&amp;rdquo;, &amp;ldquo;ns&amp;rdquo;);&lt;br /&gt;      OperationContext.Current.OutgoingMessageHeaders.Add(standardHeader );&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void Dispose()&lt;br /&gt;    {&lt;br /&gt;      if (contextScope != null)&lt;br /&gt;      {&lt;br /&gt;          contextScope.Dispose();&lt;br /&gt;      }&lt;br /&gt;    }      &lt;br /&gt; }&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;This is a bit cleaner, but still requires me to wrap every proxy call with a using() statement.&lt;br /&gt;&lt;br /&gt;Is there a way to interecept all calls and have my headers added automatically?&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Adding custom headers to a WCF message - Jan CTP</title>
				<link>https://bits.strawjackal.org/206/</link>
				<pubDate>Tue, 25 Apr 2006 12:03:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/206/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;http://blogs.microsoft.co.il/blogs/bursteg/default.aspx&#34;&gt;Guy Burstein,&lt;/a&gt; again, writes about &lt;a href=&#34;http://blogs.microsoft.co.il/blogs/bursteg/archive/2006/04/23/141.aspx&#34;&gt;adding custom headers&lt;/a&gt; to a call made by a WCF proxy.&lt;br /&gt;This is all very nice and well, but his code only works with the Feb. CTP of WCF, while I&amp;rsquo;m still using January here. &lt;br /&gt;The differences seemed subtle at first - his instantiation of the OperationContextScope passed the proxy to the constructor, but there is no such constructor in the January CTP.&lt;br /&gt;Simply instantiating the OperationContextScope with no parameters and adding headers seemed to work, but those headers never made it to the server-side.&lt;br /&gt;&lt;br /&gt;After much fussing and digging, it turns out that the headers &lt;b&gt;were&lt;/b&gt; transferred, but the way to fetch them was obscure. I don&amp;rsquo;t know if this was a design change from Jan to Feb or maybe it was just a bug that was fixed, but instead of accessing the headers like this:&lt;br /&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;&lt;br /&gt;string myHeader = OperationContext.Current.IncomingMessageHeaders.GetHeader&lt;string&gt;(&amp;ldquo;myHeader&amp;rdquo;, &amp;ldquo;myNS&amp;rdquo;);&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;we have to do it like this:&lt;br /&gt;&lt;br /&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;string myHeader = OperationContext.Current.RequestContext.RequestMessage.Headers.GetHeader&lt;string&gt;(&amp;ldquo;myHeader&amp;rdquo;, &amp;ldquo;myNS&amp;rdquo;);&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Hope it helps.&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>VSS2005 - staying in line</title>
				<link>https://bits.strawjackal.org/207/</link>
				<pubDate>Mon, 24 Apr 2006 09:13:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/207/</guid>
				<description>&lt;p&gt;Working with Visual SourceSafe always feels to me like walking on eggshells. One wrong move and you get that sickening crunching feeling and things seem to collapse.&lt;br /&gt;&lt;br /&gt;My current project&amp;rsquo;s integrator decided to keep things neat. There&amp;rsquo;s a central solution containing all the projects, sitting under a central project in VSS. Dozens of projects, divided with Solution folders, all neat and ready for integration builds.&lt;br /&gt;Naturally, most of us don&amp;rsquo;t really need all those projects open in our solutions when we work. They slow down work and are generally a headache, so we decided that everyone can create his own customized solutions and work against them. &lt;br /&gt;For some reason, the decision was made to create a project folder under VSS for each team member, and have each team-member keep his own solutions there so as to not mess up the main project folder with random SLNs. It goes something like this:&lt;br /&gt;&lt;br /&gt;$&lt;br /&gt;  / &lt;br /&gt;  / MainSolution&lt;br /&gt;  / MainSolution / FirstProject&lt;br /&gt;  / MainSolution / SecondProject&lt;br /&gt;  / Avner&lt;br /&gt;&lt;br /&gt;Where my SLN file now sits in $/Avner but references projects in $/MainSolution/FirstProject.&lt;br /&gt;&lt;br /&gt;Anyone who&amp;rsquo;s worked with VSS might already be wincing in anticipation. &lt;br /&gt;Visual Studio doesn&amp;rsquo;t really like to have project references not sitting underneath the current solution&amp;rsquo;s VSS root. If I add a new project under my solution and then check it in, it will automatically check that project in under my solution folder ($/Avner/ThirdProject). I have to remember to manually go to File -&amp;gt; Source Control -&amp;gt; Add to Source Control and answer &amp;lsquo;No&amp;rsquo; when it asks me whether to add it under the solution folder.&lt;br /&gt;&lt;br /&gt;Assuming I made a mistake, I can either spend 20 minutes struggling with moving it around and updating the bindings, or go the easy way: Erase the projects from VSS, remove them from the solution, then re-add them, permanently remove all SCC bindings and re-add them to the proper place. Ugh.&lt;br /&gt;&lt;br /&gt;Since no-one enjoys that, I&amp;rsquo;ll try to list some recommendations:&lt;br /&gt;&lt;br /&gt;1) When working with multiple solutions, it&amp;rsquo;s best to have them all reside in the same root solution project.&lt;br /&gt;2) If you must put them in alternate folders, it&amp;rsquo;s best to create any new projects from the master solution to ensure they are created in the right place, then add them to the sub-solution using File-&amp;gt;Add Existing Project -&amp;gt; From SourceSafe (LAN).&lt;br /&gt;3) If you created them directly from the subsolution, make sure you don&amp;rsquo;t check them in immediately, but manually add them to the right place from File -&amp;gt; Source Control -&amp;gt; Add Project To Source Control.&lt;br /&gt;4) If you did, don&amp;rsquo;t try to fix it. Just erase from VSS and from the solution and re-do from start.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Genericizing the GenericProxy&lt;T&gt;</title>
				<link>https://bits.strawjackal.org/208/</link>
				<pubDate>Sun, 23 Apr 2006 08:11:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/208/</guid>
				<description>&lt;p&gt;A few days ago, &lt;a href=&#34;http://blogs.microsoft.co.il/blogs/bursteg/default.aspx&#34;&gt;Guy Burstein&lt;/a&gt; wrote a entry on avoiding design-time generated proxies by extending the ClientBase&lt;t&gt; class to create a &lt;a href=&#34;http://blogs.microsoft.co.il/blogs/bursteg/archive/2006/04/17/103.aspx&#34;&gt;GenericProxy&lt;t&gt;&lt;/a&gt;. This proxy uses the client binding data in the app.config file to auto-create an appropriate proxy when the interface is shared by both client and server.&lt;br /&gt;&lt;br /&gt;I gleefully lifted that piece of code for use in my emerging WCF project, but needed it a bit more generic than that. Seeing as I currently have no need for any fine-tuned configuration, I can get by with a GenericProxy that explicitly gets the Binding and EndpointAddress of the service in question. Since the ClientBase&lt;t&gt; already supports this, I just have to make sure that my GenericProxy&lt;t&gt; exposes this too:&lt;br /&gt;&lt;br /&gt;&lt;font face=&#34;Courier New&#34;&gt;public GenericProxy(Binding binding, EndpointAddress address)&lt;br /&gt;            : base(binding, address)&lt;br /&gt;{ }&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Which now allows me to instantiate my proxy like this:&lt;br /&gt;&lt;br /&gt;&lt;font face=&#34;Courier New&#34;&gt;EndpointAddress address = new EndpointAddress(serviceUri);&lt;br /&gt;Binding binding = new NetTcpBinding();&lt;br /&gt;GenericProxy&lt;iconfigurationservice&gt; configurationProxy = new GenericProxy&lt;iconfigurationservice&gt;(binding, address);&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;As long as I don&amp;rsquo;t need any customizations beyond the basic binding and URI, I don&amp;rsquo;t need any configuration files whatsoever in my client.&lt;br /&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Creating metadata from WCF executables</title>
				<link>https://bits.strawjackal.org/209/</link>
				<pubDate>Sun, 09 Apr 2006 15:33:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/209/</guid>
				<description>&lt;p&gt;&lt;font face=&#34;Verdana&#34;&gt;So I&amp;rsquo;ve started messing around with WinFX and WCF. &lt;br /&gt;It certainly feels like it needs more work, especially on the dev-tool end of things.&lt;br /&gt;&lt;br /&gt;I was trying to run SvcUtil to generate metadata and proxy from a console application and ran into this error message:&lt;br /&gt; &lt;br /&gt;&lt;/font&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;Error: There was an error exporting the ContractDescription loaded from the type&lt;br /&gt;: Strawjackal.WCFTest.IService, MyService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&lt;br /&gt;    Duplicate contract QNames are not supported.&lt;br /&gt;Another ContractDescription with the Name: IService and Namespace:&lt;br /&gt;Strawjackal.WCFTest has already been exported.&lt;br /&gt;&lt;font size=&#34;3&#34;&gt;&lt;font face=&#34;Verdana&#34;&gt;&lt;br /&gt;This was very confusing until I found this page &lt;a href=&#34;http://jeffknutson.blogspot.com/2006/01/indigo-gotcha-1.html&#34;&gt;here&lt;/a&gt; explaining that SvcUtil is simply broken when running on EXE assemblies. The original poster&amp;rsquo;s solution was to recompile his assembly as a class, but I&amp;rsquo;ve discovered that an even simpler solution is to just rename my EXE to a DLL, run SvcUtil against it, and rename it back. &lt;br /&gt;&lt;br /&gt;WSDL created.&lt;br /&gt;Me happy.&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Problems I&#39;ve encountered  today when installing the WinFX January 2006 CTP</title>
				<link>https://bits.strawjackal.org/210/</link>
				<pubDate>Thu, 06 Apr 2006 15:20:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/210/</guid>
				<description>&lt;p&gt;&lt;br /&gt;&lt;p class=&#34;MsoListParagraphCxSpFirst&#34; dir=&#34;ltr&#34; style=&#34;margin: 0cm 0cm 0.0001pt 36pt; text-align: left; text-indent: -18pt; direction: ltr; unicode-bidi: embed;&#34;&gt;&lt;!-- [if !supportLists] --&gt;&lt;b&gt;&lt;span style=&#34;&#34;&gt;&lt;span style=&#34;&#34;&gt;1)&amp;lt;span style=&amp;ldquo;font-family: &amp;quot; new=&amp;rdquo;&amp;quot; roman=&amp;quot;&amp;quot; font-style=&amp;quot;&amp;quot; normal=&amp;quot;&amp;quot; font-variant=&amp;quot;&amp;quot; normal=&amp;quot;&amp;quot; font-weight=&amp;quot;&amp;quot; normal=&amp;quot;&amp;quot; font-size=&amp;quot;&amp;quot; 7pt=&amp;quot;&amp;quot; line-height=&amp;quot;&amp;quot; normal=&amp;quot;&amp;quot; font-size-adjust=&amp;quot;&amp;quot; none=&amp;quot;&amp;quot; font-stretch=&amp;quot;&amp;quot; normal=&amp;quot;&amp;quot;&amp;gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;!-- [endif] --&gt;&lt;span dir=&#34;ltr&#34;&gt;&lt;b&gt;Documentation Errors&amp;lt;o:p&amp;gt;&amp;lt;/o:p&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&#34;MsoListParagraphCxSpMiddle&#34; dir=&#34;ltr&#34; style=&#34;margin: 0cm 0cm 0.0001pt 36pt; text-align: left; direction: ltr; unicode-bidi: embed;&#34;&gt;When reading the documentation, I get scripting errors when accessing every page – a 80041001 script error, after which the page is readable but suffers from some layout issues. Oh, and occasionally it crashes.&amp;lt;o:p&amp;gt;&amp;lt;/o:p&amp;gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Kerberos and Web Service Preauthentication</title>
				<link>https://bits.strawjackal.org/211/</link>
				<pubDate>Mon, 13 Feb 2006 12:22:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/211/</guid>
				<description>&lt;p class=&#34;MsoNormal&#34; style=&#34;MARGIN: 0cm 0cm 0pt&#34;&gt;My current project has been having various inconsistent, irreproducible 401 Unauthorized errors on our web service calls. We tried various tests, checks, changes and wild guesses, and we think we’ve landed it this time. Let’s recap the problem:&lt;/p&gt; &lt;p class=&#34;MsoNormal&#34; style=&#34;MARGIN: 0cm 0cm 0pt&#34;&gt;&lt;?xml:namespace prefix = o ns = &#34;urn:schemas-microsoft-com:office:office&#34; /&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt; &lt;p class=&#34;MsoNormal&#34; style=&#34;MARGIN: 0cm 0cm 0pt&#34;&gt;&lt;b&gt;Symptoms&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class=&#34;MsoNormal&#34; style=&#34;MARGIN: 0cm 0cm 0pt&#34;&gt;Among the several web-service calls the system makes, some consistently succeed, while some receive sporadic 401 (Unauthorized) results from the web-service.&lt;span style=&#34;mso-spacerun: yes&#34;&gt;  &lt;/span&gt;When these are caught and retried, they will sometimes succeed. Sometimes it only succeeds after several retries.&lt;/p&gt;</description>
			</item>
			<item>
				<title>When is a dash not a dash?</title>
				<link>https://bits.strawjackal.org/212/</link>
				<pubDate>Tue, 17 Jan 2006 15:26:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/212/</guid>
				<description>&lt;p&gt;An interesting an unusually frustrating pitfall that I&#39;ve stumbled into a few times:&lt;/p&gt; &lt;p&gt;Many times when we&#39;re preparing for deployment of a software product, we find ourselves preparing a Word document with the steps for installation. In the case of my current system, installing the server requires several manual steps, among them running a command-line utility to set some Kerberos security parameters.&lt;/p&gt; &lt;p&gt;Naturally, being the friendly and considerate developers we are, we supplied the full command-line that is to be run on the target machine, complete will all options, parameters and variables.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Macro Origins</title>
				<link>https://bits.strawjackal.org/213/</link>
				<pubDate>Wed, 11 Jan 2006 22:44:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/213/</guid>
				<description>&lt;p&gt;I&#39;ve been wondering about the origin and etymology of the term &#34;macro&#34; as it is used in programming. The general use for it is to mean something large - the opposite of &#34;micro&#34; - but it didn&#39;t seem to fit for the concept it&#39;s used for.&lt;/p&gt; &lt;p&gt;Luckily, the &lt;a href=&#34;http://www.etymonline.com/index.php?term=macro-&#34;&gt;Online Etymology Dictionary&lt;/a&gt; came to my rescue:&lt;/p&gt; &lt;p&gt;&lt;em&gt;&#34;As a stand-alone word, in computer programming, meaning &#34;a macro-instruction,&#34; it is attested from 1959. &#34;&lt;/em&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Visual Studio 2005, WinForms designer and the DataDirectory.</title>
				<link>https://bits.strawjackal.org/214/</link>
				<pubDate>Sun, 25 Dec 2005 19:54:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/214/</guid>
				<description>&lt;p&gt;Why, oh why must the simplest things be plagued with the most annoying problems?&lt;/p&gt; &lt;p&gt;Finally gotten around to messing with Visual Studio 2005, I started a long-overdue project I promised someone. A very simple affair - MDB database, WinForms front-end, no tiers, no nothing. Just a simple customer-management app for 1-2 users.&lt;/p&gt; &lt;p&gt;My first impressions from using the new Studio were excellent - the new WinForms designer is nothing short of wondrous (lines! Give me more lines on the canvas!) and the databinding wizards worked great, straight out of the box. I created my main form, created a user-control that covers most of the input fields, and things went great. &lt;/p&gt;</description>
			</item>
			<item>
				<title>Impersonation and EFS</title>
				<link>https://bits.strawjackal.org/215/</link>
				<pubDate>Thu, 01 Dec 2005 12:10:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/215/</guid>
				<description>&lt;p&gt;A quick reminder, after having spent too much time on it this morning:&lt;/p&gt; &lt;p&gt;When impersonating a client context (in this case through SSPI over Remoting), not only can you not access external network resources, you also can&#39;t access files and directories encrypted with EFS. I was stumped over this - WindowsIdentity.GetCurrent() returned the proper user, but trying to create a new file in an encrypted folder resulted in UnauthorizedAccessExceptions (Win32 error #5). &lt;/p&gt;</description>
			</item>
			<item>
				<title>Outlook Miscellany: Erasing a name from the Autocomplete Cache</title>
				<link>https://bits.strawjackal.org/216/</link>
				<pubDate>Mon, 14 Nov 2005 07:35:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/216/</guid>
				<description>&lt;p&gt;The drop-down list of names that Outlook gives us to auto-complete a name or address being written is stored in a file called &lt;ProfileName&gt;.NK2 in our Application DataMicrosoftOutlook directory. This file is stored in a proprietary binary format, and there&amp;#39;s no known documentation for it as far as I know. There seems to be a company that (apparently) reverse-engineered the format and are selling a cache-editing tool, but it&amp;#39;s pricey - the basic desktop version can edit, import/export and print for $35. The network/helpdesk editions can do remote NK2 editing for all computer on the network, but gets really pricy with per-seat licenses and so forth.&lt;br /&gt;(They&amp;#39;re called &lt;a href=&#34;http://www.ingressor.com/ingressor.htm&#34;&gt;Ingressor&lt;/a&gt;, if anyone needs those tools)&lt;/p&gt;</description>
			</item>
			<item>
				<title>Disposable Unimpersonation</title>
				<link>https://bits.strawjackal.org/217/</link>
				<pubDate>Thu, 10 Nov 2005 07:40:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/217/</guid>
				<description>&lt;p&gt;A &lt;A href=&#34;http://weblogs.asp.net/avnerk/archive/2004/09/22/232967.aspx&#34;&gt;while ago&lt;/a&gt;, I discussed the possibility of using RevertToSelf() to avoid Double Hop problems. I suggested this pattern can be wrapped inside a class implementing IDisposable to easily use it.&lt;/p&gt; &lt;p&gt;This is the implementation of this Unimpersonator class:&lt;/p&gt; &lt;p&gt;Code:&lt;/p&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;1&#34;&gt; &lt;p&gt;&lt;font size=&#34;2&#34;&gt;using&lt;/font&gt;&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; System;&lt;br /&gt;&lt;font color=&#34;#0000ff&#34;&gt;using&lt;/font&gt; System.Runtime.InteropServices;&lt;br /&gt;&lt;font color=&#34;#0000ff&#34;&gt;using&lt;/font&gt; System.Security.Principal;&lt;br /&gt;&lt;font color=&#34;#0000ff&#34;&gt;namespace&lt;/font&gt; Strawjackal.Utils&lt;br /&gt;{&lt;br /&gt;   &lt;font color=&#34;#0000ff&#34;&gt;public&lt;/font&gt; &lt;font color=&#34;#0000ff&#34;&gt;class&lt;/font&gt; Unimpersonator : IDisposable&lt;br /&gt;   {&lt;br /&gt;      &lt;font color=&#34;#0000ff&#34;&gt;private&lt;/font&gt; WindowsIdentity m_CurrentUser;&lt;br /&gt;      &lt;br /&gt;      &lt;font color=&#34;#0000ff&#34;&gt;public&lt;/font&gt; Unimpersonator()&lt;br /&gt;      {&lt;br /&gt;         m_CurrentUser = WindowsIdentity.GetCurrent();&lt;br /&gt;         RevertToSelf();&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      &lt;font color=&#34;#0000ff&#34;&gt;public&lt;/font&gt; &lt;font color=&#34;#0000ff&#34;&gt;void&lt;/font&gt; Dispose()&lt;br /&gt;      {&lt;br /&gt;         &lt;font color=&#34;#0000ff&#34;&gt;if&lt;/font&gt; (m_CurrentUser != &lt;font color=&#34;#0000ff&#34;&gt;null&lt;/font&gt;)&lt;br /&gt;         m_CurrentUser.Impersonate();&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      [DllImport(&#34;advapi32.dll&#34;)]&lt;br /&gt;&lt;font color=&#34;#0000ff&#34;&gt;      private&lt;/font&gt; &lt;font color=&#34;#0000ff&#34;&gt;static&lt;/font&gt; &lt;font color=&#34;#0000ff&#34;&gt;extern&lt;/font&gt; &lt;font color=&#34;#0000ff&#34;&gt;int&lt;/font&gt; RevertToSelf();&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Control.DefaultValue isn&#39;t.</title>
				<link>https://bits.strawjackal.org/218/</link>
				<pubDate>Sun, 06 Nov 2005 08:23:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/218/</guid>
				<description>&lt;p&gt;Here is a common source of confusion and frustration that&#39;s been experienced by most people developing a custom control in .NET - in WinForms,WebForms, Sharepoint and whatnot.&lt;/p&gt; &lt;p&gt;One of the designer attributes you can put on a control&#39;s properties is the System.ComponentModel.DefaultValue attribute, that defines the default value for a property if no specific value has been assigned to it. A common (and understandable) misconception is that setting this attribute will set the specified value for the property.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Recycling Application Pools in IIS 6.0</title>
				<link>https://bits.strawjackal.org/219/</link>
				<pubDate>Sun, 09 Oct 2005 20:53:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/219/</guid>
				<description>&lt;p&gt;A quick tip for those of us fond of &lt;em&gt;iisreset&lt;/em&gt;. Restarting IIS takes quite a while. Sometimes 15-20 seconds, when my w3wp.exe processes are particularly unruly. In many cases, though, a full &lt;em&gt;iisreset &lt;/em&gt;is unnecessary. Since IIS 6.0 expanded its process isolation model to include Application Pools, the simplest way is to simply recycle the application pool - takes only a second, and usually does the trick.&lt;/p&gt; &lt;p&gt;We can do this in .NET with very little effort:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Over-Abstraction? A debate.</title>
				<link>https://bits.strawjackal.org/220/</link>
				<pubDate>Thu, 06 Oct 2005 13:12:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/220/</guid>
				<description>&lt;p&gt;I&#39;ve been having an argument with a co-worker of mine about the KeyboardHook code I recently published &lt;A href=&#34;http://weblogs.asp.net/avnerk/archive/2005/10/06/426739.aspx&#34;&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;His claim - by exposing a KeyboardHook object and letting users add Filters for specific keystrokes, I am exposing too much of my inner implementation that shouldn&#39;t interest the user of my library. Properly abstracted and refactored, the user should treat each KeyboardHook object as a specific keystroke-capture object, not have to deal with two different objects here. Various implementation details like explicitly calling Install() should be implicitly called whenever the event is hooked up to an event handler, rather than being left to the innocent caller.&lt;br /&gt;&lt;br /&gt;While my code uses this:&lt;/p&gt;</description>
			</item>
			<item>
				<title>By Hook or by Crook</title>
				<link>https://bits.strawjackal.org/221/</link>
				<pubDate>Thu, 06 Oct 2005 11:42:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/221/</guid>
				<description>&lt;p&gt;While trying to implement custom shortcut keys in Outlook, I came across an old column by Dino Esposito on implementing custom &lt;a href=&#34;http://msdn.microsoft.com/msdnmag/issues/02/10/CuttingEdge/&#34;&gt;Windows hooks in .NET&lt;/a&gt;. At first I wanted to use it as reference and inspiration only, and only when I finished did I notice I simply rewrote, from scratch, most of the code he offers in his article. The main difference is that he supplies a base, generic WindowsHook class and a derived CBTHook class to handle window opening/closing/etc events, while I implemented my generic parent class and a derived KeyboardHook class for keyboard events. This is implemented as thread-local hooks on the currently running process, rather than expensive global system hooks.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Debug Timing (and a little design pattern, to boot)</title>
				<link>https://bits.strawjackal.org/222/</link>
				<pubDate>Wed, 28 Sep 2005 17:40:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/222/</guid>
				<description>&lt;div&gt;&lt;span class=&#34;171541413&#34;&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;In almost every bit of code I write that&#39;s actually destined to go into a real system, I find myself start to look for places to optimize code. But having read the &lt;a href=&#34;http://channel9.msdn.com/wiki/default.aspx/Channel9.RicoM&#34;&gt;writings&lt;/a&gt; of &lt;a href=&#34;http://blogs.msdn.com/ricom&#34;&gt;Rico Mariani&lt;/a&gt;, I am weary of premature optimizations. So what do we do? We measure, of course.&lt;/font&gt;&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span class=&#34;171541413&#34;&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;&lt;/font&gt;&lt;/span&gt; &lt;/div&gt; &lt;div&gt;&lt;span class=&#34;171541413&#34;&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;A full-fledged profiler is often overkill when I just want to check how long a method runs. Sometimes a few quick debug-printouts will do the job just fine. I&#39;ve written hundreds of &lt;em&gt;Debug.WriteLine(&#34;Start block&#34;) &lt;/em&gt;and &lt;em&gt;Debug.WriteLine(&#34;End Block&#34;) &lt;/em&gt;statements, and it get wearisome typing the same commands, formatting the same start and end times, again and again.&lt;/font&gt;&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span class=&#34;171541413&#34;&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;&lt;/font&gt;&lt;/span&gt; &lt;/div&gt; &lt;div&gt;&lt;span class=&#34;171541413&#34;&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;So without further ado, he is the complete code for my little DebugTimer helper class, implemented using the &lt;A href=&#34;http://weblogs.asp.net/avnerk/archive/2004/06/30/170127.aspx&#34;&gt;Disposable Design Pattern&lt;/a&gt; of which I am so fond. Use it in good health.&lt;/font&gt;&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span class=&#34;171541413&#34;&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;&lt;/font&gt;&lt;/span&gt; &lt;/div&gt; &lt;div&gt;&lt;span class=&#34;171541413&#34;&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt; &lt;p&gt;public&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; &lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;class&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; DebugTimer : IDisposable&lt;br /&gt;{&lt;br /&gt;   &lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;private&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; DateTime start;&lt;br /&gt;&lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;   private&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; &lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;string&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; label;&lt;br /&gt;&lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;   private&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; &lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;static&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; &lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;int&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; level = 0;&lt;br /&gt;&lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;&lt;br /&gt;   public&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; &lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;static&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; DebugTimer Start (&lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;string&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; Label)&lt;br /&gt;   {&lt;br /&gt;&lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;      return&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; &lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;new&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; DebugTimer(Label);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;   private&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; DebugTimer (&lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;string&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; Label)&lt;br /&gt;   {&lt;br /&gt;      level++;&lt;br /&gt;&lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;      this&lt;/font&gt;&lt;font size=&#34;2&#34;&gt;.label = Label;&lt;br /&gt;&lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;      this&lt;/font&gt;&lt;font size=&#34;2&#34;&gt;.start = DateTime.Now;&lt;br /&gt;&lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;      string&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; message = &lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;string&lt;/font&gt;&lt;font size=&#34;2&#34;&gt;.Format(&lt;/font&gt;&lt;font color=&#34;#800000&#34; size=&#34;2&#34;&gt;&#34;{2}{0}: {1}&#34;&lt;/font&gt;&lt;font size=&#34;2&#34;&gt;, &lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;this&lt;/font&gt;&lt;font size=&#34;2&#34;&gt;.label, &lt;/font&gt;&lt;font color=&#34;#800000&#34; size=&#34;2&#34;&gt;&#34;Starting&#34;&lt;/font&gt;&lt;font size=&#34;2&#34;&gt;, &lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;new&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; &lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;string&lt;/font&gt;&lt;font size=&#34;2&#34;&gt;(&lt;/font&gt;&lt;font color=&#34;#800000&#34; size=&#34;2&#34;&gt;&#39; &#39;&lt;/font&gt;&lt;font size=&#34;2&#34;&gt;, level));&lt;br /&gt;&lt;font color=&#34;#0000ff&#34;&gt;      &lt;/font&gt;System.Diagnostics.Debug.WriteLine(message);&lt;br /&gt;&lt;font color=&#34;#0000ff&#34;&gt;   &lt;/font&gt;}&lt;/p&gt;</description>
			</item>
			<item>
				<title>I pity the fool who messes with CTRL-SHIFT-T.</title>
				<link>https://bits.strawjackal.org/223/</link>
				<pubDate>Mon, 22 Aug 2005 16:24:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/223/</guid>
				<description>&lt;p&gt;The Visual Studio IDE, among its myriad options and combinations and features and so forth, has a trio of rather odd key combinations:&lt;/p&gt; &lt;p&gt;CTRL-T - Interchanges the current letter and the one after it.&lt;br /&gt;CTRL-SHIFT-T - Same thing, only for the current word.&lt;br /&gt;ALT-SHIFT-T - Same thing, only for the current line.&lt;/p&gt; &lt;p&gt;These keybindings have been there at the very least since Visual Studio 4, where I first came across them. &lt;/p&gt;</description>
			</item>
			<item>
				<title>DatePicker Blues.</title>
				<link>https://bits.strawjackal.org/224/</link>
				<pubDate>Tue, 09 Aug 2005 15:31:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/224/</guid>
				<description>&lt;p&gt;I&#39;m really surprised at how hard it is to find a good DateTimePicker control that meets all our requirements:&lt;/p&gt; &lt;p&gt;1) Must suppost null dates, like the &lt;a href=&#34;http://corky.net/~merlin/DatePicker.PNG&#34;&gt;Due Date datepicker&lt;/a&gt; in Outlook tasks.&lt;br /&gt;2) Must be an ActiveX, and supported inside both .NET winforms and Outlook forms.&lt;br /&gt;3) Be generally bug-free and supported.&lt;br /&gt;&lt;br /&gt;Doesn&#39;t look that hard, does it? But still I&#39;ve wasted my time on many options, among them:&lt;/p&gt; &lt;p&gt;1) &lt;a href=&#34;http://www.janusys.com&#34;&gt;Janus &lt;/a&gt;Windows Forms Controls for Microsoft .NET. They have an excellent WinForms package with Outlook-style, controls, but their ActiveX package is old and contains only a grid. Also, their prices are a bit high for this project.&lt;br /&gt;2) &lt;a href=&#34;http://www.devexpress.com/Products/ActiveX/XEditors/index.xml&#34;&gt;DevExpress&lt;/a&gt; have a .NET and an ActiveX version of their DatePicker, which is also more than adequate. Again, prices are a problem - buying the suite is expensive, and getting only the XPressEditors component is even worse - over $1200 when all we need is a datepicker? &lt;br /&gt;&lt;font color=&#34;#ff0000&#34;&gt;Addendum&lt;/font&gt;: The control does NOT work properly on Outlook forms - the dropdown doesn&#39;t.&lt;br /&gt;3) &lt;a href=&#34;http://www.codejock.com/products/calendar/activex/&#34;&gt;CodeJock&lt;/a&gt; have a nice ActiveX Calendar Suite with a datepicker that has good features, but for some reason is implemented as a MonthCalendar display only - no pop-up calendar.&lt;br /&gt;4) &lt;a href=&#34;http://www.ncotech.com/neocalendar.asp&#34;&gt;NeoComponents&lt;/a&gt; have an ActiveX Calendar suite, with a datepicker that crashes and burns when added to an Outlook form. &lt;br /&gt;5) &lt;a href=&#34;http://www.xe-soft.com/xedate.asp&#34;&gt;XE Software&lt;/a&gt; have a nice little date control too, which unfortunately doesn&#39;t allow None as a valid date choice.&lt;br /&gt;6) &lt;font color=&#34;#ff0000&#34;&gt;*New*&lt;/font&gt;  &lt;a href=&#34;http://www.teamscope.com/otherpro/extensio.asp&#34;&gt;TeamScope &lt;/a&gt;have an Outlook Developers Library, including lots of libraries for working with Outlook solutions, and a good ActiveX DatePicker too. The problem? The font for the month name is fixed and unchangeable, and isn&#39;t set to a Hebrew codepage. How &lt;a href=&#34;http://corky.net/~merlin/TeamScopeDatePickerHebrewBad.PNG&#34;&gt;silly&lt;/a&gt; is that? &lt;/p&gt;</description>
			</item>
			<item>
				<title>Debugging HTML that is rendered at runtime.</title>
				<link>https://bits.strawjackal.org/225/</link>
				<pubDate>Tue, 02 Aug 2005 14:09:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/225/</guid>
				<description>&lt;p&gt;A little tip when we&#39;re generating HTML content on-the-fly using client-side code, whether HTC behaviours or javascript:&lt;/p&gt; &lt;p&gt;As we all know, when we try to View Source on such a page, the HTML we see is the base HTML that was received from the server, not the final layout after all the client-side code has run and changed things. This often makes it hard to debug, since we can&#39;t see the final layout that the user sees. This technique will help us get the final, rendered page for debugging.&lt;/p&gt;</description>
			</item>
			<item>
				<title>VB.NET and Enums</title>
				<link>https://bits.strawjackal.org/226/</link>
				<pubDate>Fri, 22 Jul 2005 17:20:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/226/</guid>
				<description>&lt;p&gt;I&#39;ve run into several problems with the way the VB.NET compiler handles enums. &lt;/p&gt; &lt;p&gt;I&#39;ve described one &lt;A href=&#34;http://weblogs.asp.net/avnerk/archive/2004/08/24/219102.aspx&#34;&gt;here&lt;/a&gt;, a while &lt;A href=&#34;http://weblogs.asp.net/avnerk/archive/2004/08/19/217174.aspx&#34;&gt;ago&lt;/a&gt;. In a nutshell, an enum exposed by SPS was based on the non-CLSCompliant UInt32 datatype, and VB.NET was choking on it during compilation.&lt;/p&gt; &lt;p&gt;The second one I ran into recently was when using the Enterprise Library to access an Oracle database. I was trying to create a paramater for an OracleCommandWrapper object. The AddParameter method has the following overloads:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Top 5 Web Service Mistakes</title>
				<link>https://bits.strawjackal.org/227/</link>
				<pubDate>Wed, 01 Jun 2005 08:39:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/227/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;http://www.theserverside.net/articles/showarticle.tss?id=Top5WSMistakes&amp;News05_31_05-click&#34;&gt;Paul Ballard on common Web Service mistakes.&lt;/a&gt;&lt;/p&gt; &lt;p&gt;I try to avoid posting link-only entries since I try to not feel totally useless in my own blog, but this is a really good article that has good points for consideration when building a Web Services architecture for your project. Building web-services in .NET is so damn easy that it&#39;s tempting to simply put in a [WebMethod] and forget all about it - it works, it&#39;s accessible and it gets the job done. The article gives a few easy optimization tips and caveats. Good read.&lt;/p&gt;</description>
			</item>
			<item>
				<title>CAML still has its humps.</title>
				<link>https://bits.strawjackal.org/228/</link>
				<pubDate>Tue, 31 May 2005 08:23:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/228/</guid>
				<description>&lt;p&gt;The last few days I found myself wrestling quite a bit with CAML. The basic idea was to replace the standard &#34;Create New Document&#34; button in a document library with some logic - if no document template is specified for the doclib, replace the button with three different buttons - Create Word Document, Create Excel Spreadsheet and Create Powerpoint Presentation.&lt;/p&gt; &lt;p&gt;This involved several operations to the SCHEMA.XML - wrapping the proper buttons in an &lt;IfEqual&gt; tag to check if the TemplateUrl property has been set, rendering the proper buttons, and adding a new createNewDocument javascript function to instantiate the Sharepoint.OpenDocuments class and open the new document in its proper editor.&lt;/p&gt;</description>
			</item>
			<item>
				<title>NT Networks, Delegation, Kerberos and Impersonation.</title>
				<link>https://bits.strawjackal.org/229/</link>
				<pubDate>Wed, 04 May 2005 18:42:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/229/</guid>
				<description>&lt;p&gt;The issue of delegation of permissions over a network is one of the most confusing issues people run into, it seems. I don&#39;t think I&#39;ve been to a project that involves web pages or services in some form that didn&#39;t run into it - people simply expect permissions to flow naturally between different network nodes. It&#39;s logical. It&#39;s intuitive. However, it doesn&#39;t work.&lt;/p&gt; &lt;p&gt;I&#39;ve blogged about this and the Double-Hop problem before, but for neatness&#39; sake and because I found myself explaining it three times &lt;strong&gt;today&lt;/strong&gt;, I&#39;ll reiterate here, linking to various resources so I have somewhere to point people when they ask.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Automatic population of web-parts in a New Web Part Page.</title>
				<link>https://bits.strawjackal.org/230/</link>
				<pubDate>Mon, 02 May 2005 09:05:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/230/</guid>
				<description>&lt;p&gt;When a new sharepoint is created, the default page is automatically populated with several default web-parts as described in the ONET.XML and the &lt;Modules&gt; section. This is (relatively) well documented and clear.&lt;/p&gt; &lt;p&gt;However, if I create a new Web Part Page in an existing site (from the Create -&gt; Web Part Page menu) based on one of the 9 templates in the DOCTEMPSMARTPGS directory, it is also populated with a web-part - the TitleBarWebPart, specifically. I don&#39;t want this web-part added to my new pages, and I want others to be auto-added. However, I am yet to find where this population is defined - couldn&#39;t find it in any XML file under the site definition, and the actual code that creates the webpage is in owssvr.dll, hence not managed code and not browsable with the &lt;a href=&#34;http://www.aisto.com/roeder/dotnet/&#34;&gt;Reflector&lt;/a&gt;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>The Good, the Bad and the DataViewWebPart</title>
				<link>https://bits.strawjackal.org/231/</link>
				<pubDate>Sun, 01 May 2005 08:46:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/231/</guid>
				<description>&lt;p&gt;Been wrestling lately with Sharepoint&#39;s DataViewWebPart (DVWP, from now on). I&#39;m still pretty ambivalent about it.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Easy to set up  - just add a list as a web-part, open it in Frontpage, right-click and Convert to XSLT.&lt;/li&gt; &lt;li&gt;Very customizable. I like XSLT. I can tweak it any way I want, generating custom rendering for my fields that would otherwise require me to write a custom web-part or a custom FieldType, which is too much hassle.&lt;/li&gt; &lt;li&gt;Presentation only. All the data-access logic is taken care of behind the scenes, and I have all the properties of my list items as XSLT parameters to play with as I choose.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Conditional Publication</title>
				<link>https://bits.strawjackal.org/232/</link>
				<pubDate>Sat, 02 Apr 2005 16:16:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/232/</guid>
				<description>&lt;p&gt;This is a nice trick I ran into when going over the sourcecode for the &lt;a href=&#34;http://www.xml-rpc.net/&#34;&gt;XML-RPC.NET&lt;/a&gt; library:&lt;/p&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt; &lt;p&gt;&lt;font face=&#34;Courier New&#34;&gt;#if&lt;/font&gt;&lt;/font&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt; (DEBUG)&lt;br /&gt;&lt;/font&gt;&lt;font face=&#34;Courier New&#34;&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;public&lt;br /&gt;#endif&lt;br /&gt;&lt;/font&gt;&lt;font color=&#34;#0000ff&#34; size=&#34;2&#34;&gt;void&lt;/font&gt;&lt;font size=&#34;2&#34;&gt; Serialize(...)&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&#34;Courier New&#34;&gt;&lt;font size=&#34;2&#34;&gt;&lt;font&gt;&lt;font face=&#34;Times New Roman&#34; size=&#34;3&#34;&gt;This lets you run your unit tests when developing, but remember to set your methods to private when releasing.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=&#34;#008000&#34; size=&#34;2&#34;&gt;&lt;/p&gt;&lt;/font&gt;</description>
			</item>
			<item>
				<title>A man&#39;s home (network) is his Castle</title>
				<link>https://bits.strawjackal.org/233/</link>
				<pubDate>Thu, 13 Jan 2005 23:13:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/233/</guid>
				<description>&lt;p&gt;The Longhorn Identity System (codename &#34;Castle&#34;) is a long-awaited feature.&lt;br /&gt;It replaces the ancient Workgroup model in home Windows installation with something that&#39;s more lightweight than a full-blown Active Directory. Been hoping for something like that. (And by &#34;hoping&#34;, I mean &#34;idly wondering about it at some point in the past&#34;).&lt;br /&gt;Too bad it&#39;s a Longhorn feature. It&#39;s also apparently based on WinFS, which has been pushed back to, what is it now, 2050?&lt;/p&gt;</description>
			</item>
			<item>
				<title>IBF Debugging</title>
				<link>https://bits.strawjackal.org/234/</link>
				<pubDate>Tue, 28 Dec 2004 00:42:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/234/</guid>
				<description>&lt;p&gt;The hour is late, so I will be brief.&lt;/p&gt; &lt;p&gt;If you want to debug an Office 2003 IBF solution, you must have C++ installed as part of your VS.NET 2003 installation.&lt;/p&gt; &lt;p&gt;If you click on &#34;Build Solution and Execute Action&#34; and see the build succeed but nothing else, chances are this is your problem.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Creating or customizing Field Types</title>
				<link>https://bits.strawjackal.org/235/</link>
				<pubDate>Fri, 10 Dec 2004 10:49:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/235/</guid>
				<description>&lt;p class=&#34;MsoNormal&#34; dir=&#34;ltr&#34; style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto&#34;&gt;Customizing SPS is sometimes a hassle. I&#39;m not talking about customizing graphics or Frontpaging the pages into submission - I&#39;m talking about extending the object model. Creating new templates for sites and lists, and so on. It&#39;s a hassle, which is why I&#39;m always happy when things work out the way I expect them to. :)&lt;/p&gt; &lt;p class=&#34;MsoNormal&#34; dir=&#34;ltr&#34; style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto&#34;&gt;On today&#39;s menu - adding a new Custom Field Type to the Sharepoint list repertoire.&lt;br /&gt;This came out a bit longer than I expected, but I&#39;m sure you&#39;ll pull through.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Quick Tip: Erasing many Portal Areas.</title>
				<link>https://bits.strawjackal.org/236/</link>
				<pubDate>Wed, 08 Dec 2004 20:32:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/236/</guid>
				<description>&lt;p&gt;Erasing a Portal Area via the interface is a bit annoying - you go to the Manage Portal Site to get the Area Tree, right-click and Delete, then you have to confirm again, wait 10-15 seconds, then press another button to get back to the tree. If you&#39;re erasing a whole bunch of areas (on a development server, for instance, when you want to start a new batch of tests), it can take quite a bit of time and patience.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Creating or customizing Field Types</title>
				<link>https://bits.strawjackal.org/237/</link>
				<pubDate>Tue, 07 Dec 2004 18:02:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/237/</guid>
				<description>&lt;p class=&#34;MsoNormal&#34; dir=&#34;ltr&#34; style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto&#34;&gt;Customizing SPS is sometimes a hassle. I&#39;m not talking about customizing graphics or Frontpaging the pages into submission - I&#39;m talking about extending the object model. Creating new templates for sites and lists, and so on. It&#39;s a hassle, which is why I&#39;m always happy when things work out the way I expect them to. :)&lt;/p&gt; &lt;p class=&#34;MsoNormal&#34; dir=&#34;ltr&#34; style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto&#34;&gt;On today&#39;s menu - adding a new Custom Field Type to the Sharepoint list repertoire.&lt;br /&gt;This came out a bit longer than I expected, but I&#39;m sure you&#39;ll pull through.&lt;/p&gt;</description>
			</item>
			<item>
				<title>SPS and Renaming AD Accounts</title>
				<link>https://bits.strawjackal.org/238/</link>
				<pubDate>Mon, 06 Dec 2004 21:50:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/238/</guid>
				<description>&lt;div&gt;&lt;font face=&#34;Arial&#34; color=&#34;#000000&#34; size=&#34;2&#34;&gt;We&#39;ve been seeing some strange behaviour after we rename a group or user in the Active Directory:&lt;/font&gt;&lt;/div&gt; &lt;div&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;&lt;/font&gt; &lt;/div&gt; &lt;div&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;When we go to the Site Settings to define site-wide permissions, the old username is still displayed. If we remove it and then add it again, we see the new name in the Choose Group list - but after we add it, it&#39;s shown as the old group. Humorous, but harmless.&lt;/font&gt;&lt;/div&gt; &lt;div&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;The bigger problem is when you give such a group permissions on a specific area or list. If we try to remove the old name from the permissions list, we get an ID Not Found error . When we try to add the new group to the permissions list, we get a Group Not Found error.&lt;/font&gt;&lt;/div&gt; &lt;div&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;&lt;/font&gt; &lt;/div&gt; &lt;div&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;All this is caused by SPS storing user data in the UserInfo table in the DB - it caches the old usernames, and for some reason uses that as the key when trying to add/remove groups to Areas, rather than the SID (which is also saved for every entry).&lt;/font&gt;&lt;/div&gt; &lt;div&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;&lt;/font&gt; &lt;/div&gt; &lt;div&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;The solution we found for this was to manually change the UserInfo entry, or better yet - erase it and let SPS recreate it when we add the group again. Naturally, it&#39;s not something we want to be doing in a production DB. Another minus is that the ACLs for various areas and lists point to the UserInfo row, not directly to the AD. This is a good thing generally, but means that once we erase the old entry, it&#39;s erased from all ACLs - we have to go and give that group/user permissions again. If this is a working server, we probably don&#39;t want to do that, and we&#39;ll just change the tp_Login field - leaving room for typos and human error. &lt;/font&gt;&lt;/div&gt; &lt;div&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;&lt;/font&gt; &lt;/div&gt; &lt;div&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;Anyone know why SPS doesn&#39;t re-cache the Username from the AD when it changes? It DOES keep the SID for each entry, so it does have the AD entity&#39;s unique key - it should use this, and keep the Login name purely as a cache.&lt;/font&gt;&lt;/div&gt; &lt;div&gt; &lt;/div&gt;</description>
			</item>
			<item>
				<title>Web Part Versioning</title>
				<link>https://bits.strawjackal.org/239/</link>
				<pubDate>Sat, 04 Dec 2004 09:35:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/239/</guid>
				<description>&lt;p&gt;If you have a web-part on your development machine that occasionaly decides to die - give you Not Marked As Safe errors even though it is, and requires removal and readding for it to work (with no other steps necessary), you may have a version mismatch.&lt;/p&gt; &lt;p&gt;Even if you register your web-part in the SafeControl section without any version information and without strong-naming it, somewhere along the way the version number DOES matter. &lt;br /&gt;Projects created from the Web Part Library template have the version number in the AssemblyInfo.cs file automatically set to a static 1.0.0.0, but if you have an assembly that was made using the Class Library template, it will be auto-set to 1.0.*, causing builds to generate different, psuedo-random build numbers, causing your Web Part to break.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Some thoughts on SPS Content Indexing [3/3]</title>
				<link>https://bits.strawjackal.org/240/</link>
				<pubDate>Mon, 29 Nov 2004 19:55:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/240/</guid>
				<description>&lt;p&gt;...and just one more.&lt;/p&gt; &lt;p&gt;Various indexing problems I&#39;ve encountered.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&#34;Cannot create the file because it already exists - 0x800700B7&#34;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;This error was reported in the gatherer log for my Portal_Content index. It occured several times - once for each Portal Area I had that was derived from a certain Site Definition I had customized. No content in these areas was indexed. This had me stumped for a while, since I couldn&#39;t understand what file the message referred to.&lt;br /&gt;The problem, it turned out, was in the Site Definition&#39;s XML files.&lt;br /&gt;The sitedef contained a custom list definition, which contained its own SCHEMA.XML file with the list&#39;s configuration. When customizing this file, I accidently left the &#34;DefaultView=TRUE&#34; attribute set for two different Views of the list. This apparently caused SPS to choke when trying to index sites based on the definition and leave them unindexed.&lt;br /&gt;A good way to tell if this has happened (and which should have alerted me sooner) was that when viewing the list of Lists in an area, instances of that custom list were shown twice - with links leading to both default views.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Some thoughts on SPS Content Indexing [2/3]</title>
				<link>https://bits.strawjackal.org/241/</link>
				<pubDate>Mon, 29 Nov 2004 19:41:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/241/</guid>
				<description>&lt;p&gt;..and we&#39;re back.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Enabling multiple Site Directories&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;By default, a Sharepoint installation comes with a Site Directory where WSS sites are listed and found. Each Site Directory holds a custom list called Sites which contains metadata about the site - Owner, Division and Region are among the default properties. We will often wish to add custom fields to the site metadata (which is easy, same as any WSS list), but sometimes we will wish to have differents sets of metadata - internal company sites might have a Department or TargetAudience property, while external sites have a Rating property. Maybe we just want to have logical, visual seperation of the two types of site. Whatever.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Some thoughts on SPS Content Indexing [1/3]</title>
				<link>https://bits.strawjackal.org/242/</link>
				<pubDate>Mon, 29 Nov 2004 19:29:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/242/</guid>
				<description>&lt;p align=&#34;left&#34;&gt;&lt;em&gt;[Warning: I only have Hebrew SPS installations around, so if I make some mistakes when translating the menu options, try to guess what I meant :]&lt;/em&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt; &lt;div align=&#34;left&#34;&gt;Advanced Search Mode&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p align=&#34;left&#34;&gt;Most of the features mentioned require Sharepoint to be in Advanced Search mode - this is enabled in the Site Settings -&gt; Search Settings page.&lt;br /&gt;SPS will ominously warn about the change being irreversible, but it is harmless - simply adds some more complexity to the Search administration screens.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Crash and Burn</title>
				<link>https://bits.strawjackal.org/243/</link>
				<pubDate>Fri, 26 Nov 2004 09:50:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/243/</guid>
				<description>&lt;div&gt;&lt;font color=&#34;#000000&#34;&gt;An annoying bug that had one developer here tearing his hair out (our would have, had he any) - an ASCX user-control that has been working fine for a few weeks started to cause strange Visual Studio crashes or hangs.&lt;/font&gt;&lt;/div&gt; &lt;div&gt;The project compiles - and runs - fine, but if he opens the code in Visual Studio in Design mode (or in Code mode and then switches to Design), the Studio would crash when switching to Code view, or hang when saving.&lt;/div&gt; &lt;div&gt;&lt;font face=&#34;Arial&#34; size=&#34;2&#34;&gt;&lt;/font&gt; &lt;/div&gt; &lt;div&gt;We tried this on different machines, I tried erasing the code-behind file - no go&lt;/div&gt; &lt;div&gt;When I started going over the ASCX manually, in Notepad (it&#39;s a huge ASCX, with lots of different tables that get alternately shown or hidden) I finally spotted the problem - inside a small TD tag somewhere in the middle the text got corrupted - the Style tag had about 8000 spaces inserted between the opening quote mark and the first css attribute - a bit hard to see when you&#39;re working without word-wrap and you can&#39;t see the end of the line.&lt;/div&gt; &lt;div&gt;Erased it in Notepad and reopened it in VS - works like a charm.&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;I don&#39;t know who to blame for the text corruption - my guess would be Clearcase.&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;[Update: It seems there&#39;s a known bug that causes Visual Studio to corrupt files located in ClearCase views]&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt; &lt;/div&gt;</description>
			</item>
			<item>
				<title>Object Model Security</title>
				<link>https://bits.strawjackal.org/244/</link>
				<pubDate>Sat, 23 Oct 2004 23:09:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/244/</guid>
				<description>&lt;p&gt;In a comment to my post &lt;A href=&#34;http://weblogs.asp.net/avnerk/archive/2004/09/22/232940.aspx&#34;&gt;here&lt;/a&gt;, Jim asked why he can&#39;t access the WSS object model in his code, even though it&#39;s running under the Sharepoint context. Since a month has passed and I can&#39;t re-enable comments on that post, I&#39;ll just answer here:&lt;/p&gt; &lt;p&gt;By default, the security settings for a Sharepoint site is set to WS_Minimal - a predefined set of security policies that can be found in C:Program FilesCommon FilesMicrosoft Sharedweb server extensions60CONFIGwss_minimaltrust.config. You can change this to WSS_Medium to get a slightly higher security policy (that allows Object Model access, for one thing) or create your own set of security policies for exact customization. Check out the web.config settings in the SPS root directory to see how to define another ruleset, and use the existing .config files as a base.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Double Hop and ASP.NET - a workaround.</title>
				<link>https://bits.strawjackal.org/245/</link>
				<pubDate>Wed, 22 Sep 2004 18:18:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/245/</guid>
				<description>&lt;p&gt;&lt;strong&gt;&lt;Background&gt;&lt;br /&gt;&lt;/strong&gt;Many people have stumbled across the &lt;a href=&#34;http://msdn.microsoft.com/library/default.asp?url=./library/en-us/sds/sds/troubleshooting_authentication_problems_on_asp_pages.asp&#34;&gt;IIS Double-Hop issue&lt;/a&gt; when trying to access Active Directory information on an ASP.NET page.&lt;br /&gt;In short - when we access an ASP.NET page, IIS can impersonate our user credentials for code execution (if set in the web.config). On Windows networks, impersonated credentials can&#39;t be used to access network resources - this prevents a web-server from maliciously or accidently using the credentials of a user who innocently logged on to it to access protected network resources. &lt;br /&gt;The problem is that when we try to access the Active Directory for legitimate purposes (to display the current user&#39;s details, for instance) while impersonating the user (as SPS does by default) we can&#39;t pass the credentials on and our AD query uses the understandbly-limited Anonymous Logon account.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Binding to Sharepoint List Items (Part 2 of 2)</title>
				<link>https://bits.strawjackal.org/246/</link>
				<pubDate>Wed, 22 Sep 2004 18:00:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/246/</guid>
				<description>&lt;p&gt;In the&lt;A href=&#34;http://weblogs.asp.net/avnerk/archive/2004/09/22/232940.aspx&#34;&gt; first part &lt;/a&gt;of the post we went over binding an SPListItemCollection to a DataGrid for quick&#39;n&#39;dirty binding of Sharepoint list data. The problem with this approach is that extensibility is a problem. To paraphrase the specific request I got: &#34;Remember that webpart where you put the List items in a grid? Now I want you to have the grid show the items from two other sites too&#34;.&lt;/p&gt; &lt;p&gt;In our first approach, we would be somewhat screwed - the SPListItemCollection represents items in a single list, and I can&#39;t merge several of those to one object. I would have to start writing code to take the data out of my SPListItems and putting them into DataRows and do a lot of dirty work - but luckily Sharepoint does that dirty work for us already:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Binding to Sharepoint List Items (Part 1 of 2)</title>
				<link>https://bits.strawjackal.org/247/</link>
				<pubDate>Wed, 22 Sep 2004 17:42:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/247/</guid>
				<description>&lt;p&gt;Databinding is cool. It lets us connect our front-end GUI elements (say, a DataGrid) to our back-end data elements (a DataSet, for instance) without the drudgery of synchronizing the two all the time. True, ASP.NET Datagrids are one-directional, but it&#39;s still cool.&lt;/p&gt; &lt;p&gt;The nice thing about databinding is that it can be done with custom objects, not only DataSets and such. Specifically, a DataSet&#39;s DataSource can be any object that implements ICollection. Let&#39;s see two ways to use this to bind a datagrid to a group of SPListItems:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Question: Singleton Inheritance</title>
				<link>https://bits.strawjackal.org/248/</link>
				<pubDate>Tue, 14 Sep 2004 16:03:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/248/</guid>
				<description>&lt;p&gt;I have this class, that implements the singleton pattern, and a subclass.&lt;/p&gt;&lt;font size=&#34;3&#34;&gt; &lt;p&gt;&lt;/font&gt;&lt;font face=&#34;Courier New&#34;&gt;&lt;font size=&#34;2&#34;&gt;&lt;font color=&#34;#0000ff&#34;&gt;public&lt;/font&gt; &lt;font color=&#34;#0000ff&#34;&gt;class&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&#34;Courier New&#34;&gt;&lt;font size=&#34;2&#34;&gt; Base&lt;br /&gt;{&lt;br /&gt;&lt;font color=&#34;#0000ff&#34;&gt;    public&lt;/font&gt; &lt;font color=&#34;#0000ff&#34;&gt;static&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&#34;Courier New&#34;&gt;&lt;font size=&#34;2&#34;&gt; Base Instance;&lt;br /&gt;    &lt;font color=&#34;#0000ff&#34;&gt;static&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&#34;2&#34;&gt;&lt;font face=&#34;Courier New&#34;&gt; Base()&lt;br /&gt;    {&lt;br /&gt;      System.Type myType = MethodInfo.GetCurrentMethod().DeclaringType;&lt;br /&gt;      Instance = (Base)Activator.CreateInstance(myType);&lt;br /&gt;    &lt;/font&gt;&lt;font face=&#34;Courier New&#34;&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&#34;Courier New&#34;&gt;&lt;font size=&#34;2&#34;&gt;&lt;font color=&#34;#0000ff&#34;&gt;    public&lt;/font&gt; &lt;font color=&#34;#0000ff&#34;&gt;void&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&#34;Courier New&#34;&gt;&lt;font size=&#34;2&#34;&gt; ID()&lt;br /&gt;    {&lt;br /&gt;      MessageBox.Show(&#34;I am &#34; + &lt;font color=&#34;#0000ff&#34;&gt;this&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;.GetType().Name);&lt;br /&gt;    }&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;}&lt;/font&gt;&lt;/p&gt;&lt;font size=&#34;3&#34;&gt; &lt;p&gt;&lt;/font&gt;&lt;font size=&#34;2&#34;&gt;&lt;font face=&#34;Courier New&#34;&gt;&lt;font color=&#34;#0000ff&#34;&gt;public&lt;/font&gt; &lt;font color=&#34;#0000ff&#34;&gt;class&lt;/font&gt;&lt;/font&gt;&lt;font face=&#34;Courier New&#34;&gt; Sub : Base&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;{&lt;br /&gt;&lt;/font&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&#34;Courier New&#34; size=&#34;2&#34;&gt;When I call Base.Instance.ID(), I get &#34;I am Base&#34;, which is what I want.&lt;br /&gt;When I call Sub.Instance.ID(), I also get &#34;I am Base&#34;. This makes sense,&lt;br /&gt;since MethodInfo.GetCurrentMethod().DeclaringType SHOULD return Base, since that&#39;s where it&#39;s declared.&lt;/font&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>How to get the current SPS Area in a Web-Part</title>
				<link>https://bits.strawjackal.org/249/</link>
				<pubDate>Mon, 13 Sep 2004 21:49:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/249/</guid>
				<description>&lt;p&gt;When we write a WebPart or WebControl that resides in a SPS Area, we will want to know at runtime which area we reside in.&lt;br /&gt;This, surprisingly enough, is not trivial. It&#39;s not even easy. In fact, it&#39;s downright obscure&lt;/p&gt; &lt;p&gt;You can easily get the current SPWeb you&#39;re in using the SPControl object, but while the Area class can expose the underlying SPWeb, an SPWeb can&#39;t give you the equivalent Area - which makes sense, since SPS&#39;s Areas are built on top of WSS&#39;s SPWebs.&lt;/p&gt;</description>
			</item>
			<item>
				<title>VB Build Events</title>
				<link>https://bits.strawjackal.org/250/</link>
				<pubDate>Fri, 03 Sep 2004 14:21:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/250/</guid>
				<description>&lt;p&gt;Having found myself developing in VB.NET alongside C# recently, I was rather annoyed at the lack of pre- and post-build-events for VB projects in VS.NET2003.&lt;/p&gt; &lt;p&gt;A quick check of the DTE automation model showed that while the .VBPROJ file schema does not enable persistently storing build event information for VB projects, the EnvDTE.Project object DOES enable you to specify that property, whether it&#39;s a C# or VB project - they just won&#39;t be persisted to the VBProj file.&lt;/p&gt;</description>
			</item>
			<item>
				<title>PortalRight - all wrong.</title>
				<link>https://bits.strawjackal.org/251/</link>
				<pubDate>Mon, 23 Aug 2004 21:01:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/251/</guid>
				<description>&lt;p&gt;A followup to &lt;A href=&#34;http://weblogs.asp.net/avnerk/archive/2004/08/19/217174.aspx&#34;&gt;this post&lt;/a&gt;:&lt;/p&gt; &lt;p&gt;The PortalRight enumeration defined in Microsoft.Sharepoint.Portal.Security is, for some reason, derived from UInt32 rather than Int32. You can see this in the Object Browser when in a VB.NET project. &lt;br /&gt;This anomaly - nothing more than a raised eyebrow in a C# project - seems to be crippling in a VB.NET project.&lt;br /&gt;Whenever I try to use this enum in code, the compiler claims that it can&#39;t cast from Integer to PortalRight - even I always use the enum:&lt;/p&gt;</description>
			</item>
			<item>
				<title>SPS Area Templates</title>
				<link>https://bits.strawjackal.org/252/</link>
				<pubDate>Thu, 19 Aug 2004 16:56:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/252/</guid>
				<description>&lt;p&gt;And, to close of the day&#39;s rants - an instructive post.&lt;/p&gt; &lt;p&gt;Today: How to create a template of a Sharepoint Area that can be moved or taken to different servers.&lt;/p&gt; &lt;p&gt;Unfortunately, SPS Areas can&#39;t be bundled into STP templates like WSS sites or lists, and there&#39;s no built-in method of exporting an area into a convenient format so out Frontpage customizations and painstakingly defined layout can be copied to a different site.&lt;/p&gt;</description>
			</item>
			<item>
				<title>LoadControl and HTML Comments</title>
				<link>https://bits.strawjackal.org/253/</link>
				<pubDate>Thu, 19 Aug 2004 16:45:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/253/</guid>
				<description>&lt;p&gt;Developin webparts with many UI elements can be a hassle - which is why I&#39;m fond of the UserControl shortcut - I build my web UI as a WebUserControl, then simply have my webpart call Page.LoadControl to dynamically load that usercontrol.&lt;/p&gt; &lt;p&gt;A problem I&#39;ve encountered with it today is that LoadControl, strangly enough, ignores HTML comment in the ASCX file.&lt;/p&gt; &lt;p&gt;Let&#39;s say I have the following code in the ASCX:&lt;/p&gt;</description>
			</item>
			<item>
				<title>To CLS or not to CLS.</title>
				<link>https://bits.strawjackal.org/254/</link>
				<pubDate>Thu, 19 Aug 2004 16:40:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/254/</guid>
				<description>&lt;p&gt;For some reason, Sharepoint&#39;s object &lt;font face=&#34;&#34;&gt;model doesnt adher to Microsoft&#39;s recommended practices - namely, trying to keep your external interfaces CLS-compliant. &lt;/font&gt;&lt;/p&gt; &lt;p&gt;It seems the object model itself exposes several methods and properties that use the UInt32 data-type, even if the &lt;a href=&#34;http://msdn.microsoft.com/library/en-us/spptsdk/html/pAreaCollectionCount.asp&#34;&gt;SDK &lt;/a&gt;claims otherwise.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Be Vewy Vewy Caweful - We&#39;we Instawwing Shawepoint!</title>
				<link>https://bits.strawjackal.org/255/</link>
				<pubDate>Sun, 15 Aug 2004 22:28:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/255/</guid>
				<description>&lt;p&gt;Sharepoint 2003&#39;s installation process is one of the most delicate and uncooperative I&#39;ve seen in while. Quite a surprise in this day and age - responsive, coherent installations is something we&#39;ve grown to expect from Microsoft&#39;s server systems in recent versions - or maybe it&#39;s just me. :)&lt;/p&gt; &lt;p&gt;Sharepoint&#39;s installation can be baffled by any number of reasons - lack of harddisk space on drive C:, remains of previous installations, even something as simple as a wrong password entered for the applicative user to run the services. All of these errors share one thing between them - the installer won&#39;t pop up a messagebox to let you know what happened. It won&#39;t even give you an error warning and let you try again (to a different path perhaps, or to retype the username). It will simply continue on UNINSTALLING SPS (and WSS, if it was part of the process) and direct you to a folder full of log files out of which you&#39;re suppose to dig the actual reason for the failure and presumably try again - yes, a 10-minute process just to find out I forgot to put the domain name before the username for the service account.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Lookup Hijinx</title>
				<link>https://bits.strawjackal.org/256/</link>
				<pubDate>Tue, 27 Jul 2004 18:59:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/256/</guid>
				<description>&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;Here&#39;s something that mired me down for several hours, so may it be Googled and seen and used by Sharepoint developers:&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;&lt;?xml:namespace prefix = o ns = &#34;urn:schemas-microsoft-com:office:office&#34; /&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;We&#39;re developing a solution right now based on SPS and WSS sites, under several different Site Collections, that involves copying files between sites.&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;The copying itself is done the same as the MSDN samples show - adding the byte stream to the FileCollection of the destination library - but since we&#39;re just passing the bits, the file&#39;s metadata isn&#39;t automatically copied from one List to the other.&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;If we&#39;re copying Office documents, we have automatic demotion and promotion of metadata properties from the Sharepoint List into the document, which then goes back into the new list. But if we&#39;re copying non-Office documents, the metadata is simply lost.&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;This was bypassed with a simple function after copying that also synchronizes the metadata - but that&#39;s where I ran into a strange anomaly having to do with SPFieldLookups - fields that derive their list of possible values from a list in the site.&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;The format that is saved in the metadata for these kind of fields contains both the identifier of the item in the lookup-list, and the actual string to be displayed, in this format:&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;“1;#myValue” - with myValue being shown in the list.&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;Now I want to copy this string from one SPListItem to another - but keep getting strange SPExceptions saying that the data is in an invalid format and suggesting that it is, perhaps, read-only. Preposterous, of course.&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt; &lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;More digging and hacking showed that in order to copy the value, we only have to copy the number, not the value.&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;It DOES make sense, now that I understand it - I only want to pass the ID, after all, not the whole string value - that&#39;s why it&#39;s a lookup field. I assume that it&#39;s stored inside the list for caching, so we won&#39;t have to go to the lookup list every time, but still - an explanation, a sample or a meaningful error message would have been appreciated.&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal dir=ltr style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt; &lt;/P&gt;</description>
			</item>
			<item>
				<title>Programmatically creating an IIS Application</title>
				<link>https://bits.strawjackal.org/257/</link>
				<pubDate>Tue, 27 Jul 2004 18:47:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/257/</guid>
				<description>&lt;P class=MsoNormal style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;Using System.DirectoryServices to manage IIS servers and directories is a long-established practice (or is it? Should I elaborate on that? Write a short article?), but I ran into a problem today when I wanted to turn an ordinary directory under IIS (6.0) into an Application. It seems that among the many Metabase properties available, the only one relevant is AppRoot, and the MSDN strongly urges one not to touch it since it is managed internally.&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;The alternative is simply to access the IisWebDirectory object (part of the IIS ADSI Object model) and call the AppCreate (or AppCreate2, or AppCreate3 under IIS6) to create the application.&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;Very nice and simple, except that I&#39;m working with a DirectoryEntry object and don&#39;t have AppCreate to save my life.&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;The thing to do in this case is to access the NativeObject property of the DirectoryEntry, cast it into an IisWebDirectory, and call the method – but for some reason, I don&#39;t seem to have that class registered anywhere. The IIS Adsi object model (as added via References -&gt; COM -&gt; Active DS IIS Extension or Active DS IIS Namespace) don&#39;t seem to have IisWebDirectory or IisVirtualWebDir defined, which means I am quite stumped. Looked around for it, in the Registry and other common COM hangouts, but couldn&#39;t find any reference.&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;&lt;?xml:namespace prefix = o ns = &#34;urn:schemas-microsoft-com:office:office&#34; /&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;My final solution was to simply bypass the problem using direct means – reflection:&lt;BR&gt;&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;DirectoryEntry vdir = new DirectoryEntry (&#34;IIS://localhost/W3SVC/1/Root/MyVDir&#34;);&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;Object nativeObject = vdir.NativeObject;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;native.GetType().InvokeMember(&#34;AppCreate3&#34;, BindingFlags.InvokeMethod, null, native, new object[] {2, &#34;DefaultAppPool&#34;, false}); // 2 means to use an Application Pool.&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/P&gt;&#xD;&#xA;&lt;P class=MsoNormal style=&#34;MARGIN: 0cm 0cm 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left&#34;&gt;Is there a slightly neater solution? Does anyone know where the IisWebDirectory object is hiding?&lt;/P&gt;</description>
			</item>
			<item>
				<title>SQL Server Woes.</title>
				<link>https://bits.strawjackal.org/258/</link>
				<pubDate>Fri, 16 Jul 2004 07:45:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/258/</guid>
				<description>&lt;P&gt;I am not a SQL Server Guru, I admit. Far from it, actually. But still, this shouldn&#39;t be this hard.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;I was cheerfully punching away Sharepoint code on my Win2003 machine, when suddenly the power died. Cries of alarm, black smoke from the generator - the works. Not too much of a problem, since I am a reflexive (not to say spasmodic) CTRL-S presser, so it was just a matter of waiting for the power to come back and resume working.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Except that when it did, it seemed my SQL Server (2000, sp3a) decided to call it quits. Whenever I would start the service, it would immediately after launching die again, with an event-log message that the LSN passed to the &#39;model&#39; database was incorrect.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Some checking revealed that the LSN is the Log Sequence Number, and my guess is that the power failure happened exactly while it was processing transaction logs - but should that be fatal?&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Furthermore, if it is - shouldn&#39;t there be any way of clearing it up? Is there no command-line tool to let me declare the DB consistent?&lt;/P&gt;&#xD;&#xA;&lt;P&gt;What I was forced to do, eventually, is copy my MBF files aside, run the rebuildm.exe command to rebuild the Master database from the original CD, and then re-attach my databases - luckily unharmed and unchanged. &lt;/P&gt;</description>
			</item>
			<item>
				<title>The Joy of VSTO.</title>
				<link>https://bits.strawjackal.org/259/</link>
				<pubDate>Tue, 06 Jul 2004 22:33:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/259/</guid>
				<description>&lt;P&gt;At last, I have a glowingly positive, happily cheerful and satisfyingly pleased entry instead of my usual rant.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;I installed the Whidbey Beta 1 build yesterday, and immediately started checking out the beta of VSTOv2. After the grief I went through with the Smart Documents API, I wanted to see if the much-anticipated ActionsPane interface gives me a decent replacement.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Two hours of API-learning and online help-reading later, I had in my hands a rather neat (though not very innovative) CD catalog template, with a fully functional and interactive task-pane &lt;/P&gt;</description>
			</item>
			<item>
				<title>The API Maze</title>
				<link>https://bits.strawjackal.org/260/</link>
				<pubDate>Sat, 03 Jul 2004 10:57:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/260/</guid>
				<description>&lt;P&gt;A reminder to those lost:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;The SystemInformation class, containing many useful tidbits of information like the running computer name, number of monitors and whether we&#39;re on a network, resides in System.Windows.Forms of all places.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Sure, most of the information there is GDI and Forms related, but why do I need to include and reference this in a console application if all I want is the name of the computer? A more generic SystemInformation should be sitting directly under the System namespace. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;VB 2005 has the My namespace for easy access to such information - but this is basic enough to be CLR-wide.&lt;/P&gt;</description>
			</item>
			<item>
				<title>Disposable Impersonation</title>
				<link>https://bits.strawjackal.org/261/</link>
				<pubDate>Wed, 30 Jun 2004 19:37:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/261/</guid>
				<description>&lt;P&gt;Impersonating a user in .NET isn&#39;t quite as simple as it could be. It&#39;s really easy if you you already have a WindowsIdentity or WindowsPrincipal in hand, but to get a handle on an arbitrary user you have to resort to P/Invoking the LogonUser and DuplicateToken APIs to get an impersonation context given only a username and password. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;Easy enough to wrap in your own function, if you need to use it, but then you have to remember to Undo() the ImpersonationContext when you&#39;re done. Not that bad, but could be neater.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;So the solution I came up with today is this:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Create a new class, call it ImpersonationContext, and add our Impersonation code in the constructor - pass the username/password as parameters. The WindowsImpersonationContext object we&#39;ll save in a private variable.&lt;BR&gt;Next we&#39;ll implement IDisposable in our class and call the WindowsImpersonationContext.Undo() in the Dispose method.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;What does this give us? A rather clean and readable way to run a block of code using a different security context, with automatic reversal of the impersonation when we&#39;re done.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;using (new ImpersonationContext(&lt;EM&gt;username, password, domain&lt;/EM&gt;)&lt;BR&gt;{&lt;BR&gt;      // Run my impersonated code.&lt;BR&gt;}&lt;/P&gt;&#xD;&#xA;&lt;P&gt;(Sorry for not bringing actual code - this was written on a closed network so I don&#39;t have the sources available)&lt;/P&gt;</description>
			</item>
			<item>
				<title>COM Add-Ins : Multiple Madness!</title>
				<link>https://bits.strawjackal.org/262/</link>
				<pubDate>Thu, 17 Jun 2004 14:52:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/262/</guid>
				<description>&lt;P&gt;&lt;SPAN style=&#34;COLOR: black&#34;&gt;[Don&#39;t you hate it when IE throws your long post to the trash? We need a smart client for updates!]&lt;/SPAN&gt;&lt;?xml:namespace prefix = o ns = &#34;urn:schemas-microsoft-com:office:office&#34; /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;COM AddIns for Office are a nice feature. A rather easy way to add some buttons and functionality to your documents, and even deployment isn&#39;t too much of a hassle.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;But I ran into a problem today when I had two Word documents open at once. It seems that the button was loaded for both, but was only functional for the first instance. The second instance had something that looked like a button, got clicked like a button, but all-in-all did nothing that buttons did - that is, trigger an event. &lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Several hours of furious debugging followed. VB6 code was translated to VB&lt;?xml:namespace prefix = st1 ns = &#34;urn:schemas-microsoft-com:office:smarttags&#34; /&gt;&lt;st1:mswterms w_st=&#34;on&#34;&gt;.NET&lt;/st1:mswterms&gt; and then to C#. No go. Code was moved from the OnConnection event to OnStartupComplete - still nothing. A working sample retrieved and compared - nothing relevant seemed to pop up from the page.&lt;BR&gt;Only after going line-by-line over the sample and copying it to my code did we get an answer:&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;VB controls and similar APIs tend to have a Tag property for all their controls. A convenient, loosely-typed way to store extra data about the control without having to subclass the control or design your own interface.&lt;BR&gt;A great workaround for lazy programmers, up until the time it bites you back. It bites you when you have to go over someone’s code where he uses properties for data other that their intended use. It bites you when you have a “Title” field for a mailbox that is actually used to store an organizational Department. It bites you when your code doesn’t document itself – it does something other than what you expect it to do.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;And that’s exactly what Office does – it uses the Tag property of the CommandBarButton to keep track of control instances between multiple open documents. &lt;BR&gt;It doesn’t matter what the Tag holds – the minute you put something in it, the button works fine on as many instances of Word as you’d like. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;Why does it rely on the generic, optional, misleading Tag property for this? Couldn’t they add some internal property? Some automatic mechanism? Why do I have to set a random, pointless string to an arbitrary, pointless property to get functionality to work?&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Lazy workaround for Lazy programmers. Bah.&lt;/P&gt;</description>
			</item>
			<item>
				<title>Office 2003&#39;s disappearing-reappearing PIAs.</title>
				<link>https://bits.strawjackal.org/263/</link>
				<pubDate>Wed, 09 Jun 2004 22:35:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/263/</guid>
				<description>&lt;P&gt;Just in case someone else is running into this problem:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;If you&#39;re trying to install Office 2003 Professional and want to make sure you install the PIAs as well, you go to the setup components list and look for &lt;STRONG&gt;.NET Programmability Support&lt;/STRONG&gt; and are surprised when you just can&#39;t find it - make sure you have the .NET Framework 1.1 already installed on the computer before you install Office. It won&#39;t show up on the list, and won&#39;t get installed, if the framework isn&#39;t already there - and it&#39;d be a shame to go and reinstall Office now, wouldn&#39;t it?&lt;/P&gt;</description>
			</item>
			<item>
				<title>Ghost Files</title>
				<link>https://bits.strawjackal.org/264/</link>
				<pubDate>Wed, 09 Jun 2004 22:31:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/264/</guid>
				<description>&lt;FONT size=2&gt;&#xD;&#xA;&lt;P&gt;For some obscure reason, Windows Sharepoint Services allows me to fetch a non-existent file.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Consider this code:&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;SPSite site = new SPSite(&lt;I&gt;site_url)&lt;/I&gt;;&lt;BR&gt;SPFile file = site.RootWeb.GetFile(&lt;I&gt;file_url)&lt;/I&gt;;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&#xD;&#xA;&lt;P&gt;This code will return an SPFile object regardless of whether &lt;I&gt;file_url &lt;/I&gt;points to an existing file or not. &lt;BR&gt;To find out if the file exists, you need to call the file.Exists() method.&lt;BR&gt;Even if we ignore the fact that it&#39;s against the common practice of throwing exceptions for these situations, it still behaves oddly.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;You would expect that the properties for a non-existent file would be null, or at least throw exceptions - and indeed, most of them do throw (more on that later), but some of them DON&#39;T - properties like the Name and URL of the file return values that are derived from the original URL I passed it, even though they do not, in fact, point to an existing file. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;And the other properties DO throw, but they either throw a System.ArgumentOutOfRangeException, which makes absolutely no sense, or else a SPException specifying that the document library doesn&#39;t exist. The same property can throw a different one of the above exceptions, depending on whether the URL we gave it points to a non-existing file in an existing doc library, or to a doc library that doesn&#39;t exist at all.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;It&#39;s a mess, I tell you - a mess.&lt;/P&gt;&lt;/FONT&gt;</description>
			</item>
			<item>
				<title>Who Am I?</title>
				<link>https://bits.strawjackal.org/265/</link>
				<pubDate>Tue, 01 Jun 2004 18:22:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/265/</guid>
				<description>&lt;P&gt;As we probably know, the most popular activity involving the Active Directory for the developers amongst us is to check for authorization. We get a username from the context/environment/browser, and now we wanna check if the user is allowed to do whatever. We may use the role-based security solutions provided by COM+ or .NET or whatever solution we want, and they are nice and fine and good, but there comes a time in every programmer&#39;s life when he must lay down the line and say “That&#39;s it. I&#39;m going in there. Just me and System.DirectoryServices. If I&#39;m not out in 30 minutes, contact my administrator”.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;So first, a word of warning - &lt;STRONG&gt;System.DirectoryServices is a COM wrapper. It is NOT managed code&lt;/STRONG&gt;. Windows has a lovely library for accessing the AD and other LDAP providers, and had it for years - ADSI in its various version and incarnations. A nice API, all in all. DirectoryServices in the BCL is just a set of wrappers over ADSI, not a brand-new implementation of LDAP. This means that there is a lot of COM interop going on in the background. This shouldn&#39;t be too worrisome, since COM interop isn&#39;t a bad thing, but it is important to dispose what you instantiate and make sure you don&#39;t leave things lying around.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;There, having established that, we will quickly learn to create a DirectoryEntry for our user (either directly or using the DirectorySearcher - no need to elaborate there &lt;FONT size=2&gt;(though I can, if people ask me to)&lt;/FONT&gt;) and we can now check the properties for the “memberOf” property and see what groups he is a member of. This works well, except that we only get the groups we are DIRECT members of. If we want a complete list of nested groups, we have to start recursing and iterating, and this takes a LONG time. Especially when we have a lot of groups.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;So what we do? We use a little-known and barely-documented feature of our Windows authentication architecture.&lt;BR&gt;You see, when we try to access a network resource, for instance, the resource has to know whether we are authorized or not. It does this by receiving from the client (our user) a set of security credentials that contain the Security IDs (SIDs) of all the groups we belong to, whether directly on indirectly - we can&#39;t have Windows recurse through the AD whenever we try to access some folder, right?&lt;/P&gt;&#xD;&#xA;&lt;P&gt;So we&#39;ll use the same mechanism. Among the many properties available for a DirectoryEntry object in the ActiveDirectory is a property called “tokenGroups” which contains a list of all SIDs of all security groups the user belongs to. This list is flat, since it is used for direct authorization only, not for complex rules inherent in our organizational hierarchy. This list of SIDs can then be translated into group names for our enumerating convenience, or perhaps we should just get the SID for the group we are checking and see if it is the list.&lt;/P&gt;&#xD;&#xA;&lt;P&gt; A few points of interest:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;1) Since the tokenGroups property is relatively heavy, it is not automatically loaded when we create a new DirectoryEntry. To do so, we will call the entry&#39;s RefreshCache() method to explicitly load that property:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT size=2&gt;DirectoryEntry de = new DirectoryEntry(&lt;EM&gt;my LDAP path&lt;/EM&gt;);&lt;BR&gt;de.RefreshCache(&lt;FONT color=#0000ff&gt;new string&lt;/FONT&gt;[] {&lt;FONT color=#000000&gt;“tokenGroups“});&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT face=Arial&gt;2) Once we loaded the property, it is represented as an array of byte arrays, so we will get it like this:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT face=Arial&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;PropertyValueCollection tg = de.Properties&lt;FONT color=#000000&gt;[&#34;tokenGroups&#34;];&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;foreach&lt;/FONT&gt; (&lt;FONT color=#0000ff&gt;byte&lt;/FONT&gt;[] SID &lt;FONT color=#0000ff&gt;in&lt;/FONT&gt; (Array)tg.Value)&lt;BR&gt;{&lt;BR&gt;   // Translate the SID, or whatever.&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Arial&gt;&#xD;&#xA;&lt;P&gt;1) To get a group name from a SID (which is basically an array of bytes), we&#39;ll have to do a little Win32 interop using the LookupAccountSid function.&lt;/P&gt;&lt;/FONT&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT color=#0000ff&gt;enum&lt;/FONT&gt; SID_Types&lt;BR&gt;{&lt;BR&gt;   SidTypeUser = 1, &lt;BR&gt;   SidTypeGroup, &lt;BR&gt;   SidTypeDomain, &lt;BR&gt;   SidTypeAlias, &lt;BR&gt;   SidTypeWellKnownGroup, &lt;BR&gt;   SidTypeDeletedAccount, &lt;BR&gt;   SidTypeInvalid, &lt;BR&gt;   SidTypeUnknown, &lt;BR&gt;   SidTypeComputer&lt;BR&gt;} &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;[DllImport(&lt;FONT color=#800000&gt;&#34;advapi32.dll&#34;&lt;/FONT&gt;)]&lt;BR&gt;&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;extern&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;bool&lt;/FONT&gt; LookupAccountSid(&lt;BR&gt;       &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; lpSystemName, &lt;BR&gt;&lt;FONT color=#0000ff&gt;       byte&lt;/FONT&gt;[] lpSid, &lt;BR&gt;       StringBuilder lpName, &lt;BR&gt;&lt;FONT color=#0000ff&gt;       ref&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; cchName, &lt;BR&gt;       StringBuilder lpReferencedDomainName,&lt;BR&gt;       &lt;FONT color=#0000ff&gt;ref&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; cchReferencedDomainName, &lt;BR&gt;&lt;FONT color=#0000ff&gt;       ref&lt;/FONT&gt; SID_Types peUse&lt;BR&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#0000ff&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;private string &lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face=&#34;Courier New&#34;&gt;&lt;FONT color=#000000&gt;getNameFromSID (&lt;FONT color=#0000ff&gt;byte&lt;/FONT&gt;[] SID)&lt;BR&gt;{&lt;BR&gt;   &lt;/FONT&gt;int&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt; GroupLength = 256;&lt;BR&gt;   &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; DomainLength = 256;&lt;BR&gt;   StringBuilder Groupname = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; StringBuilder(GroupLength);&lt;BR&gt;   StringBuilder Domainname = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; StringBuilder(DomainLength);&lt;BR&gt;   SID_Types AccountType = SID_Types.SidTypeUnknown;&lt;BR&gt;   LookupAccountSid(&lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;, SID, Groupname, &lt;FONT color=#0000ff&gt;ref&lt;/FONT&gt; GroupLength, Domainname, &lt;FONT color=#0000ff&gt;ref&lt;/FONT&gt; DomainLength, &lt;FONT color=#0000ff&gt;ref&lt;/FONT&gt; AccountType);&lt;BR&gt;   &lt;FONT color=#0000ff&gt;return &lt;/FONT&gt;Domainname.ToString() + @”” + Groupname.ToString();&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;</description>
			</item>
			<item>
				<title>A Sincere and Permanent Attachment</title>
				<link>https://bits.strawjackal.org/266/</link>
				<pubDate>Mon, 31 May 2004 08:20:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/266/</guid>
				<description>&lt;P&gt;Our goal for today is automatically attaching a Smart Document to a document - hopefully from a button or a COM add-in or something.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Well, my pre-2003 Office skills are a bit rusty, so I haven&#39;t gotten around to making a COM add-in for this - and I think VSTO deployment these days is still too clunky and awkward to be convenient, but for now, this bit of VBA code will attach our manifest to the active document:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;[Note: Some of my actions here might be superfluous. I am not entirely sure as to what is necessary. If you can refine this - please do.]&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Sub AttachManifest()&lt;/P&gt;&#xD;&#xA;&lt;P&gt;    Dim Namespace As XMLNamespace&lt;BR&gt;    Set Namespace = ActiveDocument.Application.XMLNamespaces.Add(“C:ProjectsSDmy.xsd, “My Schema“, “my“, True)&lt;BR&gt;    Namespace.AttachToDocument (ActiveDocument)&lt;BR&gt;    ActiveDocument.Application.XMLNamespaces.InstallManifest &#34;C:ProjectsSDmanifest_signed.xml&#34;, True&lt;BR&gt;    &lt;BR&gt;     ActiveDocument.SmartDocument.SolutionURL = &#34;C:ProjectsSDmanifest_signed.xml&#34;&lt;BR&gt;    ActiveDocument.SmartDocument.SolutionID = &#34;My Schema&#34;&lt;BR&gt;    &lt;BR&gt;End Sub&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;BR&gt; &lt;/P&gt;</description>
			</item>
			<item>
				<title>Erase-a-RegKey.</title>
				<link>https://bits.strawjackal.org/267/</link>
				<pubDate>Wed, 19 May 2004 17:38:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/267/</guid>
				<description>&lt;P&gt;For many years now I&#39;ve been using .REG files to deploy registry changes - quick, easy and notepad-compatible. The problem is that I could easily add or modify keys with this, but couldn&#39;t erase them - there was no notation in the REG file format to erase a key or value - or at least none that I know of...&lt;/P&gt;&#xD;&#xA;&lt;P&gt;I don&#39;t know which version of Windows first started supporting it, but on Win2000 it works like a charm - when specifying the name of the key, simply add a Minus sign in the beginning, and the key will be wiped clean without a trace. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;I don&#39;t know if it&#39;s possible to erase a value inside a key, too - never tried it. But it wipes a key with all sub-keys and values easily.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Ex:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;This creates a key:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;Windows Registry Editor Version 5.00 &lt;BR&gt;[HKEY_LOCAL_MACHINESoftwareMyStuff] &lt;BR&gt;&#34;MyLittleValue&#34;=dword:00000001&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;And this erases it!&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=&#34;Courier New&#34;&gt;Windows Registry Editor Version 5.00 &lt;BR&gt;[&lt;STRONG&gt;-&lt;/STRONG&gt;HKEY_LOCAL_MACHINESoftwareMyStuff] &lt;BR&gt;&lt;FONT color=#d3d3d3&gt;&#34;MyLittleValue&#34;=dword:00000001 (This line is meaningless when erasing a key).&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
			</item>
			<item>
				<title>Reporting Services and Sharepoint</title>
				<link>https://bits.strawjackal.org/268/</link>
				<pubDate>Wed, 19 May 2004 17:34:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/268/</guid>
				<description>&lt;P&gt;In case you missed it in the setup Help file (I did) and you installed SQL Server Reporting Services on a virtual directory that&#39;s under Windows Sharepoint Services - there are some manual things to adjust for it to work:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;1) Make sure your Default Web Site is up and running. Mine was Stopped (since it&#39;s the SPS site and I wasn&#39;t using it) and I got rather vague “Your IIS isn&#39;t configured properly“ messages during setup, which proceeded to install only the development components on my computer and not the ReportServer.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;2) As the setup will conveniently tell us, we need to manually activate the services after installation. Piece of cake. Just run this (one line):&lt;BR&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;rsactivate.exe c:program filesmicrosoft sql servermssqlreporting servicesreportingserverRSReportServer.config&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;3) If you&#39;re getting very minimal “404 Not Found” errors when trying to access the /Reports or /ReportServer virtual directories, it&#39;s because Sharepoint, by default, blocks access to all paths it doesn&#39;t know.&lt;BR&gt;So just run this to tell Sharepoint to exclude these VDirs from the paths it cares about:&lt;BR&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;STSADM.EXE -o addpath -url http://localhost/ReportServer -type exclusion&lt;BR&gt;STSADM.EXE -o addpath -url &lt;/FONT&gt;&lt;A href=&#34;http://localhost/Reports&#34;&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt;http://localhost/Reports&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=&#34;Courier New&#34; size=2&gt; -type exclusion&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;4) Right, now we&#39;re not getting 404&#39;s, we&#39;re just getting a nicer interface telling us that Reporting Services requires Session State to be enabled. At this point we&#39;ll probably scratch our heads in puzzlement, since it most definitely IS enabled in the IIS Manager, both for the Reports/ReportServer vdirs and for the root. &lt;BR&gt;Again, the problem lies with the Sharepoint. The sharepoint root&#39;s &lt;FONT face=&#34;Courier New&#34; size=2&gt;web.config&lt;/FONT&gt; file contains an &lt;HttpModules&gt; tag containing, by default, a commented-out SessionState module. We&#39;ll re-enable that and also look for the &lt;pages&gt; tag a bit after than and set “enableSessionState” to “true”. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;That&#39;s it, so far. All credit to &lt;A href=&#34;http://msdn.microsoft.com/library/default.asp?url=./library/en-us/RSinstall/htm/gs_installingrs_v1_9fdy.asp&#34;&gt;http://msdn.microsoft.com/library/default.asp?url=./library/en-us/RSinstall/htm/gs_installingrs_v1_9fdy.asp&lt;/A&gt;&lt;/P&gt;</description>
			</item>
			<item>
				<title>State of the Nation</title>
				<link>https://bits.strawjackal.org/269/</link>
				<pubDate>Sun, 09 May 2004 11:49:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/269/</guid>
				<description>&lt;P&gt;Another painful point I have just noticed. Again, this was embedded in the SDK, but so deep you would hardly notice it until you looked for it specifically:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;STRONG&gt;All instances of Winword will use the same instance of your ISmartDocument object&lt;/STRONG&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;This following paragraph from the SDK (&lt;A href=&#34;http://msdn.microsoft.com/library/default.asp?url=./library/en-us/sdsdk/html/sdconDevelopingSolutionsMaintainingState.asp&#34;&gt;here&lt;/A&gt;) shows that:&lt;/P&gt;&#xD;&#xA;&lt;BLOCKQUOTE dir=ltr style=&#34;MARGIN-RIGHT: 0px&#34;&gt;&#xD;&#xA;&lt;P&gt;&lt;EM&gt;If you have multiple documents open, and more than one of those documents uses the same XML expansion pack, your global variables are tied to the &lt;B&gt;ISmartDocument&lt;/B&gt; interface, of which there is only one instance for the XML expansion pack, not for each individual instance of a smart document.&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&#xD;&#xA;&lt;P dir=ltr&gt;What it basically means is that ANY variable declared in your Smart Document object is, in effect, a static variable - that&#39;s because the ISmartDocument object is instantiated as a singleton and simply called whenever it is needed.&lt;/P&gt;&#xD;&#xA;&lt;P dir=ltr&gt;This means that you can NOT save any state information that you wouldn&#39;t want shared between instances of Word, assuming you have several documents open at the same time linked to the smart document solution.&lt;/P&gt;&#xD;&#xA;&lt;P dir=ltr&gt;The suggested solution to keep instance-specific state is to have a Hashtable with the Document as the key. A bit excessive, I think, but I guess it&#39;s as good a way as any. Just remember that you shouldn&#39;t save the Current Document as a local variable, but extract it on every method call from the Target parameter passed to the PopulateX methods - it&#39;s a Word Range object, and has the Document as a parameter.&lt;/P&gt;&#xD;&#xA;&lt;P&gt; &lt;/P&gt;</description>
			</item>
			<item>
				<title>Communication Breakdown</title>
				<link>https://bits.strawjackal.org/270/</link>
				<pubDate>Sun, 09 May 2004 08:14:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/270/</guid>
				<description>&lt;UL&gt;&#xD;&#xA;&lt;LI&gt;And today, on “Why Smart Documents Are Giving Me Ulcers”: ActiveX controls!&lt;/LI&gt;&lt;/UL&gt;&#xD;&#xA;&lt;P&gt;The concept is simple - I want to have an ActiveX control on my Smart Document that can affect the Smart Doc it it initialized from. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;Assuming we have the ActiveX linked to an XML element on the document, we can get a handle to it by iterating the SmartTagActions collection on the element, and then attaching an event handler to an event on it, or simply reading a property on it. All would be well.&lt;BR&gt;But unfortunately, as we saw a few posts ago (&lt;A href=&#34;http://weblogs.asp.net/avnerk/archive/2004/04/13/112162.aspx&#34;&gt;here&lt;/A&gt;), I can&#39;t do that if the ActiveX is linked to the entire document. No way to get a handle, and thus no way to get data back from the ActiveX. Here are some relevant points:&lt;/P&gt;&#xD;&#xA;&lt;UL&gt;&#xD;&#xA;&lt;LI&gt;You can pass data TO the ActiveX using the ActiveXPropBag object from the PopulateActiveXControl event. The problem is that we can only pass strings here. &#xD;&#xA;&lt;LI&gt;There&#39;s no simple way to pass data BACK from the ActiveX to the Smart Document. &lt;/LI&gt;&lt;/UL&gt;&#xD;&#xA;&lt;P&gt;In my solution, I have an ActiveX TabStrip that controls what is displayed in the Smart Document. I can pass data TO the ActiveX telling it how many tabs should show and what their captions are, but it&#39;s not simple to get that data back to the Smart Document to refresh the display. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;There are two problems involved:&lt;/P&gt;&#xD;&#xA;&lt;OL&gt;&#xD;&#xA;&lt;LI&gt;Having the Smart Document know which tab was chosen, and &#xD;&#xA;&lt;LI&gt;Knowing WHEN the tab was changed so we can refresh the display.&lt;/LI&gt;&lt;/OL&gt;&#xD;&#xA;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;First Try - Remoting&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;I created a managed WinForms UserControl and wrapped it up as an ActiveX, then added remoting logic in the constructor that exposed the specific instance (using RemotingServices.Marshal()) as a TCP remoting listener. My Smart Document then attempted to get a handle to to object via remoting from the OnPaneUpdateComplete method and call methods such as AddTabs or attach to OnClick events on the remote object.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Problems:&lt;/P&gt;&#xD;&#xA;&lt;OL&gt;&#xD;&#xA;&lt;LI&gt;The OnPaneUpdateComplete method would run twice, once before the ActiveX had configured itself, one after. I had to add try/catch logic for standard operation, which is bad and slow. &#xD;&#xA;&lt;LI&gt;Work with a remote object is slow. It&#39;s silly that I have to pass through a TCP channel to get to an object in the SAME PROCESS as me, even if it is in a different AppDomain. &#xD;&#xA;&lt;LI&gt;The SDK recommends not to use Managed controls wrapped in ActiveX, and I can see why - I had problems with Events on the control not firing (at all, not just via remoting) and every time I tried to set a property relating to the control&#39;s display - visibility, # of tabs, etc - Word would simply hang on an internal Control.ActiveXImpl.GetAmbientProperty() method, or some such.&lt;/LI&gt;&lt;/OL&gt;&#xD;&#xA;&lt;P&gt;In short, this approach failed miserably. Time for a second try:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Second Try - VB6&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Ahhh. It&#39;s been years.&lt;BR&gt;So I open a new control in VB6 and put a TabControl in it. I initialize the TabControl with the data from the property bag, so far so good. I still have the two goals I mentioned above - refresh the smart doc and pass data back. The solution for both was similar:&lt;/P&gt;&#xD;&#xA;&lt;UL&gt;&#xD;&#xA;&lt;LI&gt;Send data back by saving in in the document&#39;s CustomProperty collection, and &#xD;&#xA;&lt;LI&gt;Refresh the data by directly calling the documents&#39;s SmartDocument.RefreshPane() method.&lt;/LI&gt;&lt;/UL&gt;&#xD;&#xA;&lt;P&gt;Very nice, but from my ActiveX control, I did not have a handle to my document.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Getting a Document Pointer - First Try&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;“When in COM“, as the saying (loosely) goes, right? How did we get an instance of the currently running Word instance in COM? GetObject! &lt;/P&gt;&#xD;&#xA;&lt;P&gt;So I use GetObject(””, “Word.Application”) to get the running instance and all is well, until I try to have two Word instance open at the same time.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;It seems that VB&#39;s GetObject() (as well as the CLR&#39;s Marshal.GetActiveObject()) go over the ROT (Running Objects Table) and retrieve the first handle matching the ProgID given. If I had an instance of Winword loaded BEFORE the one I want, I&#39;d get that instead. What to do, what to do?&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Fortunately, some nice people on an internal alias had a solution for me:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Getting a Document Pointer - Second Try&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;When I&#39;m writing my C# Smart Document code, I DO have a reference to the document, right? Right. And this pointer, this Word.Document object, is a COM object and thus implements IUnknown, right? Right.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;So we pull up our sleeves to do some interop:&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=Arial size=2&gt;IntPtr docPointer = Marshal.GetIUnknownForObject(m_Document);&lt;BR&gt;m_DocumentPointerForActiveX = docPointer.ToString();&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=Arial size=2&gt;This will give us a string containing a number that&#39;s actually a pointer to the IUnknown interface of the document in question. &lt;BR&gt;This string we can now pass as part of our ActiveXPropBag to the control, where it will be decoded back to a document pointer, and all will be well.&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;FONT face=Arial size=2&gt;Unfortunately, I couldn&#39;t find any way to do this from VB6. No pointer handlers, and all the COM in VB is under the hood, not for the likes of us to play with. So I wrote a small C# component called WordHelper that uses the reverse function to get a document pointer - and wrapped that up in COM:&lt;FONT size=1&gt;&lt;/P&gt;&#xD;&#xA;&lt;P dir=ltr style=&#34;MARGIN-RIGHT: 0px&#34;&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;[ComVisible(&lt;FONT color=#0000ff&gt;true&lt;/FONT&gt;)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; Document GetDocumentByPointer(&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; Pointer)&lt;BR&gt;{&lt;BR&gt;    IntPtr docPtr = (IntPtr)Pointer;&lt;BR&gt;&lt;FONT color=#0000ff&gt;    return&lt;/FONT&gt; (Document)Marshal.GetObjectForIUnknown(docPtr);&lt;BR&gt;}&lt;/P&gt;&#xD;&#xA;&lt;P dir=ltr style=&#34;MARGIN-RIGHT: 0px&#34;&gt;Now my VB6 code recieves a string containing a document pointer, converts it to Integer, passes it to the WordHelper and receives a Word.Document object, and from there on it&#39;s (relatively) clear sailing.&lt;/P&gt;&lt;P dir=ltr style=&#34;MARGIN-RIGHT: 0px&#34;&gt;*Whew*&lt;BR&gt;&lt;/P&gt;&lt;/FONT&gt;</description>
			</item>
			<item>
				<title>He who controls the feeds - controls INFORMATION.</title>
				<link>https://bits.strawjackal.org/271/</link>
				<pubDate>Sun, 18 Apr 2004 12:25:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/271/</guid>
				<description>&lt;P&gt;This has nothing to do with Smart Documents, but I just wanted to mention Sig Weber&#39;s XSLT files that enable you to easily show RSS feeds as web parts on a Sharepoint site, without even having to install anything.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;You simply add a built-in XML Web Part, point it at the RSS feed, and add one of the three XSLT files as the XSL source (each is a different display style). &lt;/P&gt;&#xD;&#xA;&lt;P&gt;Simple, easy and fun for the entire family.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;&lt;A href=&#34;http://playground.doesntexist.org/&#34;&gt;http://playground.doesntexist.org/&lt;/A&gt;&lt;/P&gt;</description>
			</item>
			<item>
				<title>Word and Excel - A Wor(l)d Apart</title>
				<link>https://bits.strawjackal.org/272/</link>
				<pubDate>Tue, 13 Apr 2004 11:23:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/272/</guid>
				<description>&lt;P&gt;Technically, the same smart document can apply to both Word and Excel. In practice, if you want your smart-doc to actually DO something, chance are half your code will be hacked and kludged to work for both. For example:&lt;/P&gt;&#xD;&#xA;&lt;UL&gt;&#xD;&#xA;&lt;LI&gt;The XML model is different for the two applications.&lt;/LI&gt;&#xD;&#xA;&lt;LI&gt;To get Smart Document controls to respond to the entire document in Word, you&#39;ll use the element &lt;My schema namespace&gt;#actionPertainsToEntireSchema.&lt;BR&gt;In Excel, you&#39;ll bind to &lt;A href=&#34;http://schemas.microsoft.com/office/smartdocuments/2003#default&#34;&gt;http://schemas.microsoft.com/office/smartdocuments/2003#default&lt;/A&gt;.&lt;BR&gt;Needless to say, this is not documented anywhere.&lt;/LI&gt;&#xD;&#xA;&lt;LI&gt;Assuming we&#39;ve accepted the fact that an ActiveX control bound to one of these generic elements in entirely inaccessible from code (&lt;A href=&#34;http://support.microsoft.com/default.aspx?scid=%2Fservicedesks%2Fwebcasts%2Fen%2Ftranscripts%2Fwct022504.asp&#34;&gt;Here&lt;/A&gt;, about 80% of the way down. Running a search for “pertains“ should do it), we still can&#39;t use the same code for Word and Excel even for standard elements: XML elements in word are of type Microsoft.Office.Interop.Word.XMLNode. Excel&#39;s XML model is different, and uses element-mapping to cells or ranges. Even if we do get a node, to get the Smart Tag Action from it we&#39;ll use Microsoft.Office.Interop.Word.SmartTag, while Excel has Microsoft.Office.Interop.Excel.SmartTag. Similar? Very. Compatible? Not necessarily.&lt;/LI&gt;&lt;/UL&gt;&#xD;&#xA;&lt;P&gt;In short - if you gotta support both Word and Excel, I would suggest having two different Smart Document solutions. It would seem like the less elegant solution, but when you start seeing every function broken up into huge, distinct if/else blocks, you can tell that something&#39;s just not right.&lt;/P&gt;</description>
			</item>
			<item>
				<title>Debug and Conquer!</title>
				<link>https://bits.strawjackal.org/273/</link>
				<pubDate>Thu, 08 Apr 2004 16:28:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/273/</guid>
				<description>&lt;P&gt;A few tips to keep in mind when developing and debugging a Smart Document using C# (and probably VB.NET too).&lt;BR&gt;(For my own selfish ease-of-use, I will refer to Word exclusively here. All these steps should apply to Excel equally).&lt;/P&gt;&#xD;&#xA;&lt;OL&gt;&#xD;&#xA;&lt;LI&gt;When building the Smart Doc&#39;s Manifest.xml, make sure to include the &lt;runFromServer/&gt; tag for both the solution DLL and the schema.. This makes sure Word doesn&#39;t copy the DLL and such to the current user&#39;s profile, and thus uses the same DLL that Visual Studio is debugging. &#xD;&#xA;&lt;LI&gt;Create an empty document and attach it to the schema and the expansion pack. Then save it somewhere. &#xD;&#xA;&lt;LI&gt;In the Project Properties -&gt; Configuration Properties -&gt; Debugging -&gt; Start Action, set Winword.exe as your default application to run when debugging. Pass the name and path of the document from section #2 in the Command Line Arguments field. That way we always launch Word when debugging, and don&#39;t have to mess with attaching to process and so on. &#xD;&#xA;&lt;LI&gt;In the Post Build Event for the project, add the following line:&lt;BR&gt;C:WindowsMicrosoft.NETFrameworkv1.1.4322gacutil.exe /cdl&lt;BR&gt;(You might need to replace C:Windows with C:WINNT for Windows 2000. Also replace with the version of the framework you&#39;re using).&lt;BR&gt;This command clears the Download Cache. If we don&#39;t run it, Word will use an older, cached copy of the DLL. &lt;BR&gt;&lt;EM&gt;Note: If Word is running, this command will fail. Don&#39;t forget to close Word.&lt;/EM&gt; &#xD;&#xA;&lt;LI&gt;Once we&#39;re in Word and debugging and all, it&#39;s best to manually close the document rather than just brutally stopping the debugging session. Otherwise we&#39;ll get all those “Word recovered your document from the sudden crash, do you want to restore it?“ questions and taskpanes and all popping up. Best to spare yourself the aggravation and close it politely yourself.&lt;/LI&gt;&lt;/OL&gt;&#xD;&#xA;&lt;P&gt;Those should get us started. Now to fight with ActiveX controls...&lt;/P&gt;&#xD;&#xA;&lt;P&gt; &lt;/P&gt;</description>
			</item>
			<item>
				<title>&#34;Smarter than the average Document.&#34;</title>
				<link>https://bits.strawjackal.org/274/</link>
				<pubDate>Thu, 08 Apr 2004 15:16:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/274/</guid>
				<description>&lt;P&gt;Smart Document Deployment is definitely an issue that needs a lot of work.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;For the past week I&#39;ve been repeatedly stumped in the simple task of loading a Smart Document solution into Word. Not a specific, possibly-buggy SmartDoc - ANY SmartDoc solution. Even ones that worked before. Even the SDK-supplied SimpleSample. ALL.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;I followed the MSDN instructions quite specifically. (&lt;A href=&#34;http://msdn.microsoft.com/library/default.asp?url=./library/en-us/sdsdk/html/sdconDeployingStrategiesIntro.asp&#34;&gt;Here&lt;/A&gt;).&lt;BR&gt;I tried to debug using all the information &lt;A href=&#34;http://msdn.microsoft.com/office/default.aspx?pull=/library/en-us/dno2k3ta/html/odc_oftrsmartdocerrors.asp&#34;&gt;here&lt;/A&gt;.&lt;BR&gt;I added Code Access Security.&lt;BR&gt;I changed namespace names.&lt;BR&gt;I tried read the Fusion log to see what&#39;s going on.&lt;BR&gt;I uninstalled and reinstalled Office 2003 TWICE, in two different languages.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;And all this time this nagging, teasing, whining headache of an error message popping up. “Missing or invalid Smart Document”. G&lt;FONT size=2&gt;rrr... I&#39;ll show him missing or invalid!&lt;/FONT&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Hmpf. Well. As always, the answer came from a totally unexpected direction.&lt;BR&gt;Well, a rather expected direction, but in an unexpected manner. The Troubleshooting document listed above mentions the following possible cause:&lt;/P&gt;&#xD;&#xA;&lt;BLOCKQUOTE dir=ltr style=&#34;MARGIN-RIGHT: 0px&#34;&gt;&#xD;&#xA;&lt;P&gt;&lt;EM&gt;You have Microsoft Windows® .NET Framework 1.0 and Microsoft Windows® .NET Framework 1.1 installed on your computer. However, you accidentally configured the code access security policy using version 1.0 of the .NET Framework instead of 1.1. Correct this by using the .NET Framework 1.1 to grant Full Trust permissions to the assemblies. Remember to delete the previous settings. &lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&#xD;&#xA;&lt;P dir=ltr&gt;I have never had 1.0 installed on this machine, so I didn&#39;t suspect a thing - but then I remembered that I *DID* install the 2.0 framework a couple of weeks ago, trying to get Whidbey to run here. (Unsuccessfully, I might add). Even though I built my SmartDoc project in Everett linked to Framework1.1, and I set my code-access permissions in the Configuration tool for Framework1.1, and everything was supposed to be side-by-side and fine and dandy - and nevertheless, once I uninstalled the 2.0 framework things started working immediately. &lt;/P&gt;&#xD;&#xA;&lt;P dir=ltr&gt;My guess is Word tried to load the managed Smart Document DLL using the 2.0 DLLs. Does this make sense? Is there any reason this happens? Any way to stop it? Do I need to specify explicit binding rules in WINWORD.EXE.config to get it to bind properly when both 1.1 and 2.0 are installed?&lt;/P&gt;</description>
			</item>
			<item>
				<title>&#34;Quoth the SmartDoc: &#39;Never Load!&#39;&#34;</title>
				<link>https://bits.strawjackal.org/275/</link>
				<pubDate>Tue, 30 Mar 2004 11:55:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/275/</guid>
				<description>&lt;P&gt;These days I&#39;m having the ambiguous pleasure of building Office 2003-based Smart Document Solutions. Despite their hot-buzz name, they seem to lean more towards the dim end of the scale.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;While the &lt;A href=&#34;http://www.microsoft.com/downloads/details.aspx?FamilyID=24a557f7-eb06-4a2c-8f6c-2767b174126f&amp;DisplayLang=en&#34;&gt;Smart Document SDK&lt;/A&gt; itself is rather well written and covers most points, good documentation can only go so far to describe an awkward programming model where you can&#39;t so much specify controls on your Task Pane as much as create properties that expose the name, type and amount of controls you would like to have and wait for Word or Excel to create them for you. All in all, this makes for a nervous “I have no idea what the hell is going on” development experience.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;The advantage to that, of course, is that once I do wrap my head around the concepts and start whipping out SmartDocs by the bucketload, I will earn the awe and respect of my peers. Sorta like the way people always keep a respectful distance around people who can wrap steel bars around their heads. &lt;/P&gt;&#xD;&#xA;&lt;P&gt;Anyway, second only to the development model in needless complexity is the deployment model, relying on automatic installation of the smart-doc on demand by arcane XML files and inscrutable security settings. End result is that on a test machine, every time we opened a DOC file linked to a Smart Document solution we had to pass 3-4 pointless dialogs asking us to re-download the solution we had already downloaded and installed. It gets even ickier when the user doesn&#39;t have administrative rights on his workstation - a scenario too exotic for regular Smart Doc installations, it seems.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;2 hours and several futile googlings later, a solution was found: &lt;BR&gt;A registry key by the name of &lt;STRONG&gt;NeverLoadManifests&lt;/STRONG&gt;, alarming name nonwithstanding, tells Word not to try and re-load the Smart Document Solution from the source every time, and to settle for the version it already has installed. Not the best of solutions, since it prohibits us from using Office&#39;s Automatic update of SmartDoc solutions (which we aren&#39;t using in this deployment anyway), but it sure it better than asking users to click through 3 dialogs whenever they open a document.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;Key can be found here:&lt;BR&gt;&lt;STRONG&gt;HKEY_CURRENT_USERSOFTWAREMicrosoftOfficeCommonSmart Tags&lt;BR&gt;NeverLoadManifests=dword:0000001&lt;/STRONG&gt;&lt;/P&gt;&#xD;&#xA;&lt;P&gt;And Google has apparently never heard of it, which is impressive. It can be found in the SDK, though I found THAT out only after I had tracked it down.&lt;/P&gt;&#xD;&#xA;&lt;P&gt;May this page be Googled and Feedstered and help others with the problem, amen.&lt;/P&gt;</description>
			</item>
			<item>
				<title>&#34;O frabjous day! Callooh! Callay!&#34;</title>
				<link>https://bits.strawjackal.org/276/</link>
				<pubDate>Wed, 24 Mar 2004 05:33:00 +0200</pubDate>
				<guid>https://bits.strawjackal.org/276/</guid>
				<description>&lt;P align=justify&gt;&lt;EM&gt;It doesn&#39;t work.&lt;BR&gt;The lights have long since been turned off. Your eyes are red and sore and there&#39;s a stack of empty coffee cups threatening to teeter-totter off of your desk and into your lap.&lt;BR&gt;And it doesn&#39;t work.&lt;BR&gt;You&#39;ve been working on this nagging bug, this annoying program, this insignificant technical NOTHING for hours.&lt;BR&gt;But it just doesn&#39;t work.&lt;BR&gt;&lt;/EM&gt;&lt;EM&gt;And then it comes! the flash, the light, the little cherubs blowing silver trumpets in your mind. Maybe a corworker passed by and idly pointed it out. Maybe your eyes have started looking sideways at your code in frustration. Whatever the reason - it&#39;s OVER. You&#39;ve fixed the bug. The code works. You can go home now. &lt;/EM&gt;&lt;/P&gt;&#xD;&#xA;&lt;P align=justify&gt;We&#39;ve all been there. We&#39;ve all banged our heads against the wall in frustration because of some stupid bug or undocumented API. We know the relief that comes when you finally get past it.&lt;/P&gt;&#xD;&#xA;&lt;P align=justify&gt;So this is what my blog is for. To relieve my frustration when I can&#39;t get something to work, and to gloat in exultation when I finally can. &lt;/P&gt;&#xD;&#xA;&lt;P align=justify&gt; &lt;/P&gt;</description>
			</item>
	</channel>
</rss>
