<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Michiel van Otegem, IT Composer - .NET</title>
    <link>http://michiel.vanotegem.nl/</link>
    <description />
    <language>en-us</language>
    <copyright>Michiel van Otegem</copyright>
    <lastBuildDate>Mon, 05 Jul 2010 10:25:18 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>michiel@aspnl.com</managingEditor>
    <webMaster>michiel@aspnl.com</webMaster>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=c88e5ffd-0600-4bff-8c83-44b41265b345</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,c88e5ffd-0600-4bff-8c83-44b41265b345.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,c88e5ffd-0600-4bff-8c83-44b41265b345.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=c88e5ffd-0600-4bff-8c83-44b41265b345</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A recurring theme in web programming is calling a function periodically and/or at
a specific date and time. This has two aspects:
</p>
        <ul>
          <li>
Calling a function on a scheduled basis 
</li>
          <li>
Making sure time-outs don't interfere</li>
        </ul>
        <p>
          <strong>Calling a function on a scheduled basis</strong>
          <br />
To be able to call a function on your web app, you first need an endpoint (a URL)
that you can call to kick the function off. In ASP.NET you can do this in several
ways:
</p>
        <ol>
          <li>
Create a page that calls the function. 
</li>
          <li>
Create a handler (ASHX) that calls the function (more efficient than a page). 
</li>
          <li>
Create a WCF service that allows calls with HTTP GET, as discussed in <a href="http://sasibhushan.com/Blog/post/WCF-Using-HTTP-GET.aspx">this
blog post by Sasi Suryadevara</a>.</li>
        </ol>
        <p>
With your endpoint in place, you can use the Windows Task Scheduler to invoke
the function at any given time and at intervals as low as one minute. With the Windows
Task Scheduler you have several options again:
</p>
        <p>
Create a VB Script that calls the URL, as discussed in <a href="http://weblogs.asp.net/steveschofield/archive/2006/09/28/Schedule-a-task-to-call-a-webpage-using-Task-scheduler_2E00_.aspx">this
blog post by Steve Schofield</a>.
</p>
        <p>
Create a PowerShell script that calls the URL (same as option 1, but more modern).
</p>
        <p>
Have the Windows Task Scheduler open Internet Explorer and open the specified URL
(e.g. <font face="Courier New">C:\PROGRA~1\INTERN~1\iexplore.exe  -extoff http://www.google.com</font>,
which starts IE without extensions). If you do this, you also need to specify that
the Task Scheduler closes IE after 1 minute, which you can do in the Settings tab
of the task (Windows 2003), or in the Trigger configuration (Windows 2008), as
shown below.
</p>
        <p>
          <img border="0" src="http://michiel.vanotegem.nl/content/binary/task1minute.png" />
          <br />
          <em>Task Settings in Windows 2003</em>
        </p>
        <p>
          <img border="0" src="http://michiel.vanotegem.nl/content/binary/trigger.png" />
          <br />
          <em>Trigger configuration in Windows 2008</em>
        </p>
        <p>
Note: In Windows 2008 the dropdowns governing duration and interval show 30 minutes
as lowest value. You can in fact change this to 1 minute by editing the text.
</p>
        <p>
          <strong>Making sure time-outs don't interfere</strong>
          <br />
A web based call is bound to time-out after a few minutes. If you task takes longer
than that, this may abort the call depending on how you programmed it, and what webserver
settings are used with regards to disconnected clients. To ensure a time-out does
not interfere, you can spawn a new thread and have it call the function. That way
the thread handling the request can return a response to the client, and the function
is carried out regardless. One issue that may arise there is that the function itself
hangs or takes too long. You may want to add logic to ensure that it's aborted after
a certain time, and add logging to notify you of this, and possibly also ensure that
the function can only be run by one caller at a time.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=c88e5ffd-0600-4bff-8c83-44b41265b345" />
      </body>
      <title>Periodically calling a function in your web app</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,c88e5ffd-0600-4bff-8c83-44b41265b345.aspx</guid>
      <link>http://michiel.vanotegem.nl/2010/07/05/PeriodicallyCallingAFunctionInYourWebApp.aspx</link>
      <pubDate>Mon, 05 Jul 2010 10:25:18 GMT</pubDate>
      <description>&lt;p&gt;
A recurring theme in web programming is calling a function periodically and/or at
a specific date and time. This has two aspects:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Calling a function on a scheduled basis 
&lt;li&gt;
Making sure time-outs don't interfere&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;strong&gt;Calling a function on a scheduled basis&lt;/strong&gt;
&lt;br&gt;
To be able to call a function on your web app, you first need an endpoint (a URL)
that you can call to kick the function off. In ASP.NET you can do this in several
ways:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Create a page that calls the function. 
&lt;li&gt;
Create a handler (ASHX) that calls the function (more efficient than a page). 
&lt;li&gt;
Create a WCF service that allows calls with HTTP GET, as discussed in &lt;a href="http://sasibhushan.com/Blog/post/WCF-Using-HTTP-GET.aspx"&gt;this
blog post by Sasi Suryadevara&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
With your endpoint in&amp;nbsp;place, you can use the Windows Task Scheduler to invoke
the function at any given time and at intervals as low as one minute. With the Windows
Task Scheduler you have several options again:
&lt;/p&gt;
&lt;p&gt;
Create a VB Script that calls the URL, as discussed in &lt;a href="http://weblogs.asp.net/steveschofield/archive/2006/09/28/Schedule-a-task-to-call-a-webpage-using-Task-scheduler_2E00_.aspx"&gt;this
blog post by Steve Schofield&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Create a PowerShell script that calls the URL (same as option 1, but more modern).
&lt;/p&gt;
&lt;p&gt;
Have the Windows Task Scheduler open Internet Explorer and open the specified URL
(e.g. &lt;font face="Courier New"&gt;C:\PROGRA~1\INTERN~1\iexplore.exe&amp;nbsp; -extoff http://www.google.com&lt;/font&gt;,
which starts IE without extensions). If you do this, you also need to specify that
the Task Scheduler closes IE after 1 minute, which you can do in the Settings tab
of the task (Windows 2003), or in the Trigger configuration&amp;nbsp;(Windows 2008), as
shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 src="http://michiel.vanotegem.nl/content/binary/task1minute.png"&gt;
&lt;br&gt;
&lt;em&gt;Task Settings in Windows 2003&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 src="http://michiel.vanotegem.nl/content/binary/trigger.png"&gt;
&lt;br&gt;
&lt;em&gt;Trigger configuration in Windows 2008&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
Note: In Windows 2008 the dropdowns governing duration and interval show 30 minutes
as lowest value. You can in fact change this to 1 minute by editing the text.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Making sure time-outs don't interfere&lt;/strong&gt;
&lt;br&gt;
A web based call is bound to time-out after a few minutes. If you task takes longer
than that, this may abort the call depending on how you programmed it, and what webserver
settings are used with regards to disconnected clients. To ensure a time-out does
not interfere, you can spawn a new thread and have it call the function. That way
the thread handling the request can return a response to the client, and the function
is carried out regardless. One issue that may arise there is that the function itself
hangs or takes too long. You may want to add logic to ensure that it's aborted after
a certain time, and add logging to notify you of this, and possibly also ensure that
the function can only be&amp;nbsp;run&amp;nbsp;by one caller&amp;nbsp;at a time.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=c88e5ffd-0600-4bff-8c83-44b41265b345" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,c88e5ffd-0600-4bff-8c83-44b41265b345.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</category>
      <category>Development</category>
      <category>English</category>
      <category>Services</category>
      <category>Windows</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=f940e046-6a9a-4d91-98e4-b41ebb8eac91</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,f940e046-6a9a-4d91-98e4-b41ebb8eac91.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,f940e046-6a9a-4d91-98e4-b41ebb8eac91.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=f940e046-6a9a-4d91-98e4-b41ebb8eac91</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Windows Identity Foundation introduces a new ClaimTypes class. It contains predefined
claim type URIs for claims defined by OASIS and Microsoft. In the WIF SDK
project templates for a custom STS this ClaimTypes class is mixed with the one
already in System.IdentityModel.Claims, which is rather confusing. So, what's the
difference?
</p>
        <p>
Functionally: None. All claim type URIs in Microsoft.IdentityModel.Claims.ClaimTypes
are identical to corresponding types in System.IdentityModel.Claims.ClaimTypes. That
said, Microsoft.IdentityModel.Claims.ClaimTypes adds a few new claim types.
</p>
        <p>
Technically: Claim types in System.IdentityModel.Claims.ClaimTypes are defined
as static read only string properties, whereas in Microsoft.IdentityModel.Claims.ClaimTypes
the claim types are string constants.
</p>
        <p>
My advice: for clarity always use Microsoft.IdentityModel.Claims.ClaimTypes.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=f940e046-6a9a-4d91-98e4-b41ebb8eac91" />
      </body>
      <title>System.IdentityModel.Claims.ClaimTypes vs. Microsoft.IdentityModel.Claims.ClaimTypes</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,f940e046-6a9a-4d91-98e4-b41ebb8eac91.aspx</guid>
      <link>http://michiel.vanotegem.nl/2009/11/25/SystemIdentityModelClaimsClaimTypesVsMicrosoftIdentityModelClaimsClaimTypes.aspx</link>
      <pubDate>Wed, 25 Nov 2009 12:33:08 GMT</pubDate>
      <description>&lt;p&gt;
Windows Identity Foundation introduces a new ClaimTypes class. It contains&amp;nbsp;predefined
claim type URIs for claims defined by OASIS and Microsoft.&amp;nbsp;In the WIF&amp;nbsp;SDK
project templates for a custom STS&amp;nbsp;this ClaimTypes class is mixed with the one
already in System.IdentityModel.Claims, which is rather confusing. So, what's the
difference?
&lt;/p&gt;
&lt;p&gt;
Functionally: None. All claim type URIs in Microsoft.IdentityModel.Claims.ClaimTypes
are identical to corresponding types in System.IdentityModel.Claims.ClaimTypes. That
said, Microsoft.IdentityModel.Claims.ClaimTypes adds a few new claim types.
&lt;/p&gt;
&lt;p&gt;
Technically: Claim types in System.IdentityModel.Claims.ClaimTypes&amp;nbsp;are defined
as&amp;nbsp;static read only string properties, whereas in Microsoft.IdentityModel.Claims.ClaimTypes
the claim types are string constants.
&lt;/p&gt;
&lt;p&gt;
My advice: for clarity always use Microsoft.IdentityModel.Claims.ClaimTypes.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=f940e046-6a9a-4d91-98e4-b41ebb8eac91" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,f940e046-6a9a-4d91-98e4-b41ebb8eac91.aspx</comments>
      <category>.NET</category>
      <category>Development</category>
      <category>English</category>
      <category>Windows Identity Foundation</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=9781323c-7fef-4e91-8728-6a4b6ef35cdf</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,9781323c-7fef-4e91-8728-6a4b6ef35cdf.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,9781323c-7fef-4e91-8728-6a4b6ef35cdf.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=9781323c-7fef-4e91-8728-6a4b6ef35cdf</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Windows Identity Foundation, formerly known as "Geneva", has shipped. I've been talking
about Geneva/WIF on several occasions and I absolutely love it. It opens the door
for a whole new realm of authentication/authorization scenario's. SharePoint 2010
will be the first Microsoft Product to support it, apart from the new Active Directory
Federation Services 2.0, which was part of the development effort and was formerly
known as "Geneva" Server. Be sure to <a href="http://msdn.microsoft.com/en-us/security/aa570351.aspx">check
it out</a>!
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=9781323c-7fef-4e91-8728-6a4b6ef35cdf" />
      </body>
      <title>Windows Identity Foundation released</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,9781323c-7fef-4e91-8728-6a4b6ef35cdf.aspx</guid>
      <link>http://michiel.vanotegem.nl/2009/11/19/WindowsIdentityFoundationReleased.aspx</link>
      <pubDate>Thu, 19 Nov 2009 14:09:16 GMT</pubDate>
      <description>&lt;p&gt;
