<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>.Net Jonesie</title>
  <link rel="alternate" type="text/html" href="http://jonesie.net.nz/" />
  <link rel="self" href="http://jonesie.net.nz/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2012-01-01T11:31:18.212125-06:00</updated>
  <author>
    <name>Peter G Jones</name>
  </author>
  <subtitle>A simple programmers blog</subtitle>
  <id>http://jonesie.net.nz/</id>
  <generator uri="http://dasblog.info/" version="2.3.9074.18820">DasBlog</generator>
  <entry>
    <title>Found : Samoa’s lost day</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/12/31/FoundSamoasLostDay.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,ee64250e-c47a-4f0a-a1e6-34550b1dc553.aspx</id>
    <published>2011-12-31T14:11:51.884-06:00</published>
    <updated>2012-01-01T11:31:18.212125-06:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Last week, <a href="http://www.msnbc.msn.com/id/45825600/ns/technology_and_science-science/" target="_blank">Samoa
lost their Friday</a>, seemingly forever. This is a day they will never get back!  
</p>
        <p>
However, it turns out it has not ben lost at all.  The <a href="http://www.metservice.com/national/index" target="_blank">NZ
Met service</a> has found it in Christchurch next Wednesday.  
</p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Found--Samoaslos-t-day_7E82/Capture_1.png">
            <img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Capture" border="0" alt="Capture" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Found--Samoaslos-t-day_7E82/Capture_thumb_1.png" width="661" height="207" />
          </a>
        </p>
        <p>
I guess this is Samoa’s way of showing their support for Christchurch.  Thank
you Samoa!  
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=ee64250e-c47a-4f0a-a1e6-34550b1dc553" />
      </div>
    </content>
  </entry>
  <entry>
    <title>CruiseControl.Net Improved MSBuild Integration–a fix</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/11/08/CruiseControlNetImprovedMSBuildIntegrationaFix.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,f7cd6236-45b3-4ee9-9fad-513c0d79214a.aspx</id>
    <published>2011-11-07T20:37:53.171875-06:00</published>
    <updated>2011-11-07T20:37:53.171875-06:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
We are still using CruiseControl.Net.  My TFS bias hasn't been strong enough
to overcome my laziness… yet.  However, I we have changed the ccnet build to
use MSBuild for the bulk of the process.  The MSBuild project is then checked
into the solution  so we can maintain this with the code base.
</p>
        <p>
This means the output of the build is 99% MSBuild log.  The standard MSBuild
logger that ccnet uses, is, to say the least, pretty ugly.  Fortunately, there
is a <a href="http://confluence.public.thoughtworks.org/display/CCNETCOMM/Improved+MSBuild+Integration" target="_blank">better
logger created by Christian Rodemeyer</a>.  Unfortunately, this is a little buggy. 
Fortunately, the source code is provided.
</p>
        <p>
SO!  To cut a long story short, if you are using this logger and seeing this
error:
</p>
        <blockquote>
          <p>
            <font size="2" face="Courier New">MSBUILD : error MSB4015: The build stopped unexpectedly
because the "ReusableLogger" logger failed unexpectedly during shutdown. System.ArgumentException:
Illegal characters in path. at System.IO.Path.CheckInvalidPathChars(String path) at
System.IO.Path.GetDirectoryName(String path) at Rodemeyer.MsBuildToCCNet.MsBuildToCCNetLogger.WriteErrorsOrWarnings(XmlWriter
w, String type, IEnumerable list) at Rodemeyer.MsBuildToCCNet.MsBuildToCCNetLogger.WriteProject(XmlWriter
w, Project p) at Rodemeyer.MsBuildToCCNet.MsBuildToCCNetLogger.WriteLog(XmlWriter
w) at Rodemeyer.MsBuildToCCNet.MsBuildToCCNetLogger.Shutdown() at Microsoft.Build.Evaluation.ProjectCollection.ReusableLogger.Shutdown()
at Microsoft.Build.BackEnd.Logging.LoggingService.ShutdownLogger(ILogger logger)</font>
          </p>
        </blockquote>
        <p>
Then get the source for the logger from <a href="http://confluence.public.thoughtworks.org/download/attachments/6253/MsBuildToCCNet.zip?version=6" target="_blank">here</a> and
in the Logger.cs file, replace  WriteErrorsOrWarnings() with the following:
</p>
        <p>
 
</p>
        <p>
        </p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="kwrd">static</span>
            <span class="kwrd">void</span> WriteErrorsOrWarnings(XmlWriter
w, <span class="kwrd">string</span> type, IEnumerable list)</pre>
          <pre>    {</pre>
          <pre class="alt">
            <span class="kwrd">foreach</span> (ErrorOrWarningBase
ew <span class="kwrd">in</span> list)</pre>
          <pre>      {</pre>
          <pre class="alt">        w.WriteStartElement(type);</pre>
          <pre>        w.WriteAttributeString(<span class="str">"code"</span>,
ew.Code);</pre>
          <pre class="alt">        w.WriteAttributeString(<span class="str">"message"</span>,
ew.Text);</pre>
          <pre>
            <span class="kwrd">if</span> (ew.File != <span class="kwrd">null</span>)</pre>
          <pre class="alt">        {</pre>
          <pre>
            <span class="kwrd">string</span> dir
= <span class="str">"_unknown_"</span>;</pre>
          <pre class="alt">
            <span class="kwrd">string</span> name
= ew.File;</pre>
          <pre> </pre>
          <pre class="alt">
            <span class="kwrd">try</span>
          </pre>
          <pre>          {</pre>
          <pre class="alt">            dir = Path.GetDirectoryName(ew.File);</pre>
          <pre>          }</pre>
          <pre class="alt">
            <span class="kwrd">catch</span> {
}</pre>
          <pre> </pre>
          <pre class="alt">
            <span class="kwrd">try</span>
          </pre>
          <pre>          {</pre>
          <pre class="alt">            name = Path.GetFileName(ew.File);</pre>
          <pre>          }</pre>
          <pre class="alt">
            <span class="kwrd">catch</span> {
}</pre>
          <pre> </pre>
          <pre class="alt">          w.WriteAttributeString(<span class="str">"dir"</span>,
dir);</pre>
          <pre>          w.WriteAttributeString(<span class="str">"name"</span>,
name);</pre>
          <pre class="alt">          w.WriteAttributeString(<span class="str">"pos"</span>, <span class="str">"("</span> +
XmlConvert.ToString(ew.Line) + <span class="str">", "</span> + XmlConvert.ToString(ew.Column)
+ <span class="str">")"</span>);</pre>
          <pre>        }</pre>
          <pre class="alt">        w.WriteEndElement();</pre>
          <pre>      }</pre>
          <pre class="alt">    }</pre>
        </div>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <br />
Works for me <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Cru.Net-Improved-MSBuild-Integrationa-fi_D98D/wlEmoticon-smile_2.png" /><img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=f7cd6236-45b3-4ee9-9fad-513c0d79214a" /></div>
    </content>
  </entry>
  <entry>
    <title>Using System.DirectoryServices.AccountManagement</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/08/25/UsingSystemDirectoryServicesAccountManagement.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,dc186ed8-d361-4c34-9e80-33aedbd42a2a.aspx</id>
    <published>2011-08-25T16:02:33.23175-05:00</published>
    <updated>2011-08-25T16:02:33.23175-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
This week I’ve been creating some integration code between our web product (an ASP.Net
web forms app) and LDAP – or more specifically, Active Directory.  This involves
loading principals (groups and users) and OU’s from AD into our custom database and
updating them on a schedule.  
</p>
        <p>
In the past I have used System.DirectoryServices to do any work with AD, and this
has been, to say the least, not one of my favorite things in life to do. It seems
like the people who invented LDAP have brains that don’t work the same way as ‘normal’
geeks – at least, not the same way as me.
</p>
        <p>
So, I was very pleased to discover System.DirectoryServices.AccountManagent. 
This provides a higher level of abstraction over LDAP’s and makes the simple tasks
much simpler.  
</p>
        <p>
Firstly, you create a context.  I have some properties and a helper method for
this:
</p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="kwrd">private</span> ContextType
ContextType { get; set; }</pre>
          <pre>
            <span class="kwrd">private</span>
            <span class="kwrd">string</span> OU
{ get; set; }</pre>
          <pre class="alt">
            <span class="kwrd">private</span>
            <span class="kwrd">string</span> DomainOrMachineName
{ get; set; }</pre>
          <pre>
            <span class="kwrd">private</span>
            <span class="kwrd">string</span> UserDName
{ get; set; }</pre>
          <pre class="alt">
            <span class="kwrd">private</span>
            <span class="kwrd">string</span> Password
{ get; set; }</pre>
          <pre> </pre>
          <pre class="alt">
            <span class="kwrd">private</span> PrincipalContext
CreateContext()</pre>
          <pre>{</pre>
          <pre class="alt">
            <span class="kwrd">if</span> (<span class="kwrd">this</span>.UserDName
!= <span class="kwrd">null</span> &amp;&amp; <span class="kwrd">this</span>.Password
!= <span class="kwrd">null</span>)</pre>
          <pre>  {</pre>
          <pre class="alt">
            <span class="kwrd">return</span>
            <span class="kwrd">new</span> PrincipalContext(<span class="kwrd">this</span>.ContextType, <span class="kwrd">this</span>.DomainOrMachineName, <span class="kwrd">this</span>.OU,
ContextOptions.SimpleBind, <span class="kwrd">this</span>.UserDName, <span class="kwrd">this</span>.Password);</pre>
          <pre>  }</pre>
          <pre class="alt">
            <span class="kwrd">else</span>
          </pre>
          <pre>  {</pre>
          <pre class="alt">
            <span class="kwrd">return</span>
            <span class="kwrd">new</span> PrincipalContext(<span class="kwrd">this</span>.ContextType, <span class="kwrd">this</span>.DomainOrMachineName, <span class="kwrd">this</span>.OU);</pre>
          <pre>  }</pre>
          <pre class="alt">}</pre>
        </div>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <p>
ContextType is an enum of Machine, Domain or ApplicationDirectory.  For a simple
domain AD you want Domain.  ApplicationDirectory is for AD LDS (what was once
called ADAM).
</p>
        <p>
The OU is the root OU you want to work with.
</p>
        <p>
UserDName is a user account’s distinguished name, eg: CN=Administrator,DC=domain,DC=com.
</p>
        <p>
The helper method will use the UserDName and Password if specified, otherwise it will
do a normal binding – using Negotiated credentials if available.  If you are
talking to a remote AD not in your local domain then you will probably need to use
the SimpleBind method – I found this the easiest.
</p>
        <p>
 
</p>
        <p>
To get a list of groups from a domain via this context is now trivial:
</p>
        <pre class="csharpcode">
          <span class="kwrd">using</span> (var pc = <span class="kwrd">this</span>.CreateContext())
{ var gp = <span class="kwrd">new</span> GroupPrincipal(pc, <span class="str">"*"</span>);
var ps = <span class="kwrd">new</span> PrincipalSearcher(gp); <span class="kwrd">foreach</span> (GroupPrincipal
g <span class="kwrd">in</span> ps.FindAll()) { Console.WriteLine(g.Name); } }</pre>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <p>
 
</p>
        <p>
This little snippet will output the names of the groups under the specified OU. 
However, it will only list the top level groups – not groups within groups. 
To do that, we need to get recursive.
</p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="kwrd">using</span> (var pc = <span class="kwrd">this</span>.CreateContext())</pre>
          <pre>{</pre>
          <pre class="alt">    var gp = <span class="kwrd">new</span> GroupPrincipal(pc, <span class="str">"*"</span>);</pre>
          <pre>    var ps = <span class="kwrd">new</span> PrincipalSearcher(gp);</pre>
          <pre class="alt"> </pre>
          <pre>
            <span class="kwrd">foreach</span> (GroupPrincipal
g <span class="kwrd">in</span> ps.FindAll())</pre>
          <pre class="alt">    {</pre>
          <pre>        Console.WriteLine(g.Name);</pre>
          <pre class="alt">        listNestedGroups(g, <span class="str">"-"</span>);</pre>
          <pre> </pre>
          <pre class="alt">    }</pre>
          <pre>}</pre>
          <pre class="alt"> </pre>
          <pre>
            <span class="kwrd">void</span> listNestedGroups(GroupPrincipal
gp, <span class="kwrd">string</span> indent) </pre>
          <pre class="alt">{</pre>
          <pre>
            <span class="kwrd">foreach</span>(var
p <span class="kwrd">in</span> gp.members)</pre>
          <pre class="alt">   {</pre>
          <pre>
            <span class="kwrd">if</span>(p <span class="kwrd">is</span> GroupPrincipal) <span class="rem">//
could also be a user</span></pre>
          <pre class="alt">     {</pre>
          <pre>          var g = p <span class="kwrd">as</span> GroupPrincipal;</pre>
          <pre class="alt">          Console.WriteLine(indent + g.Name);</pre>
          <pre>          listNestedGroups(g, indent + <span class="str">"-"</span>);</pre>
          <pre class="alt">      }</pre>
          <pre>   }</pre>
          <pre class="alt">}</pre>
        </div>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <p>
 
</p>
        <p>
You can use the same objects to create and manipulate LDAP entities similarly easily.
</p>
        <p>
Like all good things though, there’s a couple of issues.  When dealing with users,
I needed the middle name (Initials in AD).  The UserPrincipal includes a property
for this, but it comes through empty.  Luckily, it’s easy enough to fall back
to the old way of getting the extra properties.  The GetUnderlyingObject() method
returns the DirectoryEntry instance:
</p>
        <div class="csharpcode">
          <pre class="alt">var de = userPrincipal.GetUnderlyingObject() <span class="kwrd">as</span> DirectoryEntry;</pre>
          <pre> </pre>
          <pre class="alt">
            <span class="kwrd">if</span> (de
!= <span class="kwrd">null</span>)</pre>
          <pre>{</pre>
          <pre class="alt">  var lastChangeDates = de.Properties[<span class="str">"whenChanged"</span>];</pre>
          <pre>
            <span class="kwrd">if</span> (lastChangeDates
!= <span class="kwrd">null</span> &amp;&amp; lastChangeDates.Count == 1)</pre>
          <pre class="alt">  {</pre>
          <pre>    var lastChangeDate = (DateTime)lastChangeDates[0];</pre>
          <pre class="alt">    var initials = u.MiddleName;</pre>
          <pre>
            <span class="kwrd">if</span> (initials
== <span class="kwrd">null</span>)</pre>
          <pre class="alt">    {</pre>
          <pre>      var initialProps = de.Properties[<span class="str">"initials"</span>];</pre>
          <pre class="alt">
            <span class="kwrd">if</span> (initialProps
!= <span class="kwrd">null</span> &amp;&amp; initialProps.Count == 1)</pre>
          <pre>      {</pre>
          <pre class="alt">        initials = (<span class="kwrd">string</span>)initialProps[0];</pre>
          <pre>      }</pre>
          <pre class="alt">    }</pre>
          <pre>  }</pre>
          <pre class="alt">}</pre>
        </div>
        <p>