Windows Identity Foundation, formerly known as "Geneva", has shipped. I've been talking
about Geneva/WIF on several occasions and I absolutely love it. It opens the door
for a whole new realm of authentication/authorization scenario's. SharePoint 2010
will be the first Microsoft Product to support it, apart from the new Active Directory
Federation Services 2.0, which was part of the development effort and was formerly
known as "Geneva" Server. Be sure to &lt;a href="http://msdn.microsoft.com/en-us/security/aa570351.aspx"&gt;check
it out&lt;/a&gt;!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=9781323c-7fef-4e91-8728-6a4b6ef35cdf" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,9781323c-7fef-4e91-8728-6a4b6ef35cdf.aspx</comments>
      <category>.NET</category>
      <category>English</category>
      <category>Security</category>
      <category>Windows Identity Foundation</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=8f7b5e8e-a85c-4b62-b1eb-51c3c60fcdd8</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,8f7b5e8e-a85c-4b62-b1eb-51c3c60fcdd8.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,8f7b5e8e-a85c-4b62-b1eb-51c3c60fcdd8.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=8f7b5e8e-a85c-4b62-b1eb-51c3c60fcdd8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Komende zaterdag is <a href="http://www.codecamp.nl/">Code Camp</a> en daar zal ik
een sessie doen over Windows Identity Foundation, de nieuwe basis voor beveiliging.
Kom je ook? Het is gratis.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=8f7b5e8e-a85c-4b62-b1eb-51c3c60fcdd8" />
      </body>
      <title>Zie ik je op Code Camp?</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,8f7b5e8e-a85c-4b62-b1eb-51c3c60fcdd8.aspx</guid>
      <link>http://michiel.vanotegem.nl/2009/11/16/ZieIkJeOpCodeCamp.aspx</link>
      <pubDate>Mon, 16 Nov 2009 23:03:58 GMT</pubDate>
      <description>&lt;p&gt;
Komende zaterdag is &lt;a href="http://www.codecamp.nl/"&gt;Code Camp&lt;/a&gt; en daar zal ik
een sessie doen over Windows Identity Foundation,&amp;nbsp;de nieuwe basis voor beveiliging.
Kom je ook? Het is gratis.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=8f7b5e8e-a85c-4b62-b1eb-51c3c60fcdd8" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,8f7b5e8e-a85c-4b62-b1eb-51c3c60fcdd8.aspx</comments>
      <category>.NET</category>
      <category>Evenementen</category>
      <category>Nederlands</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=39cf5c6c-3a2e-4a16-90a5-7fa9eccafd13</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,39cf5c6c-3a2e-4a16-90a5-7fa9eccafd13.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,39cf5c6c-3a2e-4a16-90a5-7fa9eccafd13.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=39cf5c6c-3a2e-4a16-90a5-7fa9eccafd13</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As an MVP I've had the fortune of being involved early in the VS2010 beta. Because
the number of beta participants is relatively small in the beginning, Microsoft is
able to have a much more interaction with the testing population and excplicitly goes
out for feedback and discussion of some of the features. VS2010 is a great example
of Microsoft putting that to good use. Something simple like the Add Reference dialog
has improved greatly in VS2010, as Scott Guthrie explains <a href="http://weblogs.asp.net/scottgu/archive/2009/10/29/add-reference-dialog-improvements-vs-2010-and-net-4-0-series.aspx">here</a>.
I remember the discussion about it, because there were quite a few different ideas
about what should come up first and what you use the most. As you can see, Microsoft
decided that the Projects tab is the most likely to be used first, so I'm assuming
most developers agree on that (I do anyway).
</p>
        <p>
BTW, the rest of the series on <a href="http://weblogs.asp.net/scottgu/archive/2009/08/25/vs-2010-and-net-4-series.aspx">VS2010
and .NET 4.0</a> provides a good overview of what you can expect of the new release.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=39cf5c6c-3a2e-4a16-90a5-7fa9eccafd13" />
      </body>
      <title>VS2010, Microsoft has been listening</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,39cf5c6c-3a2e-4a16-90a5-7fa9eccafd13.aspx</guid>
      <link>http://michiel.vanotegem.nl/2009/11/12/VS2010MicrosoftHasBeenListening.aspx</link>
      <pubDate>Thu, 12 Nov 2009 01:37:54 GMT</pubDate>
      <description>&lt;p&gt;
As an MVP I've had the fortune of being involved early in the VS2010 beta. Because
the number of beta participants is relatively small in the beginning, Microsoft is
able to have a much more interaction with the testing population and excplicitly goes
out for feedback and discussion of some of the features. VS2010 is a great example
of Microsoft putting that to good use. Something simple like the Add Reference dialog
has improved greatly in VS2010, as Scott Guthrie explains &lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/29/add-reference-dialog-improvements-vs-2010-and-net-4-0-series.aspx"&gt;here&lt;/a&gt;.
I remember the discussion about it, because there were quite a few different ideas
about what should come up first and what you use the most. As you can see, Microsoft
decided that the Projects tab is the most likely to be used first, so I'm assuming
most developers agree on that (I do anyway).
&lt;/p&gt;
&lt;p&gt;
BTW, the rest of the series on &lt;a href="http://weblogs.asp.net/scottgu/archive/2009/08/25/vs-2010-and-net-4-series.aspx"&gt;VS2010
and .NET 4.0&lt;/a&gt; provides a good overview of what you can expect of the new release.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=39cf5c6c-3a2e-4a16-90a5-7fa9eccafd13" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,39cf5c6c-3a2e-4a16-90a5-7fa9eccafd13.aspx</comments>
      <category>.NET</category>
      <category>English</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=75f0b0f7-829e-4a4a-9b8f-ba8b85baa86e</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,75f0b0f7-829e-4a4a-9b8f-ba8b85baa86e.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,75f0b0f7-829e-4a4a-9b8f-ba8b85baa86e.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=75f0b0f7-829e-4a4a-9b8f-ba8b85baa86e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was working on this little app I wrote a while ago and wanted to add some features
requiring (de)serialization. So, I took the original class and made it a DataContract
so I could use it with the DataContractSerializer. The class then looked more or less
like this:
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">[DataContract] <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">class</span> MyClass
{ List&lt;Trip&gt; m_Items <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">new</span> List&lt;Item&gt;();
[DataMember] <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span> IList&lt;Item&gt;
Items { get { <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">return</span> m_Items;
} } }</span>
        </pre>
        <p>
Serialization went fine, but when I tried to deserialize the same object, I got a
null reference exception. Of course you say, you should have added a method tied to
de OnDeserializing event, because the constructor of the object doesn't work and hence
the m_Items field is never initialized. The code I added to solve this looked
like this:
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">[OnDeserializing] <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">protected</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Init(StreamingContext
context) { m_Items <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">new</span> List&lt;Item&gt;();
}</span>
        </pre>
        <p>
To my surprise I still got the same exception. I finally figured out that the problem
was the type of Items. It is was an IList&lt;&gt; instead of a List&lt;&gt;. To avoid
tying a class to a specific implementation of a list, I usually use an interface,
which is good practice in most cases... however, not when you want to do deserialization
:).
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=75f0b0f7-829e-4a4a-9b8f-ba8b85baa86e" />
      </body>
      <title>DataContractSerializer and interfaces</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,75f0b0f7-829e-4a4a-9b8f-ba8b85baa86e.aspx</guid>
      <link>http://michiel.vanotegem.nl/2009/09/02/DataContractSerializerAndInterfaces.aspx</link>
      <pubDate>Wed, 02 Sep 2009 21:11:22 GMT</pubDate>
      <description>&lt;p&gt;
I was working on this little app I wrote a while ago and wanted to add some features
requiring (de)serialization. So, I took the original class and made it a DataContract
so I could use it with the DataContractSerializer. The class then looked more or less
like this:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;[DataContract] &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;class&lt;/span&gt; MyClass
{ List&amp;lt;Trip&amp;gt; m_Items &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;new&lt;/span&gt; List&amp;lt;Item&amp;gt;();
[DataMember] &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; IList&amp;lt;Item&amp;gt;
Items { get { &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;return&lt;/span&gt; m_Items;
} } }&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Serialization went fine, but when I tried to deserialize the same object, I got a
null reference exception. Of course you say, you should have added a method tied to
de OnDeserializing event, because the constructor of the object doesn't work and hence
the m_Items field is never initialized. The code I added to solve this&amp;nbsp;looked
like this:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;[OnDeserializing] &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;protected&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Init(StreamingContext
context) { m_Items &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;new&lt;/span&gt; List&amp;lt;Item&amp;gt;();
}&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
To my surprise I still got the same exception. I finally figured out that the problem
was the type of Items. It is was an IList&amp;lt;&amp;gt; instead of a List&amp;lt;&amp;gt;. To avoid
tying a class to a specific implementation of a list, I usually use an interface,
which is good practice in most cases... however, not when you want to do deserialization
:).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=75f0b0f7-829e-4a4a-9b8f-ba8b85baa86e" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,75f0b0f7-829e-4a4a-9b8f-ba8b85baa86e.aspx</comments>
      <category>.NET</category>
      <category>Development</category>
      <category>English</category>
      <category>Services</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=e213994d-019b-4688-8b88-6b454802d802</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,e213994d-019b-4688-8b88-6b454802d802.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,e213994d-019b-4688-8b88-6b454802d802.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=e213994d-019b-4688-8b88-6b454802d802</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
At BataviaLabs we were debating coding guidelines the other day and came across this
one: do you use #if or the ConditionalAttribute to indicate to the compiler if a method
should be compiled. Let me elaborate...
</p>
        <p>
If you have a method you only want to compile in a debug scenario, you have the following
options:
</p>
        <p>
1) Use #if DEBUG as shown below
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">class</span> Program
{ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">static</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Main(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">string</span>[]
args) { <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">#if</span> DEBUG
SomeMethod(); <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">#endif</span> Console.WriteLine(<span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"End"</span>);
Console.ReadKey(); } <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">#if</span> DEBUG <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">internal</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">static</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> SomeMethod()
{ Console.WriteLine(<span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"SomeMethod"</span>);
} <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">#endif</span> }</span>
        </pre>
        <p>
2) Use the ConditionalAttribute as shown below
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">class</span> Program
{ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">static</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Main(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">string</span>[]
args) { SomeMethod(); Console.WriteLine(<span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"End"</span>);
Console.ReadKey(); } [Conditional(<span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"DEBUG"</span>)] <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">internal</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">static</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> SomeMethod()
{ Console.WriteLine(<span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"SomeMethod"</span>);
} }</span>
        </pre>
        <p>
The difference between these two methods is enormous. The first sample is very explicit.
Any code you don't want to compile into the production build is placed between #if
DEBUG and #endif. If you try to call SomeMethod in a production build, the compiler
will give you a compile error. The ConditionalAttributeon the other hand doesn't require
you to remove the calls to SomeMethod. If a method is marked [Conditional], any calls
made to that method are removed from the build by the compiler. A proviso here is
that [Conditional] only works with methods that don't return a value (i.e. void).
</p>
        <p>
I much more prefer #if DEBUG, because it is explicit. I can't run into a situation
where from reading the code I'm thinking "SomeMethod is being executed", but it actually
isn't because the compiler removed the call. Comments anyone?
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=e213994d-019b-4688-8b88-6b454802d802" />
      </body>
      <title>#if vs. ConditionalAttribute</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,e213994d-019b-4688-8b88-6b454802d802.aspx</guid>
      <link>http://michiel.vanotegem.nl/2009/08/26/ifVsConditionalAttribute.aspx</link>
      <pubDate>Wed, 26 Aug 2009 14:59:00 GMT</pubDate>
      <description>&lt;p&gt;