There’s a bunch of documentation on <a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.aspx" target="_blank">MSDN</a> for
this but I also found some code snippets on <a href="http://stackoverflow.com" target="_blank">StackOverflow</a>.
</p>
        <p>
Another useful tip, get the <a href="http://technet.microsoft.com/en-us/sysinternals/bb963907" target="_blank">SysInternals
AD Explorer</a>.  It shows you a lot more information that the User and Group
tool in AD.
</p>
        <p>
Enjoy!
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=dc186ed8-d361-4c34-9e80-33aedbd42a2a" />
      </div>
    </content>
  </entry>
  <entry>
    <title>I’m becoming less of a ‘softie</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/07/07/ImBecomingLessOfASoftie.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,a0642344-24df-428c-aac7-325de52a6849.aspx</id>
    <published>2011-07-07T15:43:02.621125-05:00</published>
    <updated>2011-07-07T15:43:02.621125-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
A month on from starting my new job I have noticed a few changes in my attitudes and
practices.  Working for an exclusively Microsoft shop in the past hadn’t given
me a completely closed minded attitude but it did remove opportunities to work with
other things.  What I have found since joining ARANZ is the that other options
tend to work quite well. 
</p>
        <p>
In particular, we use SVN for source control, Fogbugz for issue tracking and work
items and CruiseControl.Net for build automation.  This combination works well
enough for a small team and since the setup was already done a long time ago, I’ve
only had to tweak a few things in CCnet and learn how to use SVN.  In my previous
mind-set as a Microsoft zealot I would have said that complete integration was the
logical solution and TFS was the best product for dev teams.  I still believe
TFS is a great product but for the sort of work we do here and many other larger teams,
it’s really not necessary. In fact, I heard at a local user group meeting last night
that TradeMe use the same combination of SVN and Fogbugz.
</p>
        <p>
I guess what I’m trying to say is that I’m much more relaxed about using ‘lesser’
products and making do with a lower level of integration.  TFS is quite a heavy
product.  It provides some great benefits but at the cost of freedom and flexibility. 
Sure you can customize till the cows come home but the old adage of less is more applies
I think.  Monolithic, heavy weight beasts like TFS take time to learn and understand. 
Lightweight systems are much easier to understand and tweak – you just have to do
a little more of the lifting work yourself.
</p>
        <p>
 
</p>
        <p>
I’ve also come to notice a few things where Microsoft have dropped the ball. 
Actually, that’s being kind.  With Windows CE/Mobile/Embedded/whatevertheycallitthesedays
they have screwed up completely.  This is probably old news to most people but
I was blissfully unaware how shitty the situation is with mobile development. 
There is no tooling beyond Visual Studio 2008 unless you want to switch to Phone 7
and it’s useless for many business apps.  There is also no easy upgrade path
– it’s a complete rewrite for much of an application.
</p>
        <p>
I have my money on Phone 7 being a dead duck within 2 years due to the growth of Andriod
as a platform and Microsoft’s lack of haste and clarity.  Android works on many
types of devices, it’s development tools are fine and free and it’s already the most
popular for mobile devices.  Google also seems to have more of an emotional investment
in this area and I don’t get that feeling from Microsoft.  Thanks must go to
Apples for coming up with a UX that works on phones.  Everyone else that has
copied this has done well.  Microsoft’s attempt to do something different will
leave developers out on a limb with Steve Ballmer holding a saw at the trunk.
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=a0642344-24df-428c-aac7-325de52a6849" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Just next to the margarine…</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/06/19/JustNextToTheMargarine.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,e4badaac-d2e2-41e2-a215-53aa8c19156f.aspx</id>
    <published>2011-06-19T16:25:33.265-05:00</published>
    <updated>2011-06-19T16:25:33.265-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
When you work for a company that makes it’s own hardware, you get little surprises
sometimes.  I found this in our office refrigerator this morning:
</p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Just-next-to-the-margarine_8443/IMG_0506.jpg">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="IMG_0506" border="0" alt="IMG_0506" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Just-next-to-the-margarine_8443/IMG_0506_thumb.jpg" width="342" height="258" />
          </a>
        </p>
        <p>
It’s a camera undergoing a coldness test I guess.
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=e4badaac-d2e2-41e2-a215-53aa8c19156f" />
      </div>
    </content>
  </entry>
  <entry>
    <title>New OpenXMLDeveloper Site</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/06/15/NewOpenXMLDeveloperSite.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,1686136e-0777-4bf0-b028-1d30c34c48a7.aspx</id>
    <published>2011-06-14T20:56:48.046875-05:00</published>
    <updated>2011-06-14T20:56:48.046875-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
The long awaited upgrade to the <a href="http://openxmldeveloper.org/" target="_blank">OpenXMLDeveloper</a> site
is finally live.  I’m not a huge OpemXML developer myself but I do/did have an
interest in this site <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/New-OpenXmlDeveloper-site_C3A0/wlEmoticon-smile_2.png" /> 
This is a huge improvement over the previous site and hopefully it will be more valuable.
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=1686136e-0777-4bf0-b028-1d30c34c48a7" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Unified Version Numbering for Projects and Installers</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/06/09/UnifiedVersionNumberingForProjectsAndInstallers.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,539e51c5-9035-4f57-befc-841de974b44e.aspx</id>
    <published>2011-06-09T17:07:57.768625-05:00</published>
    <updated>2011-06-27T23:23:06.89925-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font size="2">Having a single unified version number across all assemblies in a product
has always been an issue for me and I suspect many others.  For some reason,
this has been a lot harder to achieve than it should.  I suspect the reason has
been more to do with me than the tools…</font>
        </p>
        <p>
          <font size="2">Anywho, this morning I managed to solve the problem for our product
and the new WIX based installer.  Here’s the steps I used.</font>
        </p>
        <p>
          <font size="2">Create AssemblyInfo files for the Company and Version.  I created
a CompanyAsseblyInfo.cs file that looks like this:</font>
        </p>
        <blockquote>
          <p>
            <font size="2" face="Courier New">using System.Reflection;<br />
using System.Runtime.InteropServices;</font>
          </p>
          <p>
            <font size="2" face="Courier New">[assembly: AssemblyCompany("ARANZ Medical Limited")]<br />
[assembly: AssemblyCopyright("Copyright © 2007")]<br />
[assembly: AssemblyTrademark("")]<br />
[assembly: AssemblyCulture("")]</font>
          </p>
        </blockquote>
        <p>
          <font size="2">And a VersionAssemblyInfo.cs file that looks like this:</font>
        </p>
        <blockquote>
          <p>
            <font size="2" face="Courier New">using System.Reflection;<br />
using System.Runtime.CompilerServices;<br />
using System.Runtime.InteropServices;</font>
          </p>
          <p>
            <font size="2">
              <font face="Courier New">[assembly: AssemblyVersion("3.0.*")]<br />
#if PocketPC || WindowsCE<br />
#else<br />
[assembly: AssemblyFileVersion("3.0")]<br />
#endif</font>
              <br />
            </font>
          </p>
        </blockquote>
        <p>
          <font size="2">I added these to a solution folder.</font>
        </p>
        <p>
          <font size="2">In each published project in the solution I add these files as a link:</font>
        </p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Unified-Version-Numbering-for-Projects-a_8AD6/image_2.png">
            <img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Unified-Version-Numbering-for-Projects-a_8AD6/image_thumb.png" width="434" height="366" />
          </a>
        </p>
        <p>
          <font size="2">Then I removed the duplicated entries from the project’s default AssemblyInfo.cs
file.</font>
        </p>
        <p>
          <font size="2">Now I have a single file containing the version number and company
information.  </font>
        </p>
        <p>
          <font size="2">WIX doesn’t used these files of course, but that’s not a problem thanks
to a <a href="http://wixfileversionext.codeplex.com/" target="_blank">nifty WIX Extension
I found on CodePlex</a>.  Simply reference this dll in your WIX project and update
your Product.wxs file like this:</font>
        </p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Unified-Version-Numbering-for-Projects-a_8AD6/image_4.png">
            <img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Unified-Version-Numbering-for-Projects-a_8AD6/image_thumb_1.png" width="439" height="149" />
          </a>
        </p>
        <p>
          <font size="2">Now whenever I do a build – either locally or on our build server –
all the assemblies and the installer will have the same internal version number. 
No need to futz around with MSBuild or CruiseControl tasks.  Of course, I still
need to manage the version number manually for major upgrades but our daily builds
in a sprint or iteration will be automatically incremented.</font>
        </p>
        <p>
          <font size="2">Enjoy!</font>
        </p>
        <p>
          <font size="2">Update: So it turns out the Visual Studio and MSBuild too I guess,
do not do a very good job of incrementing the build and revision numbers automatically. 
Some of the assemblies in the solution were being generated with a version number
of 3.0.0.0 despite the AssemblyVersionNumber being 3.0.*.  To get around this
required some work in CruiseControl.</font>
        </p>
        <p>
          <font size="2">Firstly, I created a VersionNumber.proj file in the solution that looks
like this:</font>
        </p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Unified-Version-Numbering-for-Projects-a_8AD6/image_6.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Unified-Version-Numbering-for-Projects-a_8AD6/image_thumb_2.png" width="520" height="249" />
          </a>
        </p>
        <p>
          <font size="2">This uses the MSBuild Community Tasks for it’s Version and FileUpdate
tasks.</font>
        </p>
        <p>
          <font size="2">Next, I updated the CruiseControl config to use MSBuild to execute
this script prior to building the solution:</font>
        </p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Unified-Version-Numbering-for-Projects-a_8AD6/image_8.png">
            <font size="2">
              <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Unified-Version-Numbering-for-Projects-a_8AD6/image_thumb_3.png" width="516" height="109" />
            </font>
          </a>
        </p>
        <p>
          <font size="2">Lastly, I installed MSBuild Community tasks to the build server and
restarted CruiseControl.  For some reason it was not able to find the .targets
file in the MSBuild directory to I copied this to the working folder also.</font>
        </p>
        <p>
          <font size="2">This is such a drag, but at least it now works and I still have a single
place to update the version number.</font>
        </p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=539e51c5-9035-4f57-befc-841de974b44e" />
      </div>
    </content>
  </entry>
  <entry>
    <title>WIX Tutorial Update</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/06/08/WIXTutorialUpdate.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,df46e8ff-e96e-411a-af2b-56cf810dc687.aspx</id>
    <published>2011-06-08T15:53:39.549875-05:00</published>
    <updated>2011-06-08T15:53:39.549875-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I rely heavily on the <a href="http://wix.tramontana.co.hu/" target="_blank">WIX tutorial
site</a> when ever I need to create an installer.  It’s not something I do every
day of the week so the tutorial site is essential to me.  Over the last week
I’ve been using it a lot but there’s been a few problems with the site and the server
(500 errors etc).
</p>
        <p>
This morning, to my surprise, the site has been updated and moved to a new server. 
It has a new look, it seems quicker and best of all, there are no more errors <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/WIX-Tutorial-Update_7C27/wlEmoticon-smile_2.png" />.
</p>
        <p>
To all the people that contribute to this site and it’s content – which is totally
advertisement free! – I thank you for saving my life many times over the years. 
Keep it up!
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=df46e8ff-e96e-411a-af2b-56cf810dc687" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Log4Net Configuration &amp; Schema</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/06/08/Log4NetConfigurationSchema.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,c4940298-f52c-41d4-b2ee-38506148af70.aspx</id>
    <published>2011-06-08T15:30:45.22175-05:00</published>
    <updated>2011-06-08T15:30:45.22175-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I don’t often use log4net – at least, I use it on just about every project but I only
set it up once every few months – so remembering the schema for the configuration
is a drag.  Thankfully, a generous geek has created a schema for the config. 
You can get it <a href="http://csharptest.net/downloads/schema/log4net.xsd" target="_blank">here</a>.
</p>
        <p>
After you download it, copy it to your Visual Studio Schemas folder.  For VS
08 this is C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas.  For 2010,
it’s probably C:\Program Files\Microsoft Visual Studio 10.0\Xml\Schemas.
</p>
        <p>
Then with your web.config/app.config open in VS, view the properties and set the schema
to include this.  
</p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Log4Net-Configuration--Schema_7745/image_2.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Log4Net-Configuration--Schema_7745/image_thumb.png" width="244" height="59" />
          </a>
        </p>
        <p>
No need to restart VS, it will automatically detect the new schema in the folder.
Intellisense will then tell you all you need to know.
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=c4940298-f52c-41d4-b2ee-38506148af70" />
      </div>
    </content>
  </entry>
  <entry>
    <title>A week into it</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/06/06/AWeekIntoIt.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,09bf94d8-008b-4be8-97f6-c30228b02056.aspx</id>
    <published>2011-06-06T00:58:44.03425-05:00</published>
    <updated>2011-06-06T00:58:44.03425-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ve had one full week with my new employer, ARANZ Medical.  So far so good. 
Compared to many 1st week’s I’ve had (and there have been a few of them!) it went
surprising smoothly and I felt useful from day 1.  My orientation lasted about
2 hours then I was into finding my way around the development environment and code
base, then some bug fixes.   A bit of ASP.Net web forms, some Silverlight
and some Windows Mobile.  By Friday I was creating new features and I’m in the
process of reimplementation of an installer using WIX.
</p>
        <p>
I’ve also had a week to compare the differences between a service company and a product
company.  Firstly the advantages.
</p>
        <ol>
          <li>
No time tracking.  Accounting for every 6 minutes of the day becomes second nature
after a while and I hope to retain some of my internal prioritisation that this gave
me, but I believe it is unrealistic to impose constant pressure on developers and
expect quality code.  There has to be some leeway for experimentation and time
for a brain to work.</li>
          <li>
Second chances.  The chance to upgrade a product means you get an opportunity
to improve things.  The constant merry go round of projects in a services company
seldom allows for version 2 and many customers have the unrealistic expectation that
we could deliver the perfect solution on the first attempt.  This situation was
often initiated by sales people and left to the developers and project managers to
refactor fantasy into reality.</li>
          <li>