At BataviaLabs we were debating coding guidelines the other day and came across this
one: do you use #if or the ConditionalAttribute to indicate to the compiler if a method
should be compiled. Let me elaborate...
&lt;/p&gt;
&lt;p&gt;
If you have a method you only want to compile in a debug scenario, you have the following
options:
&lt;/p&gt;
&lt;p&gt;
1) Use #if DEBUG as shown&amp;nbsp;below
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;class&lt;/span&gt; Program
{ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;static&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Main(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;string&lt;/span&gt;[]
args) { &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;#if&lt;/span&gt; DEBUG
SomeMethod(); &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;#endif&lt;/span&gt; Console.WriteLine(&lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"End"&lt;/span&gt;);
Console.ReadKey(); } &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;#if&lt;/span&gt; DEBUG &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;internal&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;static&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; SomeMethod()
{ Console.WriteLine(&lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"SomeMethod"&lt;/span&gt;);
} &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;#endif&lt;/span&gt; }&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
2) Use the ConditionalAttribute as shown below
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;class&lt;/span&gt; Program
{ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;static&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Main(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;string&lt;/span&gt;[]
args) { SomeMethod(); Console.WriteLine(&lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"End"&lt;/span&gt;);
Console.ReadKey(); } [Conditional(&lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"DEBUG"&lt;/span&gt;)] &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;internal&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;static&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; SomeMethod()
{ Console.WriteLine(&lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"SomeMethod"&lt;/span&gt;);
} }&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
The difference between these two methods is enormous. The first sample is very explicit.
Any code you don't want to compile into the production build is placed between #if
DEBUG and #endif. If you try to call SomeMethod in a production build, the compiler
will give you a compile error. The ConditionalAttributeon the other hand doesn't require
you to remove the calls to SomeMethod. If a method is marked [Conditional], any calls
made to that method are removed from the build by the compiler. A proviso here is
that [Conditional] only works with methods that don't return a value (i.e. void).
&lt;/p&gt;
&lt;p&gt;
I much more prefer #if DEBUG, because it is explicit.&amp;nbsp;I can't run into a situation
where from reading the code I'm thinking "SomeMethod is being executed", but it actually
isn't because the compiler removed the call. Comments anyone?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=e213994d-019b-4688-8b88-6b454802d802" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,e213994d-019b-4688-8b88-6b454802d802.aspx</comments>
      <category>.NET</category>
      <category>Development</category>
      <category>English</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=4ec64bdd-85ac-49e2-b744-ee1b7ec7606f</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,4ec64bdd-85ac-49e2-b744-ee1b7ec7606f.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,4ec64bdd-85ac-49e2-b744-ee1b7ec7606f.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=4ec64bdd-85ac-49e2-b744-ee1b7ec7606f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Thank you for all who attended my sessions in San Francisco. Below are the slides
and samples for my sessions.
</p>
        <p>
          <strong>VTH4 - Understanding Transactions in WCF</strong>
          <a href="http://michiel.vanotegem.nl/content/binary/VTH4_Slides.zip">Slides
(561.73 KB)</a> | <a href="http://michiel.vanotegem.nl/content/binary/WCFTransactions.zip">Samples
(540.1 KB)</a></p>
        <p>
          <strong>VTH16 - Supporting POX/REST with WCF</strong>
          <a href="http://michiel.vanotegem.nl/content/binary/VTH16_Slides.zip">Slides
(369.58 KB)</a> | <a href="http://michiel.vanotegem.nl/content/binary/WCFPoxRest.zip">Samples
(302.82 KB)</a></p>
        <p>
          <strong>VTH25 - Simplify WebPart (and Control) Development with WebPart Skinning</strong>
          <a href="http://michiel.vanotegem.nl/content/binary/VTH25_Slides.zip">Slides
(359.85 KB)</a> | <a href="http://michiel.vanotegem.nl/content/binary/Skinning.zip">Samples
(447.66 KB)</a></p>
        <p>
The VTH25 samples include the full installer. However, be sure to change the <em>uploadskinfeature.bat</em> to
point to the correct server. You can read more about the VirtualPathProvider
I mentioned in VTH25 session <a href="http://michiel.vanotegem.nl/2008/08/30/ServingPartOfASiteFromEmbeddedResources.aspx">here</a>.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=4ec64bdd-85ac-49e2-b744-ee1b7ec7606f" />
      </body>
      <title>VSLive! 2009 San Francisco slides and samples</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,4ec64bdd-85ac-49e2-b744-ee1b7ec7606f.aspx</guid>
      <link>http://michiel.vanotegem.nl/2009/03/02/VSLive2009SanFranciscoSlidesAndSamples.aspx</link>
      <pubDate>Mon, 02 Mar 2009 22:25:30 GMT</pubDate>
      <description>&lt;p&gt;