Creativity encouraged.   Finding new an interesting applications for a technology
and product creates opportunities and opens new markets.  The focus with a service
company is on delivering exactly what the custom is paying for an not a gram more. 
NO GOLD PLATING!  With a product you want shiny stuff, but of course, there is
still a budget to worry about – it just takes the form of a backlog rather than a
sum of money.</li>
        </ol>
        <p>
There are a couple of specific advantages in my particular situation:
</p>
        <ol>
          <li>
No SharePoint.  I’ve said it before but now I can say it without worrying about
upsetting sales people.  SharePoint is a shit development environment. 
It’s a great platform as long as you keep things simple.  I’ve been guilty of
over complicating things from time to time, but with SharePoint you have no choice
– it’s too complicated for the small things and too large to be simple.</li>
          <li>
My own desk. I don’t want to ruffle feathers but someone has to say something. 
It was a stupid idea to start with.  Putting all your developers together on
long benches does not improve communication and productivity. Everyone I spoke to
hates the idea and the feedback from other offices is the same.  Justification
for this stupidity can only be financial because it makes no sense any other way.</li>
        </ol>
        <p>
There are of course disadvantages to a product company when compared to a services
company:
</p>
        <ol>
          <li>
Same same.  The product is what we work on.  One product at a time. 
For months or years.  In a service company you get to work on many projects a
year – sometimes you like ‘em, sometimes you hate ‘em.  The variety keeps you
going but it also wears you out.</li>
          <li>
Less opportunity? Yes and no.  Not sure yet but I’m assuming that people stay
around longer so there is less movement.  In my particular case, I’m happy with
this.  I’ve reached the stage in my career (life?) where I’m happy to do what
I do best.  I’d like to do more but I really don’t want the extra stress that
often goes with extra responsibility.  
</li>
        </ol>
        <p>
That is my impression after one week.  It will be interesting to see what else
pops up after a few more.
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=09bf94d8-008b-4be8-97f6-c30228b02056" />
      </div>
    </content>
  </entry>
  <entry>
    <title>OMG! WTF? LMAO</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/05/31/OMGWTFLMAO.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,d68212e6-4689-4894-ac8a-fe7104e329d5.aspx</id>
    <published>2011-05-31T15:59:11.37925-05:00</published>
    <updated>2011-05-31T15:59:11.37925-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
If I was a vegetarian I would be insulted.  As a carnivore I feel embarrassed. 
Either way, this is classic.
</p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/Windows-Live-Writer/OMG-WTF-LMAO_7DF9/image_2.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/OMG-WTF-LMAO_7DF9/image_thumb.png" width="615" height="391" />
          </a>
        </p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=d68212e6-4689-4894-ac8a-fe7104e329d5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Sigh … Umbraco &amp; Orchard Experimentation</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/05/29/SighUmbracoOrchardExperimentation.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,4f02228e-ac96-4478-becf-881cbe3995e9.aspx</id>
    <published>2011-05-29T05:45:55.394875-05:00</published>
    <updated>2011-05-29T05:45:55.394875-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today I spent a little time trying to setup an Intranet at home.  Using the Web
Platform installer it’s a snap to select, download and install a veritable plethora
of CMS and other tools and platforms.
</p>
        <p>
I decided to have a go with Orchard.  Why?  Because it’s new and cool and
uses MVC 3.  Of course, I would expect some issues and challenges but it’s been
around for a few months and reached version 1.1 so, what could possibly go wrong? 
Well, I was working my way through adding a few modules and trying to understand how
layers, content types, content parts etc fitted together to make a web site. 
Then bam!  Object reference not set errors.  I had installed a module that
was less than stable.  So much for that.  I couldn’t uninstall.  All
I could do was scratch it and start again.
</p>
        <p>
Second attempt, lets try something a bit more mature, Umbraco 4.7.  The download
and install is very slick, 5 steps, select a starter kit, wait for it to download
and install.  BAM!  Timeout.  Hmm, try refreshing the page and it seemed
to carry on ok. Double BAM!!  Table not found!  Crap.  Delete folder,
try again.  This time, no timeout, but BAM!  Table not found!  For
F’s sake!  Taking a look around the forums I find that yes, using the Personal
or Business starter kits with SQL CE there is a bug in the SQL code.  This is
very lame!  4.7 has been out for a while.  This is supposed to be a professional
OS product.
</p>
        <p>
So, back to plan A.  I think I’ll create an intranet myself using Visual Studio
and MVC 3.  At least then I wont have to rely on others… I can make my own mistakes
and fix them straight away.
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=4f02228e-ac96-4478-becf-881cbe3995e9" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Entity Framework 4.1</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/05/29/EntityFramework41.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,c33c2194-d90a-4d8f-a4e6-dc952210a282.aspx</id>
    <published>2011-05-29T05:32:25.769875-05:00</published>
    <updated>2011-05-29T05:32:25.769875-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <category term="SQL" label="SQL" scheme="http://jonesie.net.nz/CategoryView,category,SQL.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ve started work on a personal project and I’ve decided to use Entity Framework 4
– 4.1 actually – despite a lot of pain in a recent project.  
</p>
        <p>
Previously I used the <a href="http://visualstudiogallery.msdn.microsoft.com/df3541c3-d833-4b65-b942-989e7ec74c87" target="_blank">Entity
Designer Data Generation Pack</a>.  This is an extension you install from the
VS 2010 Extension Manager.  It gives you a much nicer experience when generating
the database schema.  You have a few more choices about how the database tables
are structured.  In particular, you can choose table per type or table per hierarchy. 
I quite like the table per hierarchy template especially when using inheritance. 
Without this, you can get some silly empty tables. 
</p>
        <p>
Anyways, since SP1 and EF 4.1, the <a href="http://visualstudiogallery.msdn.microsoft.com/df3541c3-d833-4b65-b942-989e7ec74c87" target="_blank">Entity
Designer Data Generation Pack</a> does not work. <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-sadsmile" alt="Sad smile" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Entity-Framework-4.1_8573/wlEmoticon-sadsmile_2.png" /> There’s
a bit of discussion on the gallery site and a fix is coming soon.  
</p>
        <p>
I also found a link from here to <a href="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV314" target="_blank">project
Juneau</a>.  This looks really exciting and offers some very nice features such
as automatic database generation and synchronisation between database projects and
entity models.  
</p>
        <p>
However!  I cant help thinking that this and the EF are very elegant tools that
solve a problem we shouldn’t be having.  That is, object persistence.  In
the ideal world I would like to create an application that is composed of objects
and have these persisted for me in some magic way that is efficient, scalable and
reliable.  I don’t want to know anything about SQL Server or even entity models
for that matter.  What’s wrong with having simple classes with a few attributes
to indicate some persistence?
</p>
        <p>
Of course, we don’t live in a perfect world.  This is why there will always be
a place for SQL Server, SharePoint  and Lawyers.  Juneau does remove a few
nasty steps and offers some nice features.  You should <a href="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV314" target="_blank">checkout
the video</a>.
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=c33c2194-d90a-4d8f-a4e6-dc952210a282" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Really Funcky HyperV VM Issue with XEON Core</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/05/23/ReallyFunckyHyperVVMIssueWithXEONCore.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,24236296-922a-43fa-89b3-16180af44523.aspx</id>
    <published>2011-05-22T20:53:14.091-05:00</published>
    <updated>2011-05-22T20:53:14.091-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’m deploying a Telligent Community site from our development staging VM to a properly