Thank you for all who attended my sessions in San Francisco. Below are the slides
and samples for my sessions.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;VTH4 - Understanding Transactions in WCF&lt;/strong&gt; &lt;a href="http://michiel.vanotegem.nl/content/binary/VTH4_Slides.zip"&gt;Slides
(561.73 KB)&lt;/a&gt; | &lt;a href="http://michiel.vanotegem.nl/content/binary/WCFTransactions.zip"&gt;Samples
(540.1 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;VTH16 - Supporting POX/REST with WCF&lt;/strong&gt; &lt;a href="http://michiel.vanotegem.nl/content/binary/VTH16_Slides.zip"&gt;Slides
(369.58 KB)&lt;/a&gt; | &lt;a href="http://michiel.vanotegem.nl/content/binary/WCFPoxRest.zip"&gt;Samples
(302.82 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;VTH25 - Simplify WebPart (and Control) Development with WebPart Skinning&lt;/strong&gt; &lt;a href="http://michiel.vanotegem.nl/content/binary/VTH25_Slides.zip"&gt;Slides
(359.85 KB)&lt;/a&gt; | &lt;a href="http://michiel.vanotegem.nl/content/binary/Skinning.zip"&gt;Samples
(447.66 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The VTH25 samples include the full installer. However, be sure to change the &lt;em&gt;uploadskinfeature.bat&lt;/em&gt; to
point to&amp;nbsp;the correct server.&amp;nbsp;You can read more about the VirtualPathProvider
I mentioned in VTH25 session &lt;a href="http://michiel.vanotegem.nl/2008/08/30/ServingPartOfASiteFromEmbeddedResources.aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=4ec64bdd-85ac-49e2-b744-ee1b7ec7606f" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,4ec64bdd-85ac-49e2-b744-ee1b7ec7606f.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</category>
      <category>English</category>
      <category>Events</category>
      <category>SharePoint</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=8524414f-7de1-48d5-894a-25d62393c665</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,8524414f-7de1-48d5-894a-25d62393c665.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,8524414f-7de1-48d5-894a-25d62393c665.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=8524414f-7de1-48d5-894a-25d62393c665</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The wonderful folks at <a href="http://www.vslive.com">VSLive!</a> have invited
me again to do three sessions at their <a href="http://vslive.com/2009/sf/default.aspx?code=VS09SF">San
Francisco</a> event from February 23 to February 27, 2009. These are the sessions
I'll do (all on Thursday 26):
</p>
        <ul>
          <li>
Understanding Transactions in WCF</li>
          <li>
Supporting POX/REST with WCF</li>
          <li>
Simplify WebPart (and Control) Development with WepPart Skinning</li>
        </ul>
        <p>
The first two are obviously about WCF. The last talk is primarily about SharePoint,
but the discussed techniques will work with ASP.NET WebParts and WebControls as well.
</p>
        <p>
I really like VSLive! because they have some great content and top tier speakers. The
speakers (myself included of course) are also very accessible, because the
event is not as huge as some of the other conferences these days. So if you intend
to go to a conference this year, VSLive! is going to be worth your money.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=8524414f-7de1-48d5-894a-25d62393c665" />
      </body>
      <title>Speaking at VSLive San Francisco, February 23-27</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,8524414f-7de1-48d5-894a-25d62393c665.aspx</guid>
      <link>http://michiel.vanotegem.nl/2009/01/07/SpeakingAtVSLiveSanFranciscoFebruary2327.aspx</link>
      <pubDate>Wed, 07 Jan 2009 21:52:13 GMT</pubDate>
      <description>&lt;p&gt;
The&amp;nbsp;wonderful folks at &lt;a href="http://www.vslive.com"&gt;VSLive!&lt;/a&gt; have invited
me again to do three sessions at their&amp;nbsp;&lt;a href="http://vslive.com/2009/sf/default.aspx?code=VS09SF"&gt;San
Francisco&lt;/a&gt;&amp;nbsp;event from February 23 to February 27, 2009. These are the sessions
I'll do (all on Thursday 26):
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Understanding Transactions in WCF&lt;/li&gt;
&lt;li&gt;
Supporting POX/REST with WCF&lt;/li&gt;
&lt;li&gt;
Simplify WebPart (and Control) Development with WepPart Skinning&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The first two are obviously about WCF. The last talk is primarily about SharePoint,
but the discussed techniques will work with ASP.NET WebParts and WebControls as well.
&lt;/p&gt;
&lt;p&gt;
I really like VSLive! because they&amp;nbsp;have some great content and top tier speakers.&amp;nbsp;The
speakers (myself included of course)&amp;nbsp;are also&amp;nbsp;very accessible, because the
event is not as huge as some of the other conferences these days. So if you intend
to go to a conference this year, VSLive! is going to be worth your money.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=8524414f-7de1-48d5-894a-25d62393c665" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,8524414f-7de1-48d5-894a-25d62393c665.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</category>
      <category>English</category>
      <category>Events</category>
      <category>SharePoint</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=e5c9a250-efa2-45ae-a801-c7b2c066d81f</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,e5c9a250-efa2-45ae-a801-c7b2c066d81f.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,e5c9a250-efa2-45ae-a801-c7b2c066d81f.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=e5c9a250-efa2-45ae-a801-c7b2c066d81f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I will be speaking at <a href="http://vslive.com/2008/dallas/default.aspx">VSLive!</a> again,
this time in Dallas from 8 until 11 December. I'll be doing the following sessions:
</p>
        <ul>
          <li>
Introduction to ASP.NET Dynamic Data (Tuesday 9 December, 11:15 AM)</li>
          <li>
POX/REST Strategies with WCF (Thursday 11 December, 1:45 PM)</li>
          <li>
Understanding Transactions in WCF (Thursday 11 December, 4:45 PM)</li>
        </ul>
        <p>
          <a href="http://vslive.com/2008/dallas/default.aspx">VSLive!</a> is a very nice and
relaxed event with <a href="http://vslive.com/2008/dallas/agenda.aspx">great content</a>.
So it's a great opportunity to learn new stuff and new people. If you want to attend
the Dallas show and see me speak, you can get a $300 discount by entering the discount
code <strong>SPVAN</strong>. I hope to see you there.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=e5c9a250-efa2-45ae-a801-c7b2c066d81f" />
      </body>
      <title>Speaking at VSLive in Dallas 8-11 December</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,e5c9a250-efa2-45ae-a801-c7b2c066d81f.aspx</guid>
      <link>http://michiel.vanotegem.nl/2008/10/28/SpeakingAtVSLiveInDallas811December.aspx</link>
      <pubDate>Tue, 28 Oct 2008 20:19:07 GMT</pubDate>
      <description>&lt;p&gt;
I will be speaking at &lt;a href="http://vslive.com/2008/dallas/default.aspx"&gt;VSLive!&lt;/a&gt; again,
this time in Dallas from 8 until 11 December. I'll be doing the following sessions:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Introduction to ASP.NET Dynamic Data (Tuesday 9 December, 11:15 AM)&lt;/li&gt;
&lt;li&gt;
POX/REST Strategies with WCF (Thursday 11 December, 1:45 PM)&lt;/li&gt;
&lt;li&gt;
Understanding Transactions in WCF (Thursday 11 December, 4:45 PM)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;a href="http://vslive.com/2008/dallas/default.aspx"&gt;VSLive!&lt;/a&gt; is a very nice and
relaxed event with &lt;a href="http://vslive.com/2008/dallas/agenda.aspx"&gt;great content&lt;/a&gt;.
So it's a great opportunity to learn new stuff and new people. If you want to attend
the Dallas show and see me speak, you can get a $300 discount by entering the discount
code &lt;strong&gt;SPVAN&lt;/strong&gt;. I hope to see you there.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=e5c9a250-efa2-45ae-a801-c7b2c066d81f" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,e5c9a250-efa2-45ae-a801-c7b2c066d81f.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</category>
      <category>English</category>
      <category>Events</category>
      <category>LINQ</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=bc6191d7-842c-45f4-8ab4-865f75d80a9f</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,bc6191d7-842c-45f4-8ab4-865f75d80a9f.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,bc6191d7-842c-45f4-8ab4-865f75d80a9f.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=bc6191d7-842c-45f4-8ab4-865f75d80a9f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
LINQ to SQL ontwikkelt heerlijk als je weet dat je alleen tegen SQL Server hoeft te
praten. Maar LINQ to SQL voegt wel weer een extra laagje toe, waardoor de kans
groot is dat er vertraging optreedt. Hoewel... LINQ to SQL doet ook aan caching, dus
als je veel met dezelfde data moet werken, hoef je niets extra's to doen om code aanzienlijk
sneller te laten lopen dan wanneer de database iedere keer benaderd moet worden. Rico
Mariani geeft in vijf delen een aardig inzicht in de performance van LINQ to SQL en
wat je kunt doen (of niet hoeft te doen) om de performance te verbeteren. Het
eerste deel, met links naar de andere delen, vind je <a href="http://blogs.msdn.com/ricom/archive/2007/06/22/dlinq-linq-to-sql-performance-part-1.aspx">hier</a>.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=bc6191d7-842c-45f4-8ab4-865f75d80a9f" />
      </body>
      <title>LINQ to SQL performance</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,bc6191d7-842c-45f4-8ab4-865f75d80a9f.aspx</guid>
      <link>http://michiel.vanotegem.nl/2008/08/23/LINQToSQLPerformance.aspx</link>
      <pubDate>Sat, 23 Aug 2008 21:10:33 GMT</pubDate>
      <description>&lt;p&gt;
LINQ to SQL ontwikkelt heerlijk als je weet dat je alleen tegen SQL Server hoeft te
praten. Maar LINQ to SQL&amp;nbsp;voegt wel weer een extra laagje toe, waardoor de kans
groot is dat er vertraging optreedt. Hoewel... LINQ to SQL doet ook aan caching, dus
als je veel met dezelfde data moet werken, hoef je niets extra's to doen om code aanzienlijk
sneller te laten lopen dan wanneer de database iedere keer benaderd moet worden. Rico
Mariani geeft in vijf delen een aardig inzicht in de performance van LINQ to SQL en
wat je kunt doen (of niet hoeft te doen)&amp;nbsp;om de performance te verbeteren. Het
eerste deel, met links naar de andere delen, vind je &lt;a href="http://blogs.msdn.com/ricom/archive/2007/06/22/dlinq-linq-to-sql-performance-part-1.aspx"&gt;hier&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=bc6191d7-842c-45f4-8ab4-865f75d80a9f" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,bc6191d7-842c-45f4-8ab4-865f75d80a9f.aspx</comments>
      <category>.NET</category>
      <category>LINQ</category>
      <category>Nederlands</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=0b29940a-ae3f-463f-bea1-fbd23d7a6fc3</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,0b29940a-ae3f-463f-bea1-fbd23d7a6fc3.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,0b29940a-ae3f-463f-bea1-fbd23d7a6fc3.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=0b29940a-ae3f-463f-bea1-fbd23d7a6fc3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've now read several books on SharePoint development, such as <a href="http://www.amazon.com/Developers-SharePoint-Services-Platform-Programming/dp/1584505001/aspnlcom-20">Developer's
Guide to the Windows SharePoint Services v3 Platform </a>, <a href="http://www.amazon.com/Microsoft-SharePoint-2007-Development-Unleashed/dp/0672329034/aspnlcom-20">Microsoft
harePoint 2007 Development Unleashed</a>, and <a href="http://www.amazon.com/Programming-Excel-Services-PRO-Developer-Bruney/dp/0735624070/aspnlcom-20">Programming
Excel Services</a>. I've found each of these books lacking, particularly the last
two. The Unleashed book is more a reference than anything else and especially in the
more advanced topics I really didn't find what I was looking for, which is not what
you'd expect from an Unleashed title. The Excel Services book is a disappointment
if you are looking for good information about Excel Services. If you want to learn
to develop WebParts it is quite good however. In that sense the book has been completely
misnamed. I hope that my next pick will be better (that said, two of the three books
were given to me).
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=0b29940a-ae3f-463f-bea1-fbd23d7a6fc3" />
      </body>
      <title>Good books on SharePoint development are rare (or I haven't found them yet)</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,0b29940a-ae3f-463f-bea1-fbd23d7a6fc3.aspx</guid>
      <link>http://michiel.vanotegem.nl/2008/07/23/GoodBooksOnSharePointDevelopmentAreRareOrIHaventFoundThemYet.aspx</link>
      <pubDate>Wed, 23 Jul 2008 09:37:33 GMT</pubDate>
      <description>&lt;p&gt;
I've now read several books on SharePoint development, such as &lt;a href="http://www.amazon.com/Developers-SharePoint-Services-Platform-Programming/dp/1584505001/aspnlcom-20"&gt;Developer's
Guide to the Windows SharePoint Services v3 Platform &lt;/a&gt;, &lt;a href="http://www.amazon.com/Microsoft-SharePoint-2007-Development-Unleashed/dp/0672329034/aspnlcom-20"&gt;Microsoft
harePoint 2007 Development Unleashed&lt;/a&gt;, and &lt;a href="http://www.amazon.com/Programming-Excel-Services-PRO-Developer-Bruney/dp/0735624070/aspnlcom-20"&gt;Programming
Excel Services&lt;/a&gt;. I've found each of these books lacking, particularly the last
two. The Unleashed book is more a reference than anything else and especially in the
more advanced topics I really didn't find what I was looking for, which is not what
you'd expect from an Unleashed title. The Excel Services book is a disappointment
if you are looking for good information about Excel Services. If you want to learn
to develop WebParts it is quite good however. In that sense the book has been completely
misnamed. I hope that my next pick will be better (that said, two of the three books
were given to me).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=0b29940a-ae3f-463f-bea1-fbd23d7a6fc3" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,0b29940a-ae3f-463f-bea1-fbd23d7a6fc3.aspx</comments>
      <category>.NET</category>
      <category>English</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=7353c7b3-4396-4a1d-a9e1-64acebe161a3</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,7353c7b3-4396-4a1d-a9e1-64acebe161a3.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,7353c7b3-4396-4a1d-a9e1-64acebe161a3.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=7353c7b3-4396-4a1d-a9e1-64acebe161a3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Log4net is a great tool for logging in a .NET application and everything is well documented.
Finding what you need can be a pain though. If you checkout the <a href="http://logging.apache.org/log4net/release/manual/configuration.html">configuration
manual</a>, you read about all the appenders and a little about the pattern of the
message that is logged. You can set that pattern if you want. What they fail to provide however
is a <a href="http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html">reference
of the tokens</a> you can use in a pattern (for instance %exception). They only
show a sort of default pattern. After digging for about 10 minutes, I finally found <a href="http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html">the
list</a> within the <a href="http://logging.apache.org/log4net/release/sdk/index.html">SDK
reference</a>. It would be great it someone were to add I direct link to there from
the <a href="http://logging.apache.org/log4net/release/manual/configuration.html">configuration
manual</a>.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=7353c7b3-4396-4a1d-a9e1-64acebe161a3" />
      </body>
      <title>Finding patterns for the log4net conversionPattern setting</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,7353c7b3-4396-4a1d-a9e1-64acebe161a3.aspx</guid>
      <link>http://michiel.vanotegem.nl/2008/03/09/FindingPatternsForTheLog4netConversionPatternSetting.aspx</link>
      <pubDate>Sun, 09 Mar 2008 23:18:03 GMT</pubDate>
      <description>&lt;p&gt;
Log4net is a great tool for logging in a .NET application and everything is well documented.
Finding what you need can be a pain though. If you checkout the &lt;a href="http://logging.apache.org/log4net/release/manual/configuration.html"&gt;configuration
manual&lt;/a&gt;, you read about all the appenders and a little about the pattern of the
message that is logged. You can set that pattern if you want. What they fail to provide&amp;nbsp;however
is a &lt;a href="http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html"&gt;reference
of the tokens&lt;/a&gt;&amp;nbsp;you can use in a pattern (for instance %exception). They only
show a sort of default pattern. After digging for about 10 minutes, I finally found &lt;a href="http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html"&gt;the
list&lt;/a&gt; within the &lt;a href="http://logging.apache.org/log4net/release/sdk/index.html"&gt;SDK
reference&lt;/a&gt;. It would be great it someone were to add I direct link to there from
the &lt;a href="http://logging.apache.org/log4net/release/manual/configuration.html"&gt;configuration
manual&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=7353c7b3-4396-4a1d-a9e1-64acebe161a3" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,7353c7b3-4396-4a1d-a9e1-64acebe161a3.aspx</comments>
      <category>.NET</category>
      <category>English</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=e6bc4c77-207f-4fe4-bffb-60237a4252d3</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,e6bc4c77-207f-4fe4-bffb-60237a4252d3.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,e6bc4c77-207f-4fe4-bffb-60237a4252d3.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=e6bc4c77-207f-4fe4-bffb-60237a4252d3</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've been doing stuff with LINQ to SQL for a while now and there's one thing that
keeps bugging me: Proper exception handling. IMHO LINQ to SQL should encapsulate
the database. I mean, I don't care which database (SQL Server, Oracle, whatever) I'm
working with, but if I call SubmitChanges on the DataContext, I'll get a SqlException
if it fails on the database. I know that currently LINQ to SQL only supports SQL Server,
but the model is just as valid for any other (relational)database. To my surprise
there is no LinqException or something that encapsulates the SqlException, so now
I have to write code that is aware of the fact that I'm dealing with SQL. You can
of course solve this by using the Exception Handling Application Block, so you don't
deal with specific exceptions in code, but it still feels funky.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=e6bc4c77-207f-4fe4-bffb-60237a4252d3" />
      </body>
      <title>Exception handling in LINQ to SQL</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,e6bc4c77-207f-4fe4-bffb-60237a4252d3.aspx</guid>
      <link>http://michiel.vanotegem.nl/2008/01/09/ExceptionHandlingInLINQToSQL.aspx</link>
      <pubDate>Wed, 09 Jan 2008 10:21:11 GMT</pubDate>
      <description>&lt;p&gt;
I've been doing stuff with LINQ to SQL for a while now and there's one thing that
keeps bugging me: Proper exception handling. IMHO LINQ to SQL&amp;nbsp;should encapsulate
the database. I mean, I don't care which database (SQL Server, Oracle, whatever)&amp;nbsp;I'm
working with, but if I call SubmitChanges on the DataContext, I'll get a SqlException
if it fails on the database. I know that currently LINQ to SQL only supports SQL Server,
but the model is just as valid for any other (relational)database. To my surprise
there is no LinqException or something that encapsulates the SqlException, so now
I have to write code that is aware of the fact that I'm dealing with SQL. You can
of course solve this by using the Exception Handling Application Block, so you don't
deal with specific exceptions in code, but it still feels funky.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=e6bc4c77-207f-4fe4-bffb-60237a4252d3" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,e6bc4c77-207f-4fe4-bffb-60237a4252d3.aspx</comments>
      <category>.NET</category>
      <category>English</category>
      <category>LINQ</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=c76db4ae-be0e-4233-9701-028d0ea6fb92</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,c76db4ae-be0e-4233-9701-028d0ea6fb92.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,c76db4ae-be0e-4233-9701-028d0ea6fb92.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=c76db4ae-be0e-4233-9701-028d0ea6fb92</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
For those interested in the demo of <em>Using Windows Workflow Foundation in ASP.NET</em>,
you can <a href="/content/binary/VSLiveORL_WFinASPNET.zip">download it here (269 kb)</a>.
Note: this is the demo with the "double bookkeeping". The request/response inside
a workflow isn't stable enough yet for release.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=c76db4ae-be0e-4233-9701-028d0ea6fb92" />
      </body>
      <title>Windows Workflow in ASP.NET demo from VSLive! Las Vegas</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,c76db4ae-be0e-4233-9701-028d0ea6fb92.aspx</guid>
      <link>http://michiel.vanotegem.nl/2007/10/18/WindowsWorkflowInASPNETDemoFromVSLiveLasVegas.aspx</link>
      <pubDate>Thu, 18 Oct 2007 23:52:27 GMT</pubDate>
      <description>&lt;p&gt;
For those interested in the demo of &lt;em&gt;Using Windows Workflow Foundation in ASP.NET&lt;/em&gt;,
you can &lt;a href="/content/binary/VSLiveORL_WFinASPNET.zip"&gt;download it here (269 kb)&lt;/a&gt;.
Note: this is the demo with the "double bookkeeping". The request/response inside
a workflow isn't stable enough yet for release.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=c76db4ae-be0e-4233-9701-028d0ea6fb92" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,c76db4ae-be0e-4233-9701-028d0ea6fb92.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</category>
      <category>English</category>
      <category>Events</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=fbe3e0c7-7088-4905-8777-07c15f6a2a3d</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,fbe3e0c7-7088-4905-8777-07c15f6a2a3d.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,fbe3e0c7-7088-4905-8777-07c15f6a2a3d.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=fbe3e0c7-7088-4905-8777-07c15f6a2a3d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'll be at <a href="http://www.ftponline.com/conferences/vslive/2007/lasvegas/asplive.aspx">VSLive!</a> in
Las Vegas next month. On Tuesday, October 16th, I'll be speaking about two topics:
</p>
        <ul>
          <li>
Using Windows Workflow Foundation in ASP.NET 
</li>
          <li>
Create Scalable Apps with Asynchronous Processing</li>
        </ul>
        <p>
The first is an introductory session about Windows Workflow Foundation (WF) and
adresses how to deal with WF in ASP.NET. Because WF is not request-response by
nature, this is more challenging than you would think. The second session discusses
ASP.NET 2.0 Async Pages and Handlers and shows you how to use this with web services
and databases.
</p>
        <p>
Hope to see you there!
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=fbe3e0c7-7088-4905-8777-07c15f6a2a3d" />
      </body>
      <title>Speaking at VSLive! in Vegas on October 16th</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,fbe3e0c7-7088-4905-8777-07c15f6a2a3d.aspx</guid>
      <link>http://michiel.vanotegem.nl/2007/09/20/SpeakingAtVSLiveInVegasOnOctober16th.aspx</link>
      <pubDate>Thu, 20 Sep 2007 07:46:02 GMT</pubDate>
      <description>&lt;p&gt;
I'll be at &lt;a href="http://www.ftponline.com/conferences/vslive/2007/lasvegas/asplive.aspx"&gt;VSLive!&lt;/a&gt; in
Las Vegas next month. On Tuesday, October 16th, I'll be speaking about two topics:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Using Windows Workflow Foundation in ASP.NET 
&lt;li&gt;
Create Scalable Apps with Asynchronous Processing&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The first is an introductory session about Windows Workflow Foundation (WF)&amp;nbsp;and
adresses how to&amp;nbsp;deal with WF&amp;nbsp;in&amp;nbsp;ASP.NET. Because WF is not request-response&amp;nbsp;by
nature, this is more challenging than you would think. The second session discusses
ASP.NET 2.0 Async Pages and Handlers and shows you how to use this with web services
and databases.
&lt;/p&gt;
&lt;p&gt;
Hope to see you there!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=fbe3e0c7-7088-4905-8777-07c15f6a2a3d" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,fbe3e0c7-7088-4905-8777-07c15f6a2a3d.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</category>
      <category>English</category>
      <category>Events</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=d9826145-408c-4fb9-8939-79d7e6a19218</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,d9826145-408c-4fb9-8939-79d7e6a19218.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,d9826145-408c-4fb9-8939-79d7e6a19218.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=d9826145-408c-4fb9-8939-79d7e6a19218</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Last year I wrote a book (in Dutch) about ASP.NET 2.0. For that book I did an interview
with Scott Guthrie, General Manager of the .NET Developer Platform group at Microsoft.
In the book the interview is of course translated and also edited to fit the book.
Below is the original unedited version.
</p>
        <p>
          <strong>Who are you?</strong>
          <br />
My name is Scott Guthrie. I am the General Manager of .NET Developer Platform group
within Microsoft, which means I run the development teams that build the CLR, .NET
Compact Framework, ASP.NET / Atlas, Windows Presentation Foundation (aka Avalon),
Windows Forms, IIS 7.0, Commerce Server, and the Visual Studio development tools for
ASP.NET and WPF.
</p>
        <p>
          <strong>How long have you worked for Microsoft, and in what did you do up to becoming
General Manager?</strong>
          <br />
I’ve been at Microsoft for 9 years.  I’ve been focusing on frameworks, tools
and servers for developers pretty much the entire time.  Prior to my current
role, I ran the teams that built ASP.NET, IIS 7.0, and Visual Web Developer.
</p>
        <p>
          <strong>You are generally seen as the (co-)creator of ASP.NET. How was ASP.NET conceived
and where did you get the ideas from?</strong>
          <br />
We actually started the ASP.NET project in late 1997 and early 1998.  At the
time ASP was still relatively new, and we initially weren’t sure whether there was
anything left to-do in the web space (little did we know)!  We then spent a lot
of time talking with developers and customers using ASP and quickly realized that
there were a lot of things left to resolve.  
</p>
        <p>
Some specific issues/requests that came up again and again from customers: provide
the ability to write much cleaner code that provided good code/content separation
(rather than mixing code up in the HTML), provide the ability to write applications
using a variety of coding languages (and not just VBScript and Jscript), deliver a
more robust execution environment (avoiding memory leaks and crashes that could bring
down the server), provide a much cleaner configuration/code deployment model, deliver
a built-in security architecture, enable built-in output caching support to improve
scalability, and more.
</p>
        <p>
A colleague of mine (Mark Anders) and I spent about 2 months brainstorming ideas about
how we could build a programming model that delivered all of this.  Eventually
we decided we needed to put together a prototype to try out the concepts, and I ended
up coding it up over the Christmas and New Year’s holiday in 1997/98 (I was a hardcore
geek then &lt;g&gt;).   We showed off the prototype to a lot of people within
the company, built a lot of excitement, and got the go ahead to build a team to deliver
it.
</p>
        <p>
          <strong>What are the main differences between ASP.NET 1.x and ASP.NET 2.0?</strong>
          <br />
We spent a lot of time working with customers to identify where they spend their time
writing code today within web applications, and then worked to add new features in
ASP.NET 2.0 to help simplify these tasks dramatically.  Some examples: Master
Pages allow you to easily define a consistent layout across your site/application,
the new Membership/Roles API provides an easy way to manage users/passwords/roles
and allows you to build flexible secure application in only a few minutes, the new
GridView/DetailsView/DataSource controls enable you to easily provide data entry and
editing views on top of data (including 3-tier data access support), Web Parts provide
the ability to enable portal-style layout within any page and enable drag/drop end-user
customization that works both in regular ASP.NET applications and SharePoint solutions,
Localization support has been added to make it much easier to build multi-lingual
applications that can adjust at runtime depending on the culture/language of the incoming
user, SQL Output Caching enables developers to output cache any content within a site
and have it automatically be invalidated and re-generated when backend data changes
on a site (dramatically improving performance), Site Navigation and Menu controls
make it much easier to build menu structures and navigation across your sites, Health
Monitoring makes it easier to monitor how your application is doing once it is deployed,
and there are many more features I could keep calling out.
</p>
        <p>
          <strong>If you could give one tip to people learning ASP.NET 2.0, what would it be?</strong>
          <br />
I’d recommend spending time on the new <a href="http://www.asp.net">http://www.asp.net</a> web-site
in the “Getting Started” and the “Learn” sections.  We are putting out several
new videos and tutorials each week on the site that help show how you can take best
advantage of new features with ASP.NET.  These can make it significantly easier
to take full advantage of the platform and build great applications.  I’d also
recommend subscribing to my blog: <a href="http://weblogs.asp.net/scottgu">http://weblogs.asp.net/scottgu</a>. 
I try and post 1-2 tips/tricks a week that you can use.
</p>
        <p>
          <strong>What do you (personally) think is the coolest feature of ASP.NET 2.0?</strong>
          <br />
Master Pages is probably the most popular feature that virtually everyone takes immediate
use of – so in terms of popularity that is probably the coolest.
</p>
        <p>
I think the new ASP.NET 2.0 AJAX Extensions product we are shipping later this year
is also really, really cool (note: this was formerly codenamed “Atlas”).  This
will provide a free, fully-supported AJAX library with suite of ASP.NET 2.0 server
controls that enable you to easily add AJAX functionality to your ASP.NET 2.0 sites.  
</p>
        <p>
          <strong>What are the long term goals for ASP.NET, and what will we see of that in
the coming years?</strong>
          <br />
The next release of ASP.NET will have a lot of great additions.  You will see
even richer support for the AJAX Extensions built-into the next release, as well as
much richer support for building more interactive user experiences that take full
advantage of the browser.
</p>
        <p>
You’ll also see ASP.NET take advantage of the new LINQ technologies that are coming
out with .NET, and which will enable really rich data modeling and mapping support
with code which will dramatically improve the productivity of working with data. 
When LINQ is combined with the ASP.NET 2.0 GridView, DetailsView and other data controls,
you have a tremendously easy and powerful programming model for building AJAX enabled
data applications.  I’m really excited to see the applications people build with
it.  It is going to be a very exciting future!<br /></p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=d9826145-408c-4fb9-8939-79d7e6a19218" />
      </body>
      <title>Interview with Scott Guthrie, creator of ASP.NET</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,d9826145-408c-4fb9-8939-79d7e6a19218.aspx</guid>
      <link>http://michiel.vanotegem.nl/2007/07/23/InterviewWithScottGuthrieCreatorOfASPNET.aspx</link>
      <pubDate>Mon, 23 Jul 2007 23:05:53 GMT</pubDate>
      <description>&lt;p&gt;
Last year I wrote a book (in Dutch) about ASP.NET 2.0. For that book I did an interview
with Scott Guthrie, General Manager of the .NET Developer Platform group at Microsoft.
In the book the interview is of course translated and also edited to fit the book.
Below is the original unedited version.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Who are you?&lt;/strong&gt;
&lt;br&gt;
My name is Scott Guthrie. I am the General Manager of .NET Developer Platform group
within Microsoft, which means I run the development teams that build the CLR, .NET
Compact Framework, ASP.NET / Atlas, Windows Presentation Foundation (aka Avalon),
Windows Forms, IIS 7.0, Commerce Server, and the Visual Studio development tools for
ASP.NET and WPF.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;How long have you worked for Microsoft, and in what did you do up to becoming
General Manager?&lt;/strong&gt;
&lt;br&gt;
I’ve been at Microsoft for 9 years.&amp;nbsp; I’ve been focusing on frameworks, tools
and servers for developers pretty much the entire time.&amp;nbsp; Prior to my current
role, I ran the teams that built ASP.NET, IIS 7.0, and Visual Web Developer.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;You are generally seen as the (co-)creator of ASP.NET. How was ASP.NET conceived
and where did you get the ideas from?&lt;/strong&gt;
&lt;br&gt;
We actually started the ASP.NET project in late 1997 and early 1998.&amp;nbsp; At the
time ASP was still relatively new, and we initially weren’t sure whether there was
anything left to-do in the web space (little did we know)!&amp;nbsp; We then spent a lot
of time talking with developers and customers using ASP and quickly realized that
there were a lot of things left to resolve.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Some specific issues/requests that came up again and again from customers: provide
the ability to write much cleaner code that provided good code/content separation
(rather than mixing code up in the HTML), provide the ability to write applications
using a variety of coding languages (and not just VBScript and Jscript), deliver a
more robust execution environment (avoiding memory leaks and crashes that could bring
down the server), provide a much cleaner configuration/code deployment model, deliver
a built-in security architecture, enable built-in output caching support to improve
scalability, and more.
&lt;/p&gt;
&lt;p&gt;
A colleague of mine (Mark Anders) and I spent about 2 months brainstorming ideas about
how we could build a programming model that delivered all of this.&amp;nbsp; Eventually
we decided we needed to put together a prototype to try out the concepts, and I ended
up coding it up over the Christmas and New Year’s holiday in 1997/98 (I was a hardcore
geek then &amp;lt;g&amp;gt;).&amp;nbsp;&amp;nbsp; We showed off the prototype to a lot of people within
the company, built a lot of excitement, and got the go ahead to build a team to deliver
it.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;What are the main differences between ASP.NET 1.x and ASP.NET 2.0?&lt;/strong&gt;
&lt;br&gt;
We spent a lot of time working with customers to identify where they spend their time
writing code today within web applications, and then worked to add new features in
ASP.NET 2.0 to help simplify these tasks dramatically.&amp;nbsp; Some examples: Master
Pages allow you to easily define a consistent layout across your site/application,
the new Membership/Roles API provides an easy way to manage users/passwords/roles
and allows you to build flexible secure application in only a few minutes, the new
GridView/DetailsView/DataSource controls enable you to easily provide data entry and
editing views on top of data (including 3-tier data access support), Web Parts provide
the ability to enable portal-style layout within any page and enable drag/drop end-user
customization that works both in regular ASP.NET applications and SharePoint solutions,
Localization support has been added to make it much easier to build multi-lingual
applications that can adjust at runtime depending on the culture/language of the incoming
user, SQL Output Caching enables developers to output cache any content within a site
and have it automatically be invalidated and re-generated when backend data changes
on a site (dramatically improving performance), Site Navigation and Menu controls
make it much easier to build menu structures and navigation across your sites, Health
Monitoring makes it easier to monitor how your application is doing once it is deployed,
and there are many more features I could keep calling out.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;If you could give one tip to people learning ASP.NET 2.0, what would it be?&lt;/strong&gt;
&lt;br&gt;
I’d recommend spending time on the new &lt;a href="http://www.asp.net"&gt;http://www.asp.net&lt;/a&gt; web-site
in the “Getting Started” and the “Learn” sections.&amp;nbsp; We are putting out several
new videos and tutorials each week on the site that help show how you can take best
advantage of new features with ASP.NET.&amp;nbsp; These can make it significantly easier
to take full advantage of the platform and build great applications.&amp;nbsp; I’d also
recommend subscribing to my blog: &lt;a href="http://weblogs.asp.net/scottgu"&gt;http://weblogs.asp.net/scottgu&lt;/a&gt;.&amp;nbsp;
I try and post 1-2 tips/tricks a week that you can use.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;What do you (personally) think is the coolest feature of ASP.NET 2.0?&lt;/strong&gt;
&lt;br&gt;
Master Pages is probably the most popular feature that virtually everyone takes immediate
use of – so in terms of popularity that is probably the coolest.
&lt;/p&gt;
&lt;p&gt;
I think the new ASP.NET 2.0 AJAX Extensions product we are shipping later this year
is also really, really cool (note: this was formerly codenamed “Atlas”).&amp;nbsp; This
will provide a free, fully-supported AJAX library with suite of ASP.NET 2.0 server
controls that enable you to easily add AJAX functionality to your ASP.NET 2.0 sites.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;What are the long term goals for ASP.NET, and what will we see of that in
the coming years?&lt;/strong&gt;
&lt;br&gt;
The next release of ASP.NET will have a lot of great additions.&amp;nbsp; You will see
even richer support for the AJAX Extensions built-into the next release, as well as
much richer support for building more interactive user experiences that take full
advantage of the browser.
&lt;/p&gt;
&lt;p&gt;
You’ll also see ASP.NET take advantage of the new LINQ technologies that are coming
out with .NET, and which will enable really rich data modeling and mapping support
with code which will dramatically improve the productivity of working with data.&amp;nbsp;
When LINQ is combined with the ASP.NET 2.0 GridView, DetailsView and other data controls,
you have a tremendously easy and powerful programming model for building AJAX enabled
data applications.&amp;nbsp; I’m really excited to see the applications people build with
it.&amp;nbsp; It is going to be a very exciting future!&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=d9826145-408c-4fb9-8939-79d7e6a19218" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,d9826145-408c-4fb9-8939-79d7e6a19218.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</category>
      <category>English</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=4bffcf38-091f-415f-b468-8fa043084a6e</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,4bffcf38-091f-415f-b468-8fa043084a6e.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,4bffcf38-091f-415f-b468-8fa043084a6e.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=4bffcf38-091f-415f-b468-8fa043084a6e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Wil je weten hoe Microsoft Silverlight (aka WPF/Everywhere, WPF in de browser a la
Flash) er qua architectuur uit gaat zien? <a href="http://download.microsoft.com/download/f/2/e/f2ecc2ad-c498-4538-8a2c-15eb157c00a7/SL_Map_FinalNET.png">Deze
plaat</a> geeft het overzicht. <a href="http://www.hanselman.com/">Scott Hanselman</a> geeft
een zeer uitgebreid overzicht in zijn blogpost <a href="http://www.hanselman.com/blog/PuttingMixSilverlightTheCoreCLRAndTheDLRIntoContext.aspx">Putting
Mix, Silverlight, the CoreCLR and the DLR into context</a>.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=4bffcf38-091f-415f-b468-8fa043084a6e" />
      </body>
      <title>Microsoft Silverlight overzicht</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,4bffcf38-091f-415f-b468-8fa043084a6e.aspx</guid>
      <link>http://michiel.vanotegem.nl/2007/05/04/MicrosoftSilverlightOverzicht.aspx</link>
      <pubDate>Fri, 04 May 2007 08:53:31 GMT</pubDate>
      <description>&lt;p&gt;
Wil je weten hoe Microsoft Silverlight (aka WPF/Everywhere, WPF in de browser a la
Flash)&amp;nbsp;er qua architectuur uit gaat zien? &lt;a href="http://download.microsoft.com/download/f/2/e/f2ecc2ad-c498-4538-8a2c-15eb157c00a7/SL_Map_FinalNET.png"&gt;Deze
plaat&lt;/a&gt; geeft het overzicht. &lt;a href="http://www.hanselman.com/"&gt;Scott Hanselman&lt;/a&gt; geeft
een zeer uitgebreid overzicht in zijn blogpost &lt;a href="http://www.hanselman.com/blog/PuttingMixSilverlightTheCoreCLRAndTheDLRIntoContext.aspx"&gt;Putting
Mix, Silverlight, the CoreCLR and the DLR into context&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=4bffcf38-091f-415f-b468-8fa043084a6e" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,4bffcf38-091f-415f-b468-8fa043084a6e.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</category>
      <category>Nederlands</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=938b0035-c86c-4be6-b2e8-4e4fda8a1c02</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,938b0035-c86c-4be6-b2e8-4e4fda8a1c02.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,938b0035-c86c-4be6-b2e8-4e4fda8a1c02.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=938b0035-c86c-4be6-b2e8-4e4fda8a1c02</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Reflector is een heerlijke tool waarmee je dde code kunt bekijken in asemblies, ook
de System... assmeblies van Microsoft (heeeel leerzaam). Als je Reflector nog niet
kent, haast je naar <a href="http://www.aisto.com/roeder/dotnet/">http://www.aisto.com/roeder/dotnet/</a> om
'm te downloaden. Ken je 'm wel al, haast je dan ook naar <a href="http://www.aisto.com/roeder/dotnet/">http://www.aisto.com/roeder/dotnet/</a> (of
doe Check for Updates in je huidige versie).
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=938b0035-c86c-4be6-b2e8-4e4fda8a1c02" />
      </body>
      <title>Reflector 5.0 beschikbaar</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,938b0035-c86c-4be6-b2e8-4e4fda8a1c02.aspx</guid>
      <link>http://michiel.vanotegem.nl/2007/02/21/Reflector50Beschikbaar.aspx</link>
      <pubDate>Wed, 21 Feb 2007 14:51:17 GMT</pubDate>
      <description>&lt;p&gt;
Reflector is een heerlijke tool waarmee je dde code kunt bekijken in asemblies, ook
de System... assmeblies van Microsoft (heeeel leerzaam). Als je Reflector nog niet
kent, haast je naar &lt;a href="http://www.aisto.com/roeder/dotnet/"&gt;http://www.aisto.com/roeder/dotnet/&lt;/a&gt;&amp;nbsp;om
'm te downloaden. Ken je 'm wel al, haast je dan ook naar &lt;a href="http://www.aisto.com/roeder/dotnet/"&gt;http://www.aisto.com/roeder/dotnet/&lt;/a&gt;&amp;nbsp;(of
doe Check for Updates in je huidige versie).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=938b0035-c86c-4be6-b2e8-4e4fda8a1c02" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,938b0035-c86c-4be6-b2e8-4e4fda8a1c02.aspx</comments>
      <category>.NET</category>
      <category>Nederlands</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=41115845-9fd8-4413-ac2d-b81a2c310b05</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,41115845-9fd8-4413-ac2d-b81a2c310b05.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,41115845-9fd8-4413-ac2d-b81a2c310b05.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=41115845-9fd8-4413-ac2d-b81a2c310b05</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Het is heel gewoon om classes in een library <font face="Courier New" color="#0000ff">public</font> te
maken, maar eigenlijk is dit helemaal niet handig. Dat betekent namelijk dat de class
vanuit alle code die de library gebruikt beschikbaar is. Met andere woorden de class
maakt onderdeel uit van de interface van de library. Er zijn meerdere redenen waarom
dit onwenselijk is:
</p>
        <ol>
          <li>
De interface is onnodig groot en voor gebruiker van de library kan het daarom onduidelijk
zijn welke classes gebruikt moeten worden.</li>
          <li>
Het is veel lastiger om te achterhalen welke verbindingen er bestaan tussen de library
en eventuele clients. Dit is bijvoorbeeld lastig bij refactoring.</li>
          <li>
Het is in een client mogelijk om een sub-class te maken, terwijl dit wellicht niet
de bedoeling is.</li>
        </ol>
        <p>
Veel beter is om classes <font face="Courier New" color="#0000ff">internal</font> te
maken. Dit is ook standaard zo als je geen <em>access modifier</em> plaatst. Daarmee
zijn classes alleen beschikbaar voor code binnen dezelfde assembly (tenzij men reflection
gebruikt).
</p>
        <p>
Het is verstandig om opo dezelfde manier even stil te staan bij class members. Die
zijn standaard <font face="Courier New" color="#0000ff">private</font>, en als je
dat verandert kun je ze <font face="Courier New" color="#0000ff">protected</font> (alleen
beschikibaar voor de class zelf en sub-classes), <font face="Courier New" color="#0000ff">internal</font>, <font face="Courier New" color="#0000ff">protected
internal</font> (protected of internal) of <font face="Courier New" color="#0000ff">public</font> maken.
Als je dit consequent toepast kun je ook reflection tegengaan door de class te markeren
met <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">[ReflectionPermission(SecurityAction.Deny)]</span><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Arial" size="2">.
Daarmee is de boel niet alleen veel handiger, maar ook veel veiliger.</font></span></p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=41115845-9fd8-4413-ac2d-b81a2c310b05" />
      </body>
      <title>TIP: Beperk het gebuik van "public"</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,41115845-9fd8-4413-ac2d-b81a2c310b05.aspx</guid>
      <link>http://michiel.vanotegem.nl/2007/02/19/TIPBeperkHetGebuikVanPublic.aspx</link>
      <pubDate>Mon, 19 Feb 2007 14:19:15 GMT</pubDate>
      <description>&lt;p&gt;
Het is heel gewoon om classes in een library &lt;font face="Courier New" color=#0000ff&gt;public&lt;/font&gt; te
maken, maar eigenlijk is dit helemaal niet handig. Dat betekent namelijk dat de class
vanuit alle code die de library gebruikt beschikbaar is. Met andere woorden de class
maakt onderdeel uit van de interface van de library. Er zijn meerdere redenen waarom
dit onwenselijk is:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
De interface is onnodig groot en voor gebruiker van de library kan het daarom onduidelijk
zijn welke classes gebruikt moeten worden.&lt;/li&gt;
&lt;li&gt;
Het is veel lastiger om te achterhalen welke verbindingen er bestaan tussen de library
en eventuele clients. Dit is bijvoorbeeld lastig bij refactoring.&lt;/li&gt;
&lt;li&gt;
Het is in een client mogelijk om een sub-class te maken, terwijl dit wellicht niet
de bedoeling is.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Veel beter is om classes &lt;font face="Courier New" color=#0000ff&gt;internal&lt;/font&gt; te
maken. Dit is ook standaard zo als je geen &lt;em&gt;access modifier&lt;/em&gt; plaatst. Daarmee
zijn classes alleen beschikbaar voor code binnen dezelfde assembly (tenzij men reflection
gebruikt).
&lt;/p&gt;
&lt;p&gt;
Het is verstandig om opo dezelfde manier even stil te staan bij class members. Die
zijn standaard &lt;font face="Courier New" color=#0000ff&gt;private&lt;/font&gt;, en als je dat
verandert kun je ze &lt;font face="Courier New" color=#0000ff&gt;protected&lt;/font&gt; (alleen
beschikibaar voor de class zelf en sub-classes), &lt;font face="Courier New" color=#0000ff&gt;internal&lt;/font&gt;, &lt;font face="Courier New" color=#0000ff&gt;protected
internal&lt;/font&gt; (protected of internal) of &lt;font face="Courier New" color=#0000ff&gt;public&lt;/font&gt; maken.
Als je dit consequent toepast kun je ook reflection tegengaan door de class te markeren
met &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[ReflectionPermission(SecurityAction.Deny)]&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Arial size=2&gt;.
Daarmee is de boel niet alleen veel handiger, maar ook veel veiliger.&lt;/font&gt;
&lt;/p&gt;
&gt;&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=41115845-9fd8-4413-ac2d-b81a2c310b05" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,41115845-9fd8-4413-ac2d-b81a2c310b05.aspx</comments>
      <category>.NET</category>
      <category>Nederlands</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=bcaf8021-98e5-49f2-a104-cfa54b844971</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,bcaf8021-98e5-49f2-a104-cfa54b844971.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,bcaf8021-98e5-49f2-a104-cfa54b844971.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=bcaf8021-98e5-49f2-a104-cfa54b844971</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Ik zie in code geregeld dat het Session object op allerlei plaatsen gebruikt wordt,
met name in pagina's en controls, als volgt:
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> Page_Load(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> sender,
EventArgs e)<br />
{<br />
    Session[<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"MySessionVar"</span>]
+= 1;<br />
}<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> Page_PreRender(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> sender,
EventArgs e)<br />
{<br />
    Label1.Text <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Session[<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"MySessionVar"</span>].ToString();<br />
}<br /></span>
        </p>
        <p>
Dit is om meerdere redenen niet aan te raden:
</p>
        <ol>
          <li>
Omdat de collectie loosely typed is, is er geen compile-time check bij het benaderen
van de elementen in de collectie. Het is daarom heel makkelijk om een typfoutje te
maken, waardoor je tegen het verkeerde object aan praat.</li>
          <li>
Door elementen in het Session object te stoppen in de pagina, is er geen centrale
administratie van de namen (keys) die in gebruik zijn.</li>
        </ol>
        <p>
Je kunt beide zaken oplossen door een centraal object te maken waarmee je de elementen
in het Session-object benaderd, als volgt:
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;summary&gt;</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
Strongly typed toegang tot Session-object.</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;/summary&gt;</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span>
            <font color="#0000ff"> static </font>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">class</span> TypedSession<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><font color="#0000ff">int</font> MySessionVar<br />
   {<br />
      get<br />
      {</span>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">        
object o = </span>
          </span>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">HttpContext.Current.Session[<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"MySessionVar"</span>];</span>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <br />
         <font color="#0000ff">if</font>(o
== <font color="#0000ff">null</font>) <font color="#0000ff">return</font> 0;</span>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <br />
         <font color="#0000ff">return</font> (<font color="#0000ff">int</font>)o;<br />
      }<br />
      set<br />
      {<br />
         HttpContext.Current.Session[<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"MySessionVar"</span>] <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> value;<br />
      }<br />
   }<br />
}</span>
        </p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span>
              <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> Page_Load(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> sender,
EventArgs e)<br />
{<br />
TypedSession.MySessionVar += 1;<br />
}<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> Page_PreRender(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> sender,
EventArgs e)<br />
{<br />
Label1.Text <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> TypedSession.MySessionVar.ToString();<br />
}</span>
          </p>
        </span>
        <p>