setup UAT site in preparation for go-live. The dev VM was running on my Dell Desktop
and shows up in the Computer Properties thusly:
</p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/WindowsLiveWriter/ReallyFunckyHyperVVMIssuewithXEONCore_C348/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://jonesie.net.nz/content/binary/WindowsLiveWriter/ReallyFunckyHyperVVMIssuewithXEONCore_C348/image_thumb.png" width="352" height="168" />
          </a>
        </p>
        <p>
On the official platform is shows up like this:
</p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/WindowsLiveWriter/ReallyFunckyHyperVVMIssuewithXEONCore_C348/image_4.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://jonesie.net.nz/content/binary/WindowsLiveWriter/ReallyFunckyHyperVVMIssuewithXEONCore_C348/image_thumb_1.png" width="355" height="175" />
          </a>
        </p>
        <p>
I installed the site as per the instructions from Telligent which basically involves
copy and paste and manual creation of a App Pool and Site in IIS.
</p>
        <p>
When I run the site on the official platform, I get the following error:
</p>
        <blockquote>
          <p>
HTTP Error 500.0 - Internal Server Error<br />
Calling LoadLibraryEx on ISAPI filter "c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll"
failed
</p>
        </blockquote>
        <p>
Right so, this is where confusion sets in.  The app pool is configured for .Net
2 so why is this error referring to a .Net 4 assebly?
</p>
        <p>
The event log has the following:
</p>
        <blockquote>
          <p>
ISAPI Filter 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll' could
not be loaded due to a configuration problem. <strong>The current configuration only
supports loading images built for a AMD64 processor architecture</strong>. blah blah…
</p>
        </blockquote>
        <p>
Ok, now this is clearly silly as it works fine on my machine and I didn’t build the
assemblies so there ain’t much I can do about it.
</p>
        <p>
Poking around in the App Pool settings I noticed this:
</p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/WindowsLiveWriter/ReallyFunckyHyperVVMIssuewithXEONCore_C348/image_6.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://jonesie.net.nz/content/binary/WindowsLiveWriter/ReallyFunckyHyperVVMIssuewithXEONCore_C348/image_thumb_2.png" width="299" height="56" />
          </a>
        </p>
        <p>
It’s turned off on both machines but I figured, what the heck, lets give it a try. 
Sure enough, setting Enable 32-bit applications to True fixes the problem on the UAT
server.
</p>
        <p>
I can only think this is a platform error – either it’s the different CPU or it could
be the edition of Windows Server.  Either way, it’s fixed and I’m filing this
nugget of wisdom for future reference.
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=24236296-922a-43fa-89b3-16180af44523" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Moving On Again</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/05/22/MovingOnAgain.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,7f15fef2-58ac-4632-91a3-816e9ba352f8.aspx</id>
    <published>2011-05-22T05:44:15.0285-05:00</published>
    <updated>2011-05-22T05:44:15.0285-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
It’s been a fun packed few years (5 to be precise) at <a href="http://www.intergen.co.nz" target="_blank">Intergen</a> but
the time has come for a change.  In a weeks time I will be starting with <a href="http://aranzmedical.com" target="_blank">ARANZ
Medical</a>.
</p>
        <p>
In the last five years I have worked on many exciting and fulfilling projects for
a great range of customers.  I can safely say, with hand on heart, that ALL of
the work was interesting &amp; rewarding and most of it was challenging and &amp;
fun.  Before I started at Intergen I had not done many web site projects (I can
probably count them on 2 fingers) but since then I’ve worked on dozens (if you count
SharePoint as <em>just a web site</em>).  I’ve worked on projects for small and
very large companies in NZ and elsewhere.  I spent 6 months in Sydney. 
I’ve been to a couple of TechEd’s in Auckland and a PDC in LA.  But most importantly,
I’ve worked with some extremely talented and fun people whom I will miss greatly.
</p>
        <p>
All good things must come to an end though, and hopefully something equally as good
comes along to replace it.  ARANZ Medical promises to be such a place. 
I’m not entirely sure what is in store for me but I’m excited about working for a
company with a product focus.  Its something I have always wanted to do and it’s
great to get the opportunity to do this for a company with such an interesting product
line.  It will also be nice to downsize a little to a company where I can possibly
make a difference.
</p>
        <p>
It’s interesting to see how companies work and change over time and as they grow. 
When I started at Intergen Christchurch I was the 12th employee I believe.  They
are now thrice this size and growing rapidly.  They have also moved offices three
times in the five years – only one of which was caused by a natural disaster! 
When I started, bespoke web site work was the norm for small-ish businesses and small
budgets. This has been replaced with much larger budgets, bigger customers and enterprise
scale projects spanning months rather than weeks.  
</p>
        <p>
All the best for the future Intergen.  I will remember you fondly <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Moving-On-Again_139FD/wlEmoticon-smile_2.png" /></p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=7f15fef2-58ac-4632-91a3-816e9ba352f8" />
      </div>
    </content>
  </entry>
  <entry>
    <title>WCF Security Madness</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/05/18/WCFSecurityMadness.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,2fa44e14-e798-4fba-b898-07a61a25cf23.aspx</id>
    <published>2011-05-18T16:12:52.6085-05:00</published>
    <updated>2011-05-18T16:12:52.6085-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’m working on some security cruff for WCF and SharePoint at present and I stumbled
across this gem:
</p>
        <blockquote>
          <p>
MessageSecurityVersion.WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10;
</p>
        </blockquote>
        <p>
Just rolls off the tongue don't it? Gotta love those Microsoft devs <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Madness_8119/wlEmoticon-smile_2.png" /></p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=2fa44e14-e798-4fba-b898-07a61a25cf23" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Earthquake 3.0</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2011/02/22/Earthquake30.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,422f0190-ba19-4333-8355-2b1b04604875.aspx</id>
    <published>2011-02-22T14:37:03.453125-06:00</published>
    <updated>2011-02-22T14:37:03.453125-06:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Here's my story of yesterdays earthquake here in Christchurch, before I forget and
to add some more personal detail to the limited news available via the media. 
</p>
        <p>
  
</p>
        <p>
When the quake struck I did the usual thing - I backed away from the desk and started
to consider weather I should get under it or not.  Unlike other shocks, it was
immediately apparent that I should hit the deck, which I did.  About  a
second later my window shattered and covered my desk with large chucks of glass.  
</p>
        <p>
  
</p>
        <p>
The initial hit didn't seem to last more than maybe 10 seconds and I guess the rolling
and tremors continued for a while afterwards, but I was too busy gathering my wallet,
glasses, keys etc. to notice.  A quick glance around the my colleagues confirmed
there were no injuries so while others were debating weather to stay or go I was gallantly
descending the fire escape as high speed. 
</p>
        <p>
  
</p>
        <p>
Out on the street the extent of the quake became immediately apparent.  There
was one person lying in the middle of the road, with a police man and others in attendance. 
A scaffold erected on the roof of a hotel (189 Hereford street) had collapsed and
was hanging precariously over the edge of the building threating to fall to the street. 
Many windows were broken and there was glass on the road. 
</p>
        <p>
  
</p>
        <p>
A few more decent shocks hit while we were gathering on the street and once we had
confirmed everyone had got out ok, we decided to head for Latimer Square, which was
the closest open space. 
</p>
        <p>
  
</p>
        <p>
My youngest daughter Deanna attends Unlimited school which is in the centre of the
city, less than a block from my work.  I had seen her about 20 minutes before
the quake and I knew she was returning to school so instead of heading to Latimer
Square I walked around the block to see if I could find her.  Mobile communication
by this stage was useless.  I did managed to get a 'U Ok?' text out to her, but
had no reply. My wife Trish and our older kids, Michelle and Robert were out of town
thankfully but communication with them was worse as they were in a rural area with
no cell phone services. 
</p>
        <p>
  
</p>
        <p>
Walking down Hereford and Manchester street I could see several piles of rubble. 
Some from previously damaged building but also some from buildings that had re-opened
from the September and Boxing day quakes.  Passing the Grand Chancellor Hotel
building in Cashel street, I could see several people standing at a broken window
and I initially wondered by they weren't getting out.  I then looked below then
I could see several large cracks in the support structures of the Hotel and looking
further there was an obvious lean on the whole building.  Clearly the escape
exits were blocked and these people were trapped. 
</p>
        <p>
  
</p>
        <p>
Turning around I checked the Westpac bank building which was heavily damaged in September. 
This looked ok. 
</p>
        <p>
  
</p>
        <p>
In the Cashel and High Street mall I found a large crowd, mostly of children from
the school.  There was a lot of emotion coming from the kids but also a constant
noise of breaking and falling glass. The whole area was particularly unsafe. 
I then notices the Link Centre arcade, which is the normal route I would take between
Hereford and High street.  This seemed have been badly damaged.  People
were being carried and dragged from the entrance, once of which was clearly unconscious
with blood around his mouth.  His rescuers were calling frantically for someone
who new CPR. 
</p>
        <p>
  
</p>
        <p>
  
</p>
        <p>
At this point in time, the situation got the better of me and I decided to do my bit
by calling out to everyone to get out of the city.  I acted like some crazed
fool for about 30 seconds.  Not my proudest moment but it passed when I realised
no-one was listening. However, people did start to head out of the area shortly after
and head for Latimer Square.  
</p>
        <p>
 
</p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:84E294D0-71C9-4bd0-A0FE-95764E0368D9:b77eef6a-4028-41d3-bc0a-4410b1d9d998" class="wlWriterEditableSmartContent">
          <a href="http://www.bing.com/maps/default.aspx?v=2&amp;cp=-43.53091~172.6429&amp;lvl=14&amp;style=r&amp;sp=aN.-43.53217_172.6384_Intergen_~aN.-43.53276_172.6376_Unlimited%2520School_~aN.-43.53245_172.6379_Link%2520Centre%2520Arcade_~aN.-43.53281_172.6423_CTV%2520Building_~aN.-43.53943_172.6451_CPIT%2520Carpark_~aN.-43.52506_172.6468_Carpark_&amp;mkt=en-us&amp;FORM=LLWR" id="map-34b0a6d2-2ea7-4ae8-a34f-ed175e90b87f" alt="View map" title="View map">
            <img src="http://jonesie.net.nz/content/binary/Windows-Live-Writer/Earthquake-3.0_7D8C/map-71f09b8a22d0.jpg" width="320" height="240" alt="Map picture" />
          </a>
        </div>
        <p>
  
</p>
        <p>
I still had not found Deanna but had received a text from asking if I was ok, but
without any details about where she was.  I followed along with the school kids
hoping she would turn up.  We soon reached the corner of Madras and Cashel streets
to discover the collapsed CTV building.  This was maybe 15 minutes after the
quake and it had collapsed.  There were a few policeman and other scrambling
over the 10 meter high pile of rubble that was earlier a seven story building. 
Flames had started to rise from one corner of this. 
</p>
        <p>
  
</p>
        <p>
          <img src="http://static2.stuff.co.nz/1298383341/191/4692191.jpg" />
        </p>
        <p>
We could not pass the CTV building on Madras street so instead walked up to Barbados
Street then back down Hereford to the square.  Amongst the many hundreds of people
gathered her managed to find some work makes but could still not find Deanna. 
One of the teachers from the school said that some kids had remained in the school
and Deanna was most likely one of these. 
</p>
        <p>
  
</p>
        <p>
Communication via mobile phone was next to impossible although some people seemed
to be getting through.  I tried many times to text and call anyone in my favourites
list but the combination of hundreds of people in one park doing the same, a crappy
iPhone and even crappier service from Vodafone meant that it was highly unlikely I
could get a message out. 
</p>
        <p>
So, after milling around for about thirty minutes I decided to try to return to the
school to see if I could find Deanna.  This proved futile as the police had blocked
the area due to leaking gas and falling buildings.  I couldn’t get closer than
two or three blocks from the school. My only other option was to check the car, hoping
that she had made her way there, but that also proved futile.
</p>
        <p>
Walking back to Latimer Square, I finally managed to get a text from Deanna to say
they had been evacuated to the CPIT car park on Moorehouse Avenue.  Another long
walk but finally I found her, 2 hours after the quake.  We gathered up two more
kids who needed transport and headed back to the car and home.  Driving north
through the city, the traffic was very heavy and there was some major damage to roads
and bridges, but nothing impassable.  The trip was slow until we reach the suburbs
but otherwise uneventful.  
</p>
        <p>
Reaching home we found no immediately obvious damage but the cats are noticeably unsettled. 
Power had been out but was restored.  Water is ok also.
</p>
        <p>
 
</p>
        <p>
Amongst the turmoil and emotion of the time, it is reassuring to see so many people
leap into action.  People appeared instantly to leap into damaged buildings,
perform CPR, direct traffic, move people around and generally start to make some order
from chaos.  While most people do there best to get out of trouble, others are
possessed with a level of heroism that the rest of us envy and admire.  In particular,
one of Deanna's school friends, a seventeen year, mature beyond his age, spent most
of the afternoon pulling bodies from damaged buildings.  
</p>
        <p>
As for the future – it remains indeterminate for a while.  I don’t see the City
being accessible for a week or two.  Power is out so I cant access any servers
at work.  Schools are closed for at least this week but as Deanna’s school is
in the city I’m not hopeful she will be back there for at least a month – one of there
older buildings was badly damaged.
</p>
        <p>
Challenging times.
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=422f0190-ba19-4333-8355-2b1b04604875" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Visual Studio 2010 Copy &amp; Paste Brokenness</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2010/12/23/VisualStudio2010CopyPasteBrokenness.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,0d2bd796-6bbd-4f39-bafd-c43172779af5.aspx</id>
    <published>2010-12-22T18:29:41.546875-06:00</published>
    <updated>2010-12-22T18:29:41.546875-06:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <category term="Visual Studio" label="Visual Studio" scheme="http://jonesie.net.nz/CategoryView,category,VisualStudio.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you’ve been using VS 2010 for anything more than a few minutes you have probably
had the clipboard issue – ie, copy and paste randomly breaks.  This is documented
on MS connect <a href="https://connect.microsoft.com/VisualStudio/feedback/details/554039/visual-studio-2010-clipboard-copy-and-cut-does-not-work">here</a> and
probably elsewhere.  
</p>
        <p>
The current recommendation is to install VS 2010 SP1 beta which I did this morning.
</p>
        <p>