Merk op dat bij de get-accessor eerst gekeken wordt of het object null is. Dit is
nodig omdat een int niet null mag zijn. Voor objecten waarvoor dat wel mag kun je
desondanks besluiten dat er een standaardwaarde moet zijn, bijvoorbeeld een nieuw
object.
</p>
        <p>
Deze methodiek werkt ook uitstekend voor de Request.QueryString collectie en meer
van dat soort collecties die je normaal gezien loosely typed gebruikt. Die zal je
niet zo snel centraliseren, omdat het juist op een bepaalde pagina van toepassing
is, maar daarmee strongly typed kunnen werken is nog steeds minder foutgevoelig. Bovendien
hoeft de ontwikkelaar niet te weten waar de data vandaan komt.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=bcaf8021-98e5-49f2-a104-cfa54b844971" />
      </body>
      <title>TIP: Centraliseer sessiedata</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,bcaf8021-98e5-49f2-a104-cfa54b844971.aspx</guid>
      <link>http://michiel.vanotegem.nl/2007/02/12/TIPCentraliseerSessiedata.aspx</link>
      <pubDate>Mon, 12 Feb 2007 10:40:18 GMT</pubDate>
      <description>&lt;p&gt;
Ik zie in code geregeld dat het Session object op allerlei plaatsen gebruikt wordt,
met name in pagina's en controls, als volgt:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Page_Load(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
EventArgs e)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Session[&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"MySessionVar"&lt;/span&gt;]
+= 1;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Page_PreRender(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
EventArgs e)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Label1.Text &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Session[&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"MySessionVar"&lt;/span&gt;].ToString();&lt;br&gt;
}&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Dit is om meerdere redenen niet aan te raden:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Omdat de collectie loosely typed is, is er geen compile-time check bij het benaderen
van de elementen in de collectie. Het is daarom heel makkelijk om een typfoutje te
maken, waardoor je tegen het verkeerde object aan praat.&lt;/li&gt;
&lt;li&gt;
Door elementen in het Session object te stoppen in de pagina, is er geen centrale
administratie van de namen (keys) die in gebruik zijn.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Je kunt beide zaken oplossen door een centraal object te maken waarmee je de elementen
in het Session-object benaderd, als volgt:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Strongly typed toegang tot Session-object.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt;&lt;font color=#0000ff&gt; static &lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; TypedSession&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;font color=#0000ff&gt;int&lt;/font&gt;&amp;nbsp;MySessionVar&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
object o =&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;HttpContext.Current.Session[&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"MySessionVar"&lt;/span&gt;];&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#0000ff&gt;if&lt;/font&gt;(o == &lt;font color=#0000ff&gt;null&lt;/font&gt;) &lt;font color=#0000ff&gt;return&lt;/font&gt; 0;&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#0000ff&gt;return&lt;/font&gt; (&lt;font color=#0000ff&gt;int&lt;/font&gt;)o;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpContext.Current.Session[&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"MySessionVar"&lt;/span&gt;] &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; value;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Page_Load(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
EventArgs e)&lt;br&gt;
{&lt;br&gt;
TypedSession.MySessionVar += 1;&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Page_PreRender(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
EventArgs e)&lt;br&gt;
{&lt;br&gt;
Label1.Text &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; TypedSession.MySessionVar.ToString();&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/span&gt; 
&lt;p&gt;
Merk op dat bij de get-accessor eerst gekeken wordt of het object null is. Dit is
nodig omdat een int niet null mag zijn. Voor objecten waarvoor dat wel mag kun je
desondanks besluiten dat er een standaardwaarde moet zijn, bijvoorbeeld een nieuw
object.
&lt;/p&gt;
&lt;p&gt;
Deze methodiek werkt ook uitstekend voor de Request.QueryString collectie en meer
van dat soort collecties die je normaal gezien loosely typed gebruikt. Die zal je
niet zo snel centraliseren, omdat het juist op een bepaalde pagina van toepassing
is, maar daarmee strongly typed kunnen werken is nog steeds minder foutgevoelig. Bovendien
hoeft de ontwikkelaar niet te weten waar de data vandaan komt.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=bcaf8021-98e5-49f2-a104-cfa54b844971" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,bcaf8021-98e5-49f2-a104-cfa54b844971.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</category>
      <category>Nederlands</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=9331c742-74d3-4ff5-a443-0d955e027d02</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,9331c742-74d3-4ff5-a443-0d955e027d02.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,9331c742-74d3-4ff5-a443-0d955e027d02.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=9331c742-74d3-4ff5-a443-0d955e027d02</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Deze fout schijnt nogal vaak voor te komen bij het installeren van Visual Studio 2005
SP1. Dit <a href="http://support.microsoft.com/kb/925336">knowledgebase artikel</a> vertelt
wat je eraan kunt doen.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=9331c742-74d3-4ff5-a443-0d955e027d02" />
      </body>
      <title>VS2005 SP1 fout bij installatie "Error 1718. File was rejected by digital signature policy"</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,9331c742-74d3-4ff5-a443-0d955e027d02.aspx</guid>
      <link>http://michiel.vanotegem.nl/2007/01/02/VS2005SP1FoutBijInstallatieError1718FileWasRejectedByDigitalSignaturePolicy.aspx</link>
      <pubDate>Tue, 02 Jan 2007 21:52:37 GMT</pubDate>
      <description>&lt;p&gt;
Deze fout schijnt nogal vaak voor te komen bij het installeren van Visual Studio 2005
SP1. Dit &lt;a href="http://support.microsoft.com/kb/925336"&gt;knowledgebase artikel&lt;/a&gt; vertelt
wat je eraan kunt doen.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=9331c742-74d3-4ff5-a443-0d955e027d02" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,9331c742-74d3-4ff5-a443-0d955e027d02.aspx</comments>
      <category>.NET</category>
      <category>Nederlands</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=897c85bc-63ea-43e0-9cdf-de1c79fbf3b0</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,897c85bc-63ea-43e0-9cdf-de1c79fbf3b0.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,897c85bc-63ea-43e0-9cdf-de1c79fbf3b0.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=897c85bc-63ea-43e0-9cdf-de1c79fbf3b0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Visual Studio 2005 SP1 is beschikbaar.
Het lost allerlei bugs op en biedt een aantal verbeteringen, waaronder<br /><span style="color: rgb(0, 0, 0);"><ul><li>
Nieuwe project types voor ASP.NET<br /></li><li>
Ondersteuning voor nieuwe processor types voor code generatie en profiling</li><li>
Integratie van Excel 2007 en Project 2007 met Team Foundation Server</li><li>
Ondersteuning voor Windows Embedded 6.0 platform en tools</li></ul>
Meer informatie is te vinden op de MSDN pagina <a href="http://msdn.microsoft.com/vstudio/support/vs2005sp1/default.aspx">Visual
Studio 2005 Service Pack 1 (SP1)</a>.</span><img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=897c85bc-63ea-43e0-9cdf-de1c79fbf3b0" /></body>
      <title>Visual Studio 2005 SP1 beschikbaar</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,897c85bc-63ea-43e0-9cdf-de1c79fbf3b0.aspx</guid>
      <link>http://michiel.vanotegem.nl/2006/12/18/VisualStudio2005SP1Beschikbaar.aspx</link>
      <pubDate>Mon, 18 Dec 2006 12:05:13 GMT</pubDate>
      <description>Visual Studio 2005 SP1 is beschikbaar. Het lost allerlei bugs op en biedt een aantal verbeteringen, waaronder&lt;br&gt;
&lt;span style="color: rgb(0, 0, 0);"&gt;
&lt;ul&gt;
&lt;li&gt;
Nieuwe project types voor ASP.NET&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
Ondersteuning voor nieuwe processor types voor code generatie en profiling&lt;/li&gt;
&lt;li&gt;
Integratie van Excel 2007 en Project 2007 met Team Foundation Server&lt;/li&gt;
&lt;li&gt;
Ondersteuning voor Windows Embedded 6.0 platform en tools&lt;/li&gt;
&lt;/ul&gt;
Meer informatie is te vinden op de MSDN pagina &lt;a href="http://msdn.microsoft.com/vstudio/support/vs2005sp1/default.aspx"&gt;Visual
Studio 2005 Service Pack 1 (SP1)&lt;/a&gt;.&lt;/span&gt;&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=897c85bc-63ea-43e0-9cdf-de1c79fbf3b0" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,897c85bc-63ea-43e0-9cdf-de1c79fbf3b0.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</category>
      <category>Development</category>
      <category>Nederlands</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=007a2b73-236d-4381-ba7b-91707903a8b4</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,007a2b73-236d-4381-ba7b-91707903a8b4.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,007a2b73-236d-4381-ba7b-91707903a8b4.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=007a2b73-236d-4381-ba7b-91707903a8b4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Microsoft heeft een security patch uitgebracht voor Visual Studio. Het "gat" in VS2005
wordt als kritiek beschouwd, dus is het heeeel verstandig de patch te installeren.
Zie voor meer informatie en download Microsoft <a href="http://www.microsoft.com/technet/security/Bulletin/MS06-073.mspx">Security
Bulletin MS06-073</a>.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=007a2b73-236d-4381-ba7b-91707903a8b4" />
      </body>
      <title>Critical Security Patch voor Visual Studio 2005</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,007a2b73-236d-4381-ba7b-91707903a8b4.aspx</guid>
      <link>http://michiel.vanotegem.nl/2006/12/13/CriticalSecurityPatchVoorVisualStudio2005.aspx</link>
      <pubDate>Wed, 13 Dec 2006 12:05:09 GMT</pubDate>
      <description>&lt;p&gt;
Microsoft heeft een security patch uitgebracht voor Visual Studio. Het "gat" in VS2005
wordt als kritiek beschouwd, dus is het heeeel verstandig de patch te installeren.
Zie voor meer informatie en download Microsoft &lt;a href="http://www.microsoft.com/technet/security/Bulletin/MS06-073.mspx"&gt;Security
Bulletin MS06-073&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=007a2b73-236d-4381-ba7b-91707903a8b4" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,007a2b73-236d-4381-ba7b-91707903a8b4.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</category>
      <category>Development</category>
      <category>Nederlands</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=36fde194-e731-45e1-945a-445f4c3004c2</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,36fde194-e731-45e1-945a-445f4c3004c2.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,36fde194-e731-45e1-945a-445f4c3004c2.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=36fde194-e731-45e1-945a-445f4c3004c2</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Kan met de Augustus CTP van <a href="http://msdn.microsoft.com/robotics/">Microsoft
Robotics Studio</a>. Zo te zien zijn er ook al heel wat (verkrijgbare) robots die
hiermee aan te sturen zijn... leuk speelgoed.
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=36fde194-e731-45e1-945a-445f4c3004c2" />
      </body>
      <title>Robots programmeren met .NET</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,36fde194-e731-45e1-945a-445f4c3004c2.aspx</guid>
      <link>http://michiel.vanotegem.nl/2006/08/24/RobotsProgrammerenMetNET.aspx</link>
      <pubDate>Thu, 24 Aug 2006 10:54:48 GMT</pubDate>
      <description>&lt;p&gt;
Kan met de Augustus CTP van &lt;a href="http://msdn.microsoft.com/robotics/"&gt;Microsoft
Robotics Studio&lt;/a&gt;. Zo te zien zijn er ook al heel wat (verkrijgbare) robots die
hiermee aan te sturen zijn... leuk speelgoed.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=36fde194-e731-45e1-945a-445f4c3004c2" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,36fde194-e731-45e1-945a-445f4c3004c2.aspx</comments>
      <category>.NET</category>
      <category>Development</category>
      <category>Nederlands</category>
    </item>
    <item>
      <trackback:ping>http://michiel.vanotegem.nl/Trackback.aspx?guid=36633846-2eca-40fe-9957-2859d8a244dc</trackback:ping>
      <pingback:server>http://michiel.vanotegem.nl/pingback.aspx</pingback:server>
      <pingback:target>http://michiel.vanotegem.nl/PermaLink,guid,36633846-2eca-40fe-9957-2859d8a244dc.aspx</pingback:target>
      <dc:creator>Michiel van Otegem</dc:creator>
      <wfw:comment>http://michiel.vanotegem.nl/CommentView,guid,36633846-2eca-40fe-9957-2859d8a244dc.aspx</wfw:comment>
      <wfw:commentRss>http://michiel.vanotegem.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=36633846-2eca-40fe-9957-2859d8a244dc</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <em>Updated August 13, 2006 to reflect Sander's comment.</em>
        </p>
        <p>
On my old blog (in Dutch) I commented that I thought the WindowsImpersonationContext
was clumsy and I wrote a replacement that you can use as follows:
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Console.WriteLine(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Current
user: "</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> WindowsIdentity.GetCurrent().Name);<br />
WrapperImpersonationContext context <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> WrapperImpersonationContext(domain,
username, password);<br />
context.Enter();<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//
Execute code under other uses context</span><br />
Console.WriteLine(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Current
user: "</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> WindowsIdentity.GetCurrent().Name);<br />
context.Leave();<br />
Console.WriteLine(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Current
user: "</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> WindowsIdentity.GetCurrent().Name);</span>
        </p>
        <p>
Recently a visitor noted that the code wasn't quite right (missng a view using statements,
and I found some other small issues. The correct code (including namespace references)
is below. It takes care of all that nasty calls into the Win32 API. The one thing
you need to be aware of is that it requires permissions to call into a DLL (i.e. run
unsafe code), which is why I added the attributes that indicate this. Unfortunately
that renders this class useless in a hosted environment, unless you strong sign the
assembly and pursuade the host to allow your assembly to run in Full or High
trust. This however is a problem you will run into regardless your use of this class.
As soon as you call LogonUser you need at least High trust. If this is something that
should be possible under lower trust by default it's up to the folks in Redmond to
add this functionality to .NET and handle it as such.
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">using</span> System;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">using</span> System.Runtime.InteropServices;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">using</span> System.Security.Principal;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">using</span> System.Security.Permissions;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">using</span> System.ComponentModel;<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">class</span> WrapperImpersonationContext<br />
{<br />
   [DllImport(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"advapi32.dll"</span>,
SetLastError <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">true</span>)]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">extern</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">bool</span> LogonUser(String
lpszUsername, String lpszDomain,<br />
   String lpszPassword, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> dwLogonType, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> dwLogonProvider, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ref</span> IntPtr
phToken);<br /><br />
   [DllImport(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"kernel32.dll"</span>,
CharSet <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> CharSet.Auto)]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">extern</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">bool</span> CloseHandle(IntPtr
handle);<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> LOGON32_PROVIDER_DEFAULT <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> LOGON32_LOGON_INTERACTIVE <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 2;<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> m_Domain;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> m_Password;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> m_Username;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
private</span> IntPtr m_Token;<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
private</span> WindowsImpersonationContext m_Context <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">null</span>;</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
protected</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">bool</span> IsInContext<br />
   {<br />
      get { <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span> m_Context
!<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">null</span>;
}<br />
   }<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
public</span> WrapperImpersonationContext(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> domain, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> username, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> password)<br />
   {<br />
      m_Domain <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> domain;<br />
      m_Username <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> username;<br />
      m_Password <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> password;<br />
   }<br /><br />
   [PermissionSetAttribute(SecurityAction.Demand, Name <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"FullTrust"</span>)]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> Enter()<br />
   {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
if</span> (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>.IsInContext) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span>;<br />
      m_Token <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> IntPtr(0);<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">      try</span><br />
      {<br />
         m_Token <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> IntPtr.Zero;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">        
bool</span> logonSuccessfull <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> LogonUser(<br />
            m_Username,<br />
            m_Domain,<br />
            m_Password,<br />
            LOGON32_LOGON_INTERACTIVE,<br />
            LOGON32_PROVIDER_DEFAULT,<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">           
ref</span> m_Token);<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">        
if</span> (logonSuccessfull == <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">false</span>)<br />
         {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">           
int</span> error <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Marshal.GetLastWin32Error();<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">           
throw</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> Win32Exception(error);<br />
         }<br />
         WindowsIdentity identity <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> WindowsIdentity(m_Token);<br />
         m_Context <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> identity.Impersonate();<br />
      }<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
catch</span> (Exception exception)<br />
      {<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">        
// Catch exceptions here</span><br />
      }<br />
   }<br /></span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
[PermissionSetAttribute(SecurityAction.Demand, Name <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"FullTrust"</span>)]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> Leave()<br />
   {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">      
if</span> (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>.IsInContext
== <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">false</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span>;<br />
       m_Context.Undo();<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">      
if</span> (m_Token !<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> IntPtr.Zero)
CloseHandle(m_Token);<br />
       m_Context <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">null</span>;<br />
   }<br />
}</span>
        </p>
        <p>
 
</p>
        <img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=36633846-2eca-40fe-9957-2859d8a244dc" />
      </body>
      <title>WindowsImpersonationContext made easy</title>
      <guid isPermaLink="false">http://michiel.vanotegem.nl/PermaLink,guid,36633846-2eca-40fe-9957-2859d8a244dc.aspx</guid>
      <link>http://michiel.vanotegem.nl/2006/07/07/WindowsImpersonationContextMadeEasy.aspx</link>
      <pubDate>Fri, 07 Jul 2006 19:18:44 GMT</pubDate>
      <description>&lt;p&gt;
&lt;em&gt;Updated August 13, 2006 to reflect Sander's comment.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
On my old blog (in Dutch) I commented that I thought the WindowsImpersonationContext
was clumsy and I wrote a replacement that you can use as follows:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Console.WriteLine(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Current
user: "&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; WindowsIdentity.GetCurrent().Name);&lt;br&gt;
WrapperImpersonationContext context &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; WrapperImpersonationContext(domain,
username, password);&lt;br&gt;
context.Enter();&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//
Execute code under other uses context&lt;/span&gt;
&lt;br&gt;
Console.WriteLine(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Current
user: "&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; WindowsIdentity.GetCurrent().Name);&lt;br&gt;
context.Leave();&lt;br&gt;
Console.WriteLine(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Current
user: "&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; WindowsIdentity.GetCurrent().Name);&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Recently a visitor noted that the code wasn't quite right (missng a view using statements,
and I found some other small issues. The correct code (including namespace references)
is below. It takes care of all that nasty calls into the Win32 API. The one thing
you need to be aware of is that it requires permissions to call into a DLL (i.e. run
unsafe code), which is why I added the attributes that indicate this. Unfortunately
that renders this class useless in a hosted environment, unless you strong sign the
assembly and pursuade the host to&amp;nbsp;allow your assembly to run in Full or High
trust. This however is a problem you will run into regardless your use of this class.
As soon as you call LogonUser you need at least High trust. If this is something that
should be possible under lower trust by default it's up to the folks in Redmond to
add this functionality to .NET and handle it as such.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Runtime.InteropServices;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Security.Principal;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Security.Permissions;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.ComponentModel;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; WrapperImpersonationContext&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; [DllImport(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"advapi32.dll"&lt;/span&gt;,
SetLastError &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;true&lt;/span&gt;)]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;extern&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; LogonUser(String
lpszUsername, String lpszDomain,&lt;br&gt;
&amp;nbsp;&amp;nbsp; String lpszPassword, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; dwLogonType, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; dwLogonProvider, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ref&lt;/span&gt; IntPtr
phToken);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; [DllImport(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"kernel32.dll"&lt;/span&gt;,
CharSet &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; CharSet.Auto)]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;extern&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; CloseHandle(IntPtr
handle);&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; LOGON32_PROVIDER_DEFAULT &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; LOGON32_LOGON_INTERACTIVE &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 2;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; m_Domain;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; m_Password;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; m_Username;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
private&lt;/span&gt; IntPtr m_Token;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
private&lt;/span&gt; WindowsImpersonationContext m_Context &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/span&gt;;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
protected&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; IsInContext&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; m_Context
!&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/span&gt;;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
public&lt;/span&gt; WrapperImpersonationContext(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; domain, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; username, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; password)&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Domain &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; domain;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Username &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; username;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Password &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; password;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; [PermissionSetAttribute(SecurityAction.Demand, Name &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"FullTrust"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Enter()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
if&lt;/span&gt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;.IsInContext) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m_Token &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; IntPtr(0);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Token &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; IntPtr.Zero;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
bool&lt;/span&gt; logonSuccessfull &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; LogonUser(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Username,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Domain,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Password,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOGON32_LOGON_INTERACTIVE,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOGON32_PROVIDER_DEFAULT,&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
ref&lt;/span&gt; m_Token);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
if&lt;/span&gt; (logonSuccessfull == &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;false&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
int&lt;/span&gt; error &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Marshal.GetLastWin32Error();&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; Win32Exception(error);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WindowsIdentity identity &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; WindowsIdentity(m_Token);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Context &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; identity.Impersonate();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
catch&lt;/span&gt; (Exception exception)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
// Catch exceptions here&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;/p&gt;
&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
[PermissionSetAttribute(SecurityAction.Demand, Name &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"FullTrust"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Leave()&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
if&lt;/span&gt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;.IsInContext
== &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;false&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Context.Undo();&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
if&lt;/span&gt; (m_Token !&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; IntPtr.Zero)
CloseHandle(m_Token);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Context &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://michiel.vanotegem.nl/aggbug.ashx?id=36633846-2eca-40fe-9957-2859d8a244dc" /&gt;</description>
      <comments>http://michiel.vanotegem.nl/CommentView,guid,36633846-2eca-40fe-9957-2859d8a244dc.aspx</comments>
      <category>.NET</category>
      <category>Development</category>
      <category>English</category>
    </item>
  </channel>
</rss>