Unfortunately this doesn't work for me.  I still get random errors, albeit slightly
different.  Now when I paste, the cursor moves back to what I had selected and
nothing is pasted.
</p>
        <p>
Happy days !
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=0d2bd796-6bbd-4f39-bafd-c43172779af5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>PowerShell Join-Path</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2010/12/21/PowerShellJoinPath.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,2643faac-8704-4b7f-9a00-8d628f4d4906.aspx</id>
    <published>2010-12-21T15:21:32.78125-06:00</published>
    <updated>2010-12-21T15:21:32.78125-06:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <category term="PowerShell" label="PowerShell" scheme="http://jonesie.net.nz/CategoryView,category,PowerShell.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Don’t use Join-Path in PowerShell if you are trying to compose paths for remote machines. 
I did this for creating SQL database file paths.  These must be relative to the
SQL server, which in my case, was remote. So, something like this fails miserably:
</p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/WindowsLiveWriter/PowerShellJoinPath_91AB/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://jonesie.net.nz/content/binary/WindowsLiveWriter/PowerShellJoinPath_91AB/image_thumb.png" width="526" height="71" />
          </a>
        </p>
        <p>
This is a bit silly really but I guess it’s useful sometimes.
</p>
        <p>
Instead, use [System.IO.Path]::Combine:
</p>
        <p>
          <a href="http://jonesie.net.nz/content/binary/WindowsLiveWriter/PowerShellJoinPath_91AB/image_4.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://jonesie.net.nz/content/binary/WindowsLiveWriter/PowerShellJoinPath_91AB/image_thumb_1.png" width="345" height="40" />
          </a>
        </p>
        <p>
HTH
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=2643faac-8704-4b7f-9a00-8d628f4d4906" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Thanks again Apple :(</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2010/07/20/ThanksAgainApple.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,94a2b090-fd26-464d-b14c-32f877002235.aspx</id>
    <published>2010-07-20T04:29:33.21225-05:00</published>
    <updated>2010-07-20T04:29:33.21225-05:00</updated>
    <category term="I Hate Apple" label="I Hate Apple" scheme="http://jonesie.net.nz/CategoryView,category,IHateApple.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
If your like me and made the mistake of upgrading your iPhone 3G to OS 4 then found
your phone is – to be blunt – fucked, you can actually reverse the update.
</p>
        <p>
See here for the story: 
</p>
        <p>
          <a href="http://www.stuff.co.nz/technology/gadgets/3937179/iPhone-3G-crippled-by-software-update">http://www.stuff.co.nz/technology/gadgets/3937179/iPhone-3G-crippled-by-software-update</a>
        </p>
        <p>
 
</p>
        <p>
See here for the remedy: 
</p>
        <p>
          <a href="http://www.lifehacker.com.au/2010/06/how-to-downgrade-from-ios-4-to-iphone-3-1-3/">http://www.lifehacker.com.au/2010/06/how-to-downgrade-from-ios-4-to-iphone-3-1-3/</a>
        </p>
        <p>
 
</p>
        <p>
Apple Score: Love – 0 , Hate - 5
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=94a2b090-fd26-464d-b14c-32f877002235" />
      </div>
    </content>
  </entry>
  <entry>
    <title>SharePoint 2010 Custom Timer Jobs</title>
    <link rel="alternate" type="text/html" href="http://jonesie.net.nz/2010/05/05/SharePoint2010CustomTimerJobs.aspx" />
    <id>http://jonesie.net.nz/PermaLink,guid,83274683-123b-47e3-b4f1-ee46d47fb318.aspx</id>
    <published>2010-05-05T16:56:27.690875-05:00</published>
    <updated>2010-05-05T16:56:27.690875-05:00</updated>
    <category term="General" label="General" scheme="http://jonesie.net.nz/CategoryView,category,General.aspx" />
    <category term="Sharepoint" label="Sharepoint" scheme="http://jonesie.net.nz/CategoryView,category,Sharepoint.aspx" />
    <author>
      <name>Peter</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ve been working on a sample app for SharePoint 2010 that demonstrates the Sync Framework,
Custom Service Applications and a Custom Timer.
</p>
        <p>
There’s a few good articles on <a href="http://msdn.microsoft.com/en-us/library/cc406686.aspx" target="_blank">MSDN</a> and <a href="http://www.andrewconnell.com/blog/articles/CreatingCustomSharePointTimerJobs.aspx" target="_blank">elsewhere</a> that
document the process of creating a custom timer job pretty well.  This hasn’t
changed much in 2010 – if at all – from what I can see.  However, the samples
don’t show you how to create a Service/Server level job definition, so here’s my small
addendum to show how to do this.
</p>
        <p>
          <strong>Creating a Service Job</strong>
        </p>
        <p>
When you construct a new job definition – custom or otherwise – there are two constructors
you use:
</p>
        <blockquote>
          <p>
protected SPJobDefinition(string name, SPWebApplication webApplication, SPServer server,
SPJobLockType lockType);
</p>
          <p>
protected SPJobDefinition(string name, SPService service, SPServer server, SPJobLockType
lockType);
</p>
        </blockquote>
        <p>
You can override the constructors in your custom job.  For a service timer you
should use the 2nd constructor.  In this case, the lockType can only be Job or
None.
</p>
        <p>
          <strong>Persisted Configuration</strong>
        </p>
        <p>
If you take a look at the definition of SPJobDefinition you will notice that it inherits
SPPersistedObject.  The MSDN sample talks about creating a separate persisted
object for the job configuration data.  This is not necessary.  Instead,
you can add your [Persisted] public fields directly to your custom job definition.
</p>
        <p>
          <strong>Errors</strong>
        </p>
        <p>
When you run a timer job that is created for a service, the service must be running
– yes, strangely :)  If it’s not the job will fail silently and you have to look
in the logs to see the error.  There doesn’t seem to be any way to catch this
exception.
</p>
        <p>
          <strong>Weirdness</strong>
        </p>
        <p>
I managed to waste about 3 hours trying to track down why timer execution of my service
method was failing when calling it directly would work.  There is no special
logic in the timer.  The bug I was seeing was something that I had fixed previously
so I was baffled why it was failing for the timer and not for my web page.
</p>
        <p>
Overnight, and after a few IISResets, redeployments and reboots, it came right and
now works correctly.  I also made sure the GAC was cleared out between deployments. 
It seems to me like there was an old version of the service application dll that the
timer was using and the rest of the site wasn’t.  I cant prove this but that’s
certainly how it appeared.
</p>
        <p>
          <strong>Debugging</strong>
        </p>
        <p>
As Andrew Connell points out in his articles, you need to fire an Assert() to get
the debugger to stop in the job Execute() method.  
</p>
        <blockquote>
          <p>
#if DEBUG<br />
            System.Diagnostics.Trace.Assert(false);<br />
#endif
</p>
        </blockquote>
        <p>
Attaching to OWTIMER.exe is not enough.  However, for me, this Assert does not
popup a message – you need to attached to OWTIMER first.  This maybe a SP or
VS 2010 thing.
</p>
        <p>
 
</p>
        <p>
Enjoy :)
</p>
        <img width="0" height="0" src="http://jonesie.net.nz/aggbug.ashx?id=83274683-123b-47e3-b4f1-ee46d47fb318" />
      </div>
    </content>
  </entry>
</feed>
