<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-23748967</id><updated>2012-02-16T19:55:23.032-06:00</updated><category term='ReSharper'/><category term='TDD'/><category term='eScrum'/><category term='IoC'/><category term='VisualStudio'/><category term='TFS'/><category term='Unity'/><category term='log4net'/><category term='TeamBuild'/><category term='LINQ to SQL'/><category term='Rhino Mocks'/><category term='recipes'/><category term='WPF'/><category term='Entity Framework'/><title type='text'>Agile .Net Adventures</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>27</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-23748967.post-4793148900590160983</id><published>2010-02-03T19:25:00.001-06:00</published><updated>2010-02-03T19:25:21.245-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Rhino Mocks'/><category scheme='http://www.blogger.com/atom/ns#' term='Entity Framework'/><category scheme='http://www.blogger.com/atom/ns#' term='TDD'/><title type='text'>Mocking Entity Framework ObjectSets</title><content type='html'>&lt;p&gt;After finally getting my head around &lt;a href="http://mocella.blogspot.com/2010/01/entity-framework-v4-object-graph.html" target="_blank"&gt;object-graph deletes in Entity Framework v4&lt;/a&gt;, I set about getting some better testing around my EF code.&amp;#160; The first step was updating my self-tracking entities template to have my object-sets be exposed as IObjectSets which involved a small tweak to my TT file.&lt;/p&gt;  &lt;p&gt;I ran into some challenges using a Rhino Mock of IObjectSet, so I let Google do some work for me and I landed on &lt;a href="http://devblog.petrellyn.com/" target="_blank"&gt;Jamie Phillip’s&lt;/a&gt; post about mocking IObjectSet via his &lt;a href="http://devblog.petrellyn.com/?p=189" target="_blank"&gt;MockObjectSet&lt;/a&gt;., which was exactly what I was looking for.&amp;#160; Adding this class into my test library got me 90% of where I wanted to be, but I still had compile errors on the spots where I was building out my object-graphs with “.Include(“”)” calls.&amp;#160; &lt;/p&gt;  &lt;p&gt;After some time digging through the EF4 code with &lt;a href="http://www.red-gate.com/products/reflector/" target="_blank"&gt;Reflector&lt;/a&gt;,&amp;#160; I was not finding what I thought I needed, an IObjectQuery interface, which would allow me to mock the Include method.&amp;#160; Again, I went back to Google and ran across a &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/categories" target="_blank"&gt;MSDN Forum&lt;/a&gt; post which &lt;a href="http://blogs.msdn.com/diego/" target="_blank"&gt;Diego Vega&lt;/a&gt; answered with an almost too obvious solution to my exact problem: &lt;a href="http://social.msdn.microsoft.com/Forums/en/adonetefx/thread/023ff3eb-c245-4ee8-94d8-4dbeaa071967" target="_blank"&gt;use an extension-method for Include&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Since I was only interested in mocking out the “Include” behavior, and have my &lt;a href="http://devblog.petrellyn.com/?p=189" target="_blank"&gt;MockOjectSet&lt;/a&gt; return my configured entity list, I went with Diego’s first suggestion for Include, which looks like this:&lt;/p&gt;  &lt;p&gt;public static IQueryable&amp;lt;T&amp;gt; Include&amp;lt;T&amp;gt;(this IQueryable&amp;lt;T&amp;gt; source, string path){   &lt;br /&gt;&amp;#160;&amp;#160; var objectQuery = source as ObjectQuery&amp;lt;T&amp;gt;;    &lt;br /&gt;&amp;#160;&amp;#160; if (objectQuery != null){    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return objectQuery.Include(path);    &lt;br /&gt;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160; return source;    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;The only pain point to this approach to testing, is that I’m stuck remembering that I need to add a new extension method whenever I utilize one of the methods in the &lt;a href="http://msdn.microsoft.com/en-us/library/bb349034.aspx" target="_blank"&gt;ObjectQuery&amp;lt;T&amp;gt;&lt;/a&gt; class – Union, Distinct, etc.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-4793148900590160983?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/4793148900590160983/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2010/02/mocking-entity-framework-objectsets.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/4793148900590160983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/4793148900590160983'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2010/02/mocking-entity-framework-objectsets.html' title='Mocking Entity Framework ObjectSets'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-9006762000253975145</id><published>2010-01-31T10:32:00.001-06:00</published><updated>2010-01-31T10:32:57.234-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='VisualStudio'/><category scheme='http://www.blogger.com/atom/ns#' term='log4net'/><title type='text'>Using log4net with .Net 4.0 WPF Applications</title><content type='html'>&lt;p&gt;I ran into some issues trying to get log4net up and running on my current project, which is being written in VS2010 Beta2, targeting the .net 4.0 framework.&amp;#160; I went about adding a reference to &lt;a href="http://logging.apache.org/log4net/" target="_blank"&gt;log4net&lt;/a&gt;, setup my app.config with a rolling log-file appender and added a call to XmlConfigurator.Configure() in one of my classes.&lt;/p&gt;  &lt;p&gt;I then went to compile and got the following error: &lt;font color="#ff0000"&gt;The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)&lt;/font&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;I double-checked, and yes, I had indeed added a reference to log4net, so what was wrong?&amp;#160; Turns out, for .net 4.0 WPF projects, the default Target Framework is the “.Net Framework 4 Client Profile”, which is a subset of the full framework with the goal of shrinking footprint of the .net framework needed to download for a typical windows application.&amp;#160; However, log4net apparently needs access to system.web.dll, which isn’t included in the client profile.&amp;#160; &lt;/p&gt;  &lt;p&gt;To fix your app so it’ll compile/run, open your project’s properties page, and set the Target Framework to “.Net Framework 4” and save your changes.&amp;#160; &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-9006762000253975145?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/9006762000253975145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2010/01/using-log4net-with-net-40-wpf.html#comment-form' title='25 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/9006762000253975145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/9006762000253975145'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2010/01/using-log4net-with-net-40-wpf.html' title='Using log4net with .Net 4.0 WPF Applications'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>25</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-6209112741304691886</id><published>2010-01-30T13:46:00.001-06:00</published><updated>2010-01-31T10:05:55.039-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Entity Framework'/><category scheme='http://www.blogger.com/atom/ns#' term='VisualStudio'/><title type='text'>Entity Framework v4 Object-Graph Deleting Quirks</title><content type='html'>&lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;Update&lt;/font&gt;&lt;/strong&gt;: &lt;a href="http://blogs.msdn.com/dsimmons/default.aspx" target="_blank"&gt;Danny&lt;/a&gt; was quick to respond with a &lt;a href="http://blogs.msdn.com/dsimmons/archive/2010/01/31/deleting-foreign-key-relationships-in-ef4.aspx" target="_blank"&gt;great explanation about how EF4 deals with object-graphs and deletes&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I’ve been getting up to speed on Entity Framework V4 (EF4) lately, for use in a WPF application that I’m working on.&amp;#160;&amp;#160; One of the issues I’m coming up against is removal of objects in one-to-many and many-to-many relationships.&amp;#160; It’s still not clear to me why things work the way they do in EF4, but I’ll lay out a few scenarios and talk about what works and what doesn’t work and hope that someone can later comment as to why things may not be working as I would expect.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Scenario 1&lt;/strong&gt;: A many-to-many relationship where the join table has its own primary key (an identity column in this case):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_9wmVJvGIiEM/S2SMbmYD96I/AAAAAAAADJg/Qk-ZT223iIA/s1600-h/image4.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_9wmVJvGIiEM/S2SMceI4HTI/AAAAAAAADJk/rf3shuEjUm8/image_thumb2.png?imgmax=800" width="644" height="261" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Given the following code, I’d expect to be able to remove an object from the Employee.ProjectAssignments collection and see that object removed from the database when I call SaveChanges on my ObjectContext:&lt;/p&gt;  &lt;p&gt;using (var context = new EFTestDBEntities()){    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var employeeGraph = (from e in context.Employees.Include(&amp;quot;ProjectAssignments&amp;quot;).Include(&amp;quot;ProjectAssignments.Project&amp;quot;) where e.ID == employeeID select e).FirstOrDefault();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (employeeGraph != null){     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var assignment = employeeGraph.ProjectAssignments.First();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; employeeGraph.ProjectAssignments.Remove(assignment); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; context.SaveChanges();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;When I hit the “SaveChanges()” call, I get the following exception:&lt;/p&gt;  &lt;p&gt;&lt;font size="1" face="Tahoma"&gt;System.InvalidOperationException: The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This strikes me as strange – I assume that I’ve indicated that the employee is no longer related to this project-assignment, so the object is essentially “worthless” and I’d expect it to be removed.&lt;/p&gt;  &lt;p&gt;In order to successfully remove this project-assignment, I had to do the following:&lt;/p&gt;  &lt;p&gt;using (var context = new EFTestDBEntities()){    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var employeeGraph = (from e in context.Employees.Include(&amp;quot;ProjectAssignments&amp;quot;).Include(&amp;quot;ProjectAssignments.Project&amp;quot;) where e.ID == employeeID select e).FirstOrDefault();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (employeeGraph != null){     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ProjectAssignment assignment = employeeGraph.ProjectAssignments.First();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; context.ProjectAssignments.DeleteObject(assignment); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; context.SaveChanges();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assert.AreEqual(0, employeeGraph.ProjectAssignments.Count);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;Okay, so if I “manually” delete the object by the explicit call to DeleteObject, things work.&amp;#160; So far so good, I can work with this.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Scenario 2&lt;/strong&gt;: A many-to-many relationship where the join table has a primary key that is composed by foreign-keys to the tables on either side of the relationship:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_9wmVJvGIiEM/S2SMcgQbp3I/AAAAAAAADJo/qKELJgFniQg/s1600-h/image%5B5%5D.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_9wmVJvGIiEM/S2SMdmRmMPI/AAAAAAAADJs/zt8654Xh6Qw/image_thumb%5B2%5D.png?imgmax=800" width="644" height="245" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;In this case, the code I’d expect to work, actually worked and allowed me to delete a class-schedule from a teacher:&lt;/p&gt;  &lt;p&gt;using (var context = new EFTestDBEntities()){    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var teacherGraph = (from t in context.Teachers.Include(&amp;quot;ClassSchedules&amp;quot;).Include(&amp;quot;ClassSchedules.Class&amp;quot;) where t.ID == teacherID select t).FirstOrDefault();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if(teacherGraph != null){     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var classSchedule = teacherGraph.ClassSchedules.First();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; teacherGraph.ClassSchedules.Remove(classSchedule); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; context.SaveChanges();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;Why does EF4 make a distinction in behavior between these two scenarios that are essentially the same operation yet one object-graph allows me to write what I naturally want to write (scenario 2), but not the other?&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Scenario 3&lt;/strong&gt;: A one-to-many relationship:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_9wmVJvGIiEM/S2SMecSlr2I/AAAAAAAADJ0/hV-AdxmF8Ns/s1600-h/image%5B10%5D.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_9wmVJvGIiEM/S2SMfP8m0PI/AAAAAAAADJ4/Vs7fwRe5FG4/image_thumb%5B5%5D.png?imgmax=800" width="644" height="352" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Once again, I tried to write the code in a way I’d expect to naturally work:&lt;/p&gt;  &lt;p&gt;using (var context = new EFTestDBEntities()){    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var orderGraph = (from o in context.Orders.Include(&amp;quot;OrderDetails&amp;quot;) where o.ID == orderID select o).FirstOrDefault();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if(orderGraph != null){     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var detail = orderGraph.OrderDetails.First();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; orderGraph.OrderDetails.Remove(detail); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; context.SaveChanges();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;And once again, I got the following exception:&lt;/p&gt;  &lt;p&gt;&lt;font size="1" face="Tah"&gt;System.InvalidOperationException: The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;As with&lt;strong&gt; scenario 1&lt;/strong&gt;, I had to write the following code to successfully remove the OrderDetail record:&lt;/p&gt;  &lt;p&gt;using (var context = new EFTestDBEntities()){    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var orderGraph = (from o in context.Orders.Include(&amp;quot;OrderDetails&amp;quot;) where o.ID == orderID select o).FirstOrDefault();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (orderGraph != null){     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var detail = orderGraph.OrderDetails.First();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; context.OrderDetails.DeleteObject(detail); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; context.SaveChanges();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;Alright, so I have managed to work around some of the quirks with EF4, but I really don’t understand why removal of objects in the object-graph don’t cause a proper remove/delete in some cases, yet work just as I expect in others.&amp;#160; &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-6209112741304691886?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/6209112741304691886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2010/01/entity-framework-v4-object-graph.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/6209112741304691886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/6209112741304691886'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2010/01/entity-framework-v4-object-graph.html' title='Entity Framework v4 Object-Graph Deleting Quirks'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_9wmVJvGIiEM/S2SMceI4HTI/AAAAAAAADJk/rf3shuEjUm8/s72-c/image_thumb2.png?imgmax=800' height='72' width='72'/><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-8283755448382540245</id><published>2009-08-29T14:25:00.001-05:00</published><updated>2009-08-29T14:25:18.401-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LINQ to SQL'/><title type='text'>LINQ to SQL SubmitChanges Order of Operations</title><content type='html'>&lt;p&gt;I did not realize the following is true in &lt;a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx" target="_blank"&gt;LINQ to SQL&lt;/a&gt;: Calling &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.submitchanges.aspx" target="_blank"&gt;SubmitChanges&lt;/a&gt; fires &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.linq.changeset.aspx" target="_blank"&gt;ChangeSet&lt;/a&gt; changes in the following order:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Inserts &lt;/li&gt;    &lt;li&gt;Updates &lt;/li&gt;    &lt;li&gt;Deletes &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Normally, this might not be a big deal, and you might never notice it, but it was the source of some pain on my current project.&lt;/p&gt;  &lt;p&gt;Consider an order-entry screen that allows the user to add/edit/delete line items on an order.&amp;#160; The order-detail records are keyed by order-number/line-number, and this is the source of the problem.&amp;#160; If the user deletes line #1 in the order, what was originally line #2 gets re-ordered as line #1.&amp;#160; When the user decides they are done editing the order, they will then hit the save button and the queued up add/edit/delete operations are committed via the LINQ to SQL SubmitChanges command.&lt;/p&gt;  &lt;p&gt;Fortunately, we were able to change the primary-key on our order-detail table, but we effectively lost some automatic data-integrity since we were previously able to ensure uniqueness on order-number/line-number.&amp;#160; For teams that don’t have the luxury of changing their database keys, this design decision by the LINQ to SQL team may be cause to move away from LINQ to SQL.&amp;#160; &lt;/p&gt;  &lt;p&gt;Why the LINQ to SQL team decided to not submit changes in the order of operations, or allow the user to specify a non-default order to submit changes is beyond me.&amp;#160; I’m sure they had valid reasons for this decision, but it’s a bit short-sighted in that this interaction pattern is fairly common in order-entry system.&amp;#160; &lt;/p&gt;  &lt;p&gt;This could perhaps been avoided by stamping various LINQ class members as virtual and letting us developers (consumers) override behaviors as we need – and assume the risks that come with overriding the framework code.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-8283755448382540245?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/8283755448382540245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/08/linq-to-sql-submitchanges-order-of.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/8283755448382540245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/8283755448382540245'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/08/linq-to-sql-submitchanges-order-of.html' title='LINQ to SQL SubmitChanges Order of Operations'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-6175946743165847805</id><published>2009-07-14T07:48:00.001-05:00</published><updated>2009-07-14T07:48:48.621-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LINQ to SQL'/><title type='text'>Linq to SQL Object Equality Issue</title><content type='html'>&lt;p&gt;I started having some issues where &lt;a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx" target="_blank"&gt;Linq to SQL&lt;/a&gt; objects are &amp;quot;different” instances between calls to db.&lt;a href="http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.gettable.aspx" target="_blank"&gt;GetTable&lt;/a&gt;(type) and comparing objects returned.&amp;#160; In the majority of my types, object equality was working just fine, but in a few types, the hash-codes for otherwise “equal” objects was different, while the remainder of the object data was as expected.&lt;/p&gt;  &lt;p&gt;Deleted the designer-objects and re-added to my DBML and the issue is resolved.&amp;#160; &lt;/p&gt;  &lt;p&gt;A compare of my DBML file shows that the “&lt;a href="http://msdn.microsoft.com/en-us/library/system.data.linq.mapping.columnattribute.isprimarykey.aspx" target="_blank"&gt;IsPrimaryKey&lt;/a&gt;” attribute on my Identity columns was missing.&amp;#160; I had probably added the table to the DBML and realized later that I hadn’t specified a primary key and later added said key, without re-synchronizing my DBML.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-6175946743165847805?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/6175946743165847805/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/07/linq-to-sql-object-equality-issue.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/6175946743165847805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/6175946743165847805'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/07/linq-to-sql-object-equality-issue.html' title='Linq to SQL Object Equality Issue'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-4545503771529343792</id><published>2009-05-16T07:49:00.002-05:00</published><updated>2009-05-18T09:17:21.196-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LINQ to SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='TDD'/><title type='text'>Mocking IQueryable</title><content type='html'>&lt;p&gt;On my current project, we’ve been pretty successful in mocking out all of our &lt;a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx" target="_blank"&gt;LINQ to SQL&lt;/a&gt; repository operations, with one exception.  One of our new methods returns an &lt;a href="http://msdn.microsoft.com/en-us/library/system.linq.iqueryable.aspx" target="_blank"&gt;IQueryable&lt;/a&gt; object.  No problem I think, I’ll just set an expectation on that call and return a list of the property entity type.  But that gives me a build-error that I can’t convert a List&amp;lt;T&amp;gt; to IQueryable&amp;lt;T&amp;gt;.  &lt;/p&gt;  &lt;p&gt;A quick &lt;a href="http://www.google.com/" target="_blank"&gt;google&lt;/a&gt; yields the simplest of solutions to mocking IQueryable: the “&lt;a href="http://msdn.microsoft.com/en-us/library/bb353734.aspx" target="_blank"&gt;AsQueryable&lt;/a&gt;” extension method.  So now, my mock expectation returns something like “List&amp;lt;T&amp;gt;.AsQueryable” and all is well.  This finding also clued me into a whole slew of interesting looking extension methods in the System.Linq namespace…..&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-4545503771529343792?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/4545503771529343792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/05/mocking-iqueryable.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/4545503771529343792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/4545503771529343792'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/05/mocking-iqueryable.html' title='Mocking IQueryable'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-8728729416458488816</id><published>2009-04-06T18:41:00.001-05:00</published><updated>2009-04-06T18:41:57.781-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LINQ to SQL'/><title type='text'>LINQ to SQL and Overriding .Equals = not a good idea.</title><content type='html'>&lt;p&gt;Short version: don’t override .Equals in your LINQ TO SQL entities, unless you really know what “equals” means to your objects!&lt;/p&gt;  &lt;p&gt;Long version: on my current project, we’re using &lt;a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx" target="_blank"&gt;LINQ to SQL&lt;/a&gt; for our ORM needs, and it’s been working pretty well for us so far.&amp;#160; Pretty well, except for late last week when we realized that we weren’t properly persisting a number of records in our object graph.&lt;/p&gt;  &lt;p&gt;We have a fairly complex object model, with some deep graphs of related objects, and have been using the .Add method to add child and grandchild objects into our “Order” object’s graph.&amp;#160; There was one particular “Child” record that was only being created one time per order, when we expected several variations of this child, yet only the first was being saved.&lt;/p&gt;  &lt;p&gt;Our object graphs were build correctly, SubmitChanges was doing its job, we weren’t getting any errors, and yet these records just weren’t making it to the database.&amp;#160; After a few conversations with other people that have some LINQ to SQL experience and me trying some of the ugliest hacks I could think of, it dawned on me to try testing another theory I had – create another order-detail that looked similar to an existing order-detail. &lt;/p&gt;  &lt;p&gt;Lo and behold, this similar order-detail also did not persist, and it was behaving like the other “exceptional” order-details – they were all in the object-graph, but not in the Insert Changes of my data-context!&amp;#160; Once I was able to see this, I took a closer look at the order-detail partial class we had written, and there I saw an overridden .Equals implementation.&amp;#160; Unfortunately, this .Equals was testing for property values within the order-detail to determine if a detail might match another detail instance, not testing for reference equality, which is evidently important to LINQ to SQL.&lt;/p&gt;  &lt;p&gt;So there you have it – when working with LINQ to SQL entities, take care in how you decide to utilize the .Equals method and how you decide to override it.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-8728729416458488816?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/8728729416458488816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/04/linq-to-sql-and-overriding-equals-not.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/8728729416458488816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/8728729416458488816'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/04/linq-to-sql-and-overriding-equals-not.html' title='LINQ to SQL and Overriding .Equals = not a good idea.'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-7562572575934659812</id><published>2009-03-07T12:19:00.001-06:00</published><updated>2009-03-07T12:21:37.411-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VisualStudio'/><title type='text'>Managing Environment Specific Configurations Settings at Install Time</title><content type='html'>&lt;p&gt;I’ve been asked a few times in the past few weeks about approaches for managing environment specific settings in config files.&amp;#160; Over the years, I’ve seen this solved a few different ways, and I tend to like the following approach: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Create a Setup project in your solution. &lt;/li&gt;    &lt;li&gt;Open the User Interface Editor, and add a 3-button dialog to the setup (right-click the Start folder and choose “Add Dialog” and pick the 3-button dialog option) &lt;/li&gt;    &lt;li&gt;Right-Click the newly added entry in the “Start” windows tree and select “Move Up”, so that this window is somewhere before the “Conform Install” dialog. &lt;/li&gt;    &lt;li&gt;Edit the Properties Window for the 3-buttons window to be something like the following: &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_9wmVJvGIiEM/SbK6uCaveeI/AAAAAAAABNs/rc0gSuSOLdM/s1600-h/SetupProject3Buttons%5B13%5D.jpg" target="_blank"&gt;&lt;img title="SetupProject3Buttons" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="386" alt="SetupProject3Buttons" src="http://lh3.ggpht.com/_9wmVJvGIiEM/SbK6urhyIEI/AAAAAAAABN0/pVCqVJQOVb0/SetupProject3Buttons_thumb%5B11%5D.jpg?imgmax=800" width="469" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;In your main project (UI, Console, etc), add an XML file for the environment specific settings.&amp;#160; The schema should be something like the following: &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;environments&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;      &lt;br /&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;environment &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;Development&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;setting &lt;/span&gt;&lt;span style="color: red"&gt;settingKeyPath&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;em&gt;&amp;lt;your xpath here..&amp;gt;&lt;/em&gt;&amp;quot; &lt;span style="color: red"&gt;propertyName&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&lt;em&gt;&amp;lt;your property here..&amp;gt;&lt;/em&gt;&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;propertyValue&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;em&gt;&amp;lt;your value here…&amp;gt;&lt;/em&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;      &lt;br /&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;environment&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;      &lt;br /&gt;…….repeat the environment section for each targeted environment&lt;/span&gt;&lt;span style="color: blue"&gt;      &lt;br /&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;environments&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;In your main project, add a new class and have it implement the “&lt;a href="http://msdn.microsoft.com/en-us/library/system.configuration.install.installer.aspx" target="_blank"&gt;Installer&lt;/a&gt;” class (found in System.Configuration.Install – so you’ll probably need to add a project reference to that assembly). &lt;/li&gt;    &lt;li&gt;Override OnAfterInstall, but make sure you first call base.OnAfterInstall(), then start the process of applying your settings from the XML file created earlier to the config file of your installing application. &lt;/li&gt;    &lt;li&gt;Your environment setting can be pulled from Context.Parameters[“ENVIRONMENT”] &lt;/li&gt;    &lt;li&gt;Write yourself some code to read in the data in the XML file, and overwrite the appropriate settings in the config file. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;That’s the basic steps I take to manage environment specific config file settings in my VisualStudio projects. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-7562572575934659812?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/7562572575934659812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/03/managing-environment-specific.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/7562572575934659812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/7562572575934659812'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/03/managing-environment-specific.html' title='Managing Environment Specific Configurations Settings at Install Time'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_9wmVJvGIiEM/SbK6urhyIEI/AAAAAAAABN0/pVCqVJQOVb0/s72-c/SetupProject3Buttons_thumb%5B11%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-7864350720331164532</id><published>2009-03-07T11:26:00.002-06:00</published><updated>2009-03-07T11:27:40.294-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VisualStudio'/><title type='text'>VS2008 Database Project Deployment Script Failures</title><content type='html'>&lt;p&gt;On my current project, we’re using a database project to allow us to manage our schema changes.  This has helped us keep all of our dev and build boxes in sync, and things are moving along smoothly.  &lt;/p&gt;  &lt;p&gt;However, there is one quirk that seems to burn me every few weeks.  When we have a script failure, I scan through the output window to see where things went wrong.  The IDE is even nice enough to let you click through to the failing line so you can figure out where things went wrong.&lt;/p&gt;  &lt;p&gt;That’s nice and all, but the script that gets opened is the deployment script, not the actual .sql file that you created earlier.  So, I end up making the change and rebuild/deploy only to get the same error, again.  By now, when I review the output and realize what I did, I locate the actual post-deployment script file and make my edits there, rebuild/deploy and things work just fine.&lt;/p&gt;  &lt;p&gt;How difficult would it have been to make the generated deployment script read-only so I wouldn’t keep getting burned by this quirk?  Better yet, why not take me to the actual script file that caused the problem in the first place?&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-7864350720331164532?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/7864350720331164532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/03/vs2008-database-project-deployment.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/7864350720331164532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/7864350720331164532'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/03/vs2008-database-project-deployment.html' title='VS2008 Database Project Deployment Script Failures'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-8102068993735031612</id><published>2009-02-19T08:57:00.001-06:00</published><updated>2009-02-19T09:04:02.942-06:00</updated><title type='text'>Pandora WTF</title><content type='html'>&lt;p&gt;I was sitting here jamming out to some &lt;a href="http://www.pandora.com" target="_blank"&gt;Pandora&lt;/a&gt; this morning, and wondered what song I was hearing, so I flipped over to my desktop to see &lt;a href="http://www.pandora.com/music/song/pantera/yesterday+dont+mean+sh" target="_blank"&gt;what was playing&lt;/a&gt; and I see this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_9wmVJvGIiEM/SZ1zdEXjJtI/AAAAAAAABMM/QRq8jVdERl8/s1600-h/PandoraPanteraWTF%5B3%5D.jpg"&gt;&lt;img title="PandoraPanteraWTF" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="198" alt="PandoraPanteraWTF" src="http://lh4.ggpht.com/_9wmVJvGIiEM/SZ1zdslokcI/AAAAAAAABMQ/JcgwrrrIvhA/PandoraPanteraWTF_thumb%5B1%5D.jpg?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;That’s the cover for Pantera’s &lt;a href="http://www.cduniverse.com/search/xx/music/pid/1096301/a/Reinventing+The+Steel.htm" target="_blank"&gt;Reinventing the Steel&lt;/a&gt; album?? &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-8102068993735031612?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/8102068993735031612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/02/pandora-wtf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/8102068993735031612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/8102068993735031612'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/02/pandora-wtf.html' title='Pandora WTF'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_9wmVJvGIiEM/SZ1zdslokcI/AAAAAAAABMQ/JcgwrrrIvhA/s72-c/PandoraPanteraWTF_thumb%5B1%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-6611435863319166405</id><published>2009-02-10T12:41:00.001-06:00</published><updated>2009-02-10T12:48:15.935-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>Responsive WPF Interfaces</title><content type='html'>&lt;p&gt;I had a bit of a challenge today while trying to get a WPF &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.progressbar.aspx" target="_blank"&gt;ProgressBar&lt;/a&gt; to send feedback to my UI while a long-running processes ran.&amp;#160; &lt;/p&gt;  &lt;p&gt;My first challenge was finding “that one property that lets the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.progressbar.aspx" target="_blank"&gt;ProgressBar&lt;/a&gt; animation run continuously” – &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.progressbar.isindeterminate.aspx" target="_blank"&gt;IsIndeterminate&lt;/a&gt;.&amp;#160; &lt;/p&gt;  &lt;p&gt;My next challenge was setting the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.progressbar.isindeterminate.aspx" target="_blank"&gt;IsIndeterminate&lt;/a&gt; property to true before firing off my long-running process.&amp;#160;&amp;#160; I remembered something about using the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.aspx" target="_blank"&gt;Dispatcher&lt;/a&gt;, but even using that didn’t reflect the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.progressbar.aspx" target="_blank"&gt;ProgressBar&lt;/a&gt; property changes to the UI.&amp;#160; I briefly considered trying an &lt;a href="http://www.codinghorror.com/blog/archives/000159.html" target="_blank"&gt;evil DoEvents&lt;/a&gt; type trick, but came to my senses before heading down that road.&lt;/p&gt;  &lt;p&gt;I landed on creating a delegate which I could invoke to fire off my long-running process, and it ended up looking something like this (forgive the crude method names, this was some spike code I was playing around with:&lt;/p&gt; &lt;div style="overflow: scroll"&gt;   &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private delegate void &lt;/span&gt;&lt;span style="color: #2b91af"&gt;UpdateProgressbarIndeterminateState&lt;/span&gt;(&lt;span style="color: blue"&gt;bool &lt;/span&gt;isEnabled);&lt;br /&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;CompareClick(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;RoutedEventArgs &lt;/span&gt;e){&lt;br /&gt;   Dispatcher.Invoke(&lt;span style="color: #2b91af"&gt;DispatcherPriority&lt;/span&gt;.Normal,&lt;br /&gt;      (&lt;span style="color: #2b91af"&gt;UpdateProgressbarIndeterminateState&lt;/span&gt;)&lt;br /&gt;         &lt;span style="color: blue"&gt;delegate&lt;/span&gt;(&lt;span style="color: blue"&gt;bool &lt;/span&gt;isIndeterminate){&lt;br /&gt;            progressBar.IsIndeterminate = isIndeterminate;&lt;br /&gt;         }, &lt;span style="color: blue"&gt;true&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;   &lt;span style="color: #2b91af"&gt;AsyncDelegate &lt;/span&gt;caller = PerformCompare;&lt;br /&gt;   caller.BeginInvoke(AfterCompareCallback, &lt;span style="color: blue"&gt;null&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;internal delegate void &lt;/span&gt;&lt;span style="color: #2b91af"&gt;AsyncDelegate&lt;/span&gt;();&lt;br /&gt;&lt;span style="color: blue"&gt;private static void &lt;/span&gt;PerformCompare() {&lt;br /&gt;   &lt;span style="color: #2b91af"&gt;DataComparer&lt;/span&gt;.Execute();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;protected void &lt;/span&gt;AfterCompareCallback(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;ar) {&lt;br /&gt;   Dispatcher.Invoke(&lt;span style="color: #2b91af"&gt;DispatcherPriority&lt;/span&gt;.Normal,&lt;br /&gt;      (&lt;span style="color: #2b91af"&gt;UpdateProgressbarIndeterminateState&lt;/span&gt;)&lt;br /&gt;         &lt;span style="color: blue"&gt;delegate&lt;/span&gt;(&lt;span style="color: blue"&gt;bool &lt;/span&gt;isIndeterminate) {&lt;br /&gt;            progressBar.IsIndeterminate = isIndeterminate;&lt;br /&gt;         }, &lt;span style="color: blue"&gt;false&lt;/span&gt;);&lt;br /&gt;}&lt;/div&gt;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-6611435863319166405?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/6611435863319166405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/02/responsive-wpf-interfaces.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/6611435863319166405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/6611435863319166405'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/02/responsive-wpf-interfaces.html' title='Responsive WPF Interfaces'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-2831839770444099832</id><published>2009-02-03T14:35:00.001-06:00</published><updated>2009-02-03T14:36:46.474-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>WPF DataGrid Conditional Formatting</title><content type='html'>&lt;p&gt;I recently ran into a problem on my project where I needed to apply some conditional formatting to WPF DataGrid Cells based upon values from another property in my bound object. &lt;/p&gt;  &lt;p&gt;The requirement was pretty simple: if condition is met, change the cell-text color to red, otherwise, leave it black.&amp;#160; What should have been a pretty simple task (never heard a programmer say that, right?) ended up taking me more time than I’d care to admit.&lt;/p&gt;  &lt;p&gt;After fumbling around with a few attempts at the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx" target="_blank"&gt;IValueConverter&lt;/a&gt; and a &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.datatemplateselector.aspx" target="_blank"&gt;DataTemplateSelector&lt;/a&gt;, I still was not having any luck in getting my conditional formatting to work.&amp;#160; I eventually landed back at my usual source of information for the &lt;a href="http://www.codeplex.com/wpf" target="_blank"&gt;WPF Toolkit&lt;/a&gt; – &lt;a href="http://www.codeplex.com/" target="_blank"&gt;CodePlex&lt;/a&gt;, and “shockingly”, the answer was in the &lt;a href="http://www.codeplex.com/wpf/Thread/View.aspx?ThreadId=40912" target="_blank"&gt;discussion for the project&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I had been fighting the “Foreground” property of the DataGridTextColumn directly, trying what was recommended in &lt;a href="http://bradygaster.com/post/WPF-Conditional-DataBinding.aspx" target="_blank"&gt;this article&lt;/a&gt;, but I just couldn’t get that working.&amp;#160; Once I followed the &lt;a href="http://www.codeplex.com/" target="_blank"&gt;CodePlex&lt;/a&gt; forum recommendation of embedding a &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.cellstyle(VS.95).aspx" target="_blank"&gt;CellStyle&lt;/a&gt; into the DataGridTextColumn, things worked as expected.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-2831839770444099832?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/2831839770444099832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/02/wpf-datagrid-conditional-formatting.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/2831839770444099832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/2831839770444099832'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/02/wpf-datagrid-conditional-formatting.html' title='WPF DataGrid Conditional Formatting'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-7507160562607753577</id><published>2009-01-30T19:00:00.002-06:00</published><updated>2009-01-30T19:01:41.330-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ to SQL'/><title type='text'>Two-way Data Binding with WPF DataGrids</title><content type='html'>&lt;p&gt;We’re making use of the the &lt;a href="http://www.codeplex.com/wpf" target="_blank"&gt;WPF Toolkit’s&lt;/a&gt; DataGrid control in my current project and have solved a few things along the way that weren’t entirely obvious to us at the start.  One of these things was figuring out how to automatically reflect domain object changes in the UI.&lt;/p&gt;  &lt;p&gt;Of the three developers on this project, &lt;a href="http://improvingenterprises.com/culture/people/nik-clarkson.aspx" target="_blank"&gt;Nik Clarkson&lt;/a&gt; has the most background with WPF and we usually throw out ideas to him and he “translates” what we want to do to into WPF terms and we’re off and running.  In the case of getting our UI to reflect domain model changes, he mentioned &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.data.binding.mode.aspx" target="_blank"&gt;BindingMode&lt;/a&gt;.  &lt;/p&gt;  &lt;p&gt;I was able to find some examples that showed how to do this in XAML pretty quickly, but I spent a few cycles trying to get this to work with a DataGridColumn that I was adding programmatically.  My first attempt looked like how you’d do it in XAML a-la  &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Binding&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"Price,&lt;/span&gt;&lt;span style="color:#a31515;"&gt; Mode = &lt;span style="color: rgb(43, 145, 175);"&gt;BindingMode&lt;/span&gt;.Two-way&lt;/span&gt;”), but that didn’t work.  &lt;/p&gt;  &lt;p&gt;I decided to make up a fresh batch of coffee in the team &lt;a href="http://www.bodum.com/" target="_blank"&gt;french-press&lt;/a&gt;, and then it hit me: &lt;a href="http://msdn.microsoft.com/en-us/library/bb384062.aspx" target="_blank"&gt;object initializers&lt;/a&gt;.  A quick edit and I ended up with following: &lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;var &lt;/span&gt;priceColumn = &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;DataGridTextColumn&lt;/span&gt;{ Header = &lt;span style="color: rgb(163, 21, 21);"&gt;"Price"&lt;/span&gt;, Width = &lt;span style="color: rgb(43, 145, 175);"&gt;DataGridLength&lt;/span&gt;.Auto,&lt;br /&gt; Binding = &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Binding&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"Price"&lt;/span&gt;) { Mode = &lt;span style="color: rgb(43, 145, 175);"&gt;BindingMode&lt;/span&gt;.Two-way, UpdateSourceTrigger = &lt;span style="color: rgb(43, 145, 175);"&gt;UpdateSourceTrigger&lt;/span&gt;.PropertyChanged }};&lt;br /&gt;ResultsGrid.Columns.Add(priceColumn);&lt;/pre&gt;This worked perfectly with the “Price” property I was binding to, since this was a property on one of our &lt;a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx" target="_blank"&gt;LINQ to SQL&lt;/a&gt; objects, and as such was raising the property-changed event for us in the generated code.  When I went to do the same thing with another column (one not generated by the &lt;a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx" target="_blank"&gt;LINQ to SQL&lt;/a&gt; designer), I wasn’t seeing my edits reflected in my UI, but did see them in the domain objects via the debugger.&lt;br /&gt;&lt;br /&gt;I had forgotten to raise the property-changed event in my ProposedPrice setter, so once I changed it to the following, everything worked great.&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;if &lt;/span&gt;(_proposedPrice != &lt;span style="color:blue;"&gt;value&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;SendPropertyChanging();&lt;br /&gt;_proposedPrice = &lt;span style="color:blue;"&gt;value&lt;/span&gt;;&lt;br /&gt;SendPropertyChanged(&lt;span style="color: rgb(163, 21, 21);"&gt;"ProposedPrice"&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-7507160562607753577?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/7507160562607753577/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/01/two-way-data-binding-with-wpf-datagrids.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/7507160562607753577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/7507160562607753577'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/01/two-way-data-binding-with-wpf-datagrids.html' title='Two-way Data Binding with WPF DataGrids'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-5374096231308629840</id><published>2009-01-28T10:19:00.002-06:00</published><updated>2009-01-28T11:09:10.183-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='recipes'/><title type='text'>I just discovered something</title><content type='html'>&lt;p&gt;One Kashi honey/cinnamon oatmeal packet plus a scoop of chocolate Muscle Milk with a bit of water and milk makes for one &lt;strong&gt;tasty&lt;/strong&gt; breakfast/snack.&lt;/p&gt;  &lt;p&gt;That is all.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-5374096231308629840?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/5374096231308629840/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/01/i-just-discovered-something.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/5374096231308629840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/5374096231308629840'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/01/i-just-discovered-something.html' title='I just discovered something'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-2904818261583325818</id><published>2009-01-26T16:59:00.002-06:00</published><updated>2009-01-26T17:00:13.233-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='recipes'/><title type='text'>Pasta Primavera</title><content type='html'>&lt;p&gt;Here’s one of my old standby recipes that’s extremely easy to make and is quite tasty.  &lt;/p&gt;  &lt;table border="0" cellpadding="2" cellspacing="0" width="450"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="223"&gt;1lb cooked linguini&lt;/td&gt;        &lt;td valign="top" width="225"&gt;2 cups broccoli&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="223"&gt;2 tbsp olive oil&lt;/td&gt;        &lt;td valign="top" width="225"&gt;12oz fresh mushrooms&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="223"&gt;1 small zucchini cut in small sticks&lt;/td&gt;        &lt;td valign="top" width="225"&gt;several cloves garlic – diced&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="223"&gt;1 small white onion&lt;/td&gt;        &lt;td valign="top" width="225"&gt;2 carrots cut into small sticks&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="223"&gt;1 small red bell pepper&lt;/td&gt;        &lt;td valign="top" width="225"&gt;12oz can evaporated skim milk&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="223"&gt;2 vegetable bullion cubes&lt;/td&gt;        &lt;td valign="top" width="225"&gt;1 1/4 tsp corn starch&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="223"&gt;2 plum tomatoes&lt;/td&gt;        &lt;td valign="top" width="225"&gt;2 tbsp parmesan cheese&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="223"&gt;Italian herbs (basil, oregano, etc)&lt;/td&gt;        &lt;td valign="top" width="226"&gt; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;In large skillet over medium heat, warm olive oil and then add mushrooms, onion, garlic and carrots.  Stir frequently until almost tender then add red pepper and cook.  In a separate pan, steam the broccoli for several minutes until tender and then set aside.&lt;/p&gt;  &lt;p&gt;In blender, mix evaporated milk, vegetable bullion, corn starch and herbs (and a 1/2 tsp of salt if desired).  Pour mixture over vegetables cooking in skillet and bring to boil.  Cook for one minute, stirring nearly constantly.  &lt;/p&gt;  &lt;p&gt;After draining the pasta, return to a large pot (4 qt or so), dump the skillet contents over the pasta, and top with the tomato, broccoli and parmesan and stir.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-2904818261583325818?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/2904818261583325818/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/01/pasta-primavera.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/2904818261583325818'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/2904818261583325818'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/01/pasta-primavera.html' title='Pasta Primavera'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-3050089470285012661</id><published>2009-01-16T08:03:00.002-06:00</published><updated>2009-01-24T19:54:36.171-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>AutoScroll panels in WPF</title><content type='html'>&lt;p&gt;I’m still pretty new to WPF, coming from a WinForms background, and I keep running into situations where stuff that I can do easily in WinForms just isn’t there in WPF.  Well, it’s there, I just don’t know how to do it.  My latest example was a requirement to add some auto-scrolling to a WrapPanel, and I couldn’t find any sort of “overflow=auto” type setting on the WrapPanel, so off to &lt;a href="http://www.google.com/" target="_blank"&gt;Google&lt;/a&gt; I went.&lt;/p&gt;  &lt;p&gt;Turns out WPF provides a pretty simple mechanism for allowing scroll: ScrollViewer.  This control allowed me to do exactly what I needed to get done, but it needed to be treated as a container around my WrapPanel - a concept I’m seeing more and more as I get into WPF – another example of this was adding borders to a panel.&lt;/p&gt;  &lt;p&gt;Here’s an example of a WrapPanel that has vertical auto-scrolling:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ScrollViewer&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;="MyScroller"&lt;/span&gt; &lt;span class="attr"&gt;VerticalScrollBarVisibility&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;  &amp;lt;&lt;/span&gt;&lt;span class="html"&gt;WrapPanel&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;="MyPanel"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;WrapPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ScrollViewer&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt; font-size: small;&lt;br /&gt; color: black;&lt;br /&gt; font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt; background-color: #ffffff;&lt;br /&gt; /*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt; background-color: #f4f4f4;&lt;br /&gt; width: 100%;&lt;br /&gt; margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-3050089470285012661?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/3050089470285012661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/01/autoscroll-panels-in-wpf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/3050089470285012661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/3050089470285012661'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/01/autoscroll-panels-in-wpf.html' title='AutoScroll panels in WPF'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-1692069069279943536</id><published>2009-01-16T07:43:00.002-06:00</published><updated>2009-01-24T19:54:23.237-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LINQ to SQL'/><title type='text'>LINQ to SQL Entity Association Quirks</title><content type='html'>&lt;p&gt;On my current project, we’re trying to adhere to the &lt;a href="http://www.xprogramming.com/Practices/PracSimplest.html" target="_blank"&gt;Simplest Thing That Could Possibly Work&lt;/a&gt; principle and this unfortunately led to some pains with LINQ to SQL surfacing after we had claimed victory on a few stories.&lt;/p&gt;  &lt;p&gt;We are early in this project, and didn’t have a wire-frame of what the screen flow would eventually look like, so we were just adding buttons to allow a user to see each piece of functionality as we delivered stories.  But, as we finished each story, it became more and more clear that we needed to do some proper UI soon.  &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Enter “The Wizard”    &lt;br /&gt;&lt;/strong&gt;We realized that the independent stories were really leading up to a flow of execution that a wizard style approach seemed to be a perfect fit for.  Things came together pretty well, until I started to mess around with back-and-forward navigation and I started to get “&lt;span style="color: rgb(255, 0, 0);"&gt;An attempt was made to remove a relationship between a &lt;em&gt;PARENT &lt;/em&gt;and a &lt;em&gt;CHILD&lt;/em&gt;.  However, one of the relationship’s foreign keys (&lt;em&gt;CHILD.PARENT_ID&lt;/em&gt;) cannot be set to null&lt;/span&gt;”.  This only occurred when I did any back-and-forward navigation and if I only navigated the happy-path straight through the wizard, things worked just fine.&lt;/p&gt;  &lt;p&gt;Part of my problem was that I wasn’t submitting my changes until the user completed work in the wizard, but I was running code to disassociate existing entities (that may or may not have been persisted to the database) from local collections – each time the user left particular steps in the wizard.  I was able to overcome some of those quirks with the “what didn’t work” approach below, but I still would saw the “null relationship” error on a fairly regular basis.&lt;/p&gt;  &lt;p&gt;After much time searching &lt;a href="http://www.google.com/" target="_blank"&gt;Google&lt;/a&gt;, and trying a number of approaches as recommended &lt;a href="http://blogs.msdn.com/bethmassi/archive/2007/10/02/linq-to-sql-and-one-to-many-relationships.aspx" target="_blank"&gt;here&lt;/a&gt; and &lt;a href="http://stackoverflow.com/questions/384755/linq-to-sql-one-to-many-databinding-deleting-problem" target="_blank"&gt;here&lt;/a&gt;, I started to realize that I wasn’t properly disassociating my entities from their parent relationships before I deleted them.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What didn’t work:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color:blue;"&gt;try&lt;/span&gt;{  &lt;br /&gt;   Repository.Delete(pricingElementDepartment);  &lt;br /&gt;}  &lt;br /&gt;&lt;span style="color:blue;"&gt;catch&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;InvalidOperationException &lt;/span&gt;) {}&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;What did work:&lt;/strong&gt;&lt;/p&gt; &lt;span style="color:blue;"&gt;try&lt;/span&gt;{&lt;br /&gt;   &lt;strong&gt;childEntity.Parent = null;&lt;/strong&gt;&lt;br /&gt;   Repository.Delete(childEntity);&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:blue;"&gt;catch&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);"&gt;InvalidOperationException &lt;/span&gt;) {}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-1692069069279943536?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/1692069069279943536/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2009/01/linq-to-sql-entity-association-quirks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/1692069069279943536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/1692069069279943536'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2009/01/linq-to-sql-entity-association-quirks.html' title='LINQ to SQL Entity Association Quirks'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-3280964151866758186</id><published>2008-12-22T20:04:00.004-06:00</published><updated>2008-12-25T09:16:12.688-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>WPF DataGrid CheckBox Column Editing</title><content type='html'>&lt;p&gt;We’re using the &lt;a href="http://www.codeplex.com/wpf" target="_blank"&gt;WPFToolkit&lt;/a&gt; on my current project, specifically the DataGrid control.  We needed to programmatically add some CheckBox Columns to the layout, and it was pretty straight-forward. &lt;/p&gt;  &lt;p&gt;The only issue we had was the cells required two clicks to flip the checked state of these cells.  I spent a few minutes searching through the &lt;a href="http://www.codeplex.com/wpf/Thread/List.aspx" target="_blank"&gt;Discussions&lt;/a&gt; for the project and stumbled across this gem: &lt;a href="http://www.codeplex.com/wpf/Wiki/View.aspx?title=Single-Click%20Editing&amp;amp;version=7" target="_blank"&gt;Single Click Editing&lt;/a&gt; – worked like a charm (and now QA should be able to resolve the bug that was generated around this quirky functionality).&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-3280964151866758186?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/3280964151866758186/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2008/12/wpftoolkit-datagridcheckboxcolumn.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/3280964151866758186'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/3280964151866758186'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2008/12/wpftoolkit-datagridcheckboxcolumn.html' title='WPF DataGrid CheckBox Column Editing'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-740269431285397795</id><published>2008-12-22T18:27:00.004-06:00</published><updated>2008-12-25T09:16:56.254-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='TFS'/><title type='text'>FileNotFoundException: Could not load file or assembly 'Microsoft.TeamFoundation.Client....</title><content type='html'>&lt;p&gt;At the start of my current project, I decided it was time to rewrite my TFS Build Utility against the 2008 API/SDK.  &lt;/p&gt;  &lt;p&gt;I didn’t get get very far before I started to see a “System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.TeamFoundation.Client, Version=9.0.0.0” message whenever I ran my code.&lt;/p&gt;  &lt;p&gt;More strange, the app would bring up my main form just fine, but as soon as it hit the constructor of my presenter, I’d get that error.  The first line in my constructor was a call to a method where I’d be initializing my TeamFoundationServer object, but I never even got to that line, the exception happened as soon as I stepped into the first line of the constructor. &lt;/p&gt;  &lt;p&gt;After a bit of &lt;a href="http://www.google.com/" target="_blank"&gt;Google&lt;/a&gt; searching, I eventually landed on &lt;a href="http://teamsystemrocks.com/blogs/omarv/archive/2008/09/10/40541.aspx" target="_blank"&gt;Omar Villarreal's&lt;/a&gt; post on using the TFS API in a 64-bit environment – which is what I was doing, and the solution: setting the Platform Target property for my project to&lt;strong&gt; x86&lt;/strong&gt;, instead of “&lt;strong&gt;Any CPU&lt;/strong&gt;” as is set by default in Visual Studio. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-740269431285397795?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/740269431285397795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2008/12/filenotfoundexception-could-not-load.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/740269431285397795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/740269431285397795'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2008/12/filenotfoundexception-could-not-load.html' title='FileNotFoundException: Could not load file or assembly &apos;Microsoft.TeamFoundation.Client....'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-8892762150774413519</id><published>2008-12-06T06:28:00.003-06:00</published><updated>2008-12-25T09:17:50.978-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='TFS'/><category scheme='http://www.blogger.com/atom/ns#' term='TeamBuild'/><title type='text'>TeamBuild Error Running UnitTests with WPF Objects</title><content type='html'>&lt;p&gt;I’m just wrapping up sprint 1 of my latest project and as such have been taking care of some infrastructure type tasks.  We’re using TFS2008 for our SCM/CI stuff, so I created a new build definition for our main project (WPF/Linq to SQL).   We had about a dozen unit tests at this point, all of which we green on our machines (&lt;a href="http://www.codinghorror.com/blog/archives/000818.html" target="_blank"&gt;Works on my machine&lt;/a&gt;), but once I fired off my build on the CI box, two of the tests failed with the following error:&lt;/p&gt;  &lt;p&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Test method TestAssembly.TestClass.MyTest threw exception:  System.Windows.Markup.XamlParseException: 'StackPanel' object cannot be added to 'Grid'. The program issued a command but the command length is incorrect. (Exception from HRESULT: 0x80070018)  Error at object 'System.Windows.Controls.StackPanel' in markup file 'TestApp.UserInterface;component/view/myview.xaml'. ---&amp;gt;  System.Runtime.InteropServices.COMException: The program issued a command but the command length is incorrect. (Exception from HRESULT: 0x80070018).&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;The two tests that failed happened to be the two that created an instance of a WPF Window, which no other tests in the suite did, so at least we had some clues to &lt;a href="http://www.google.com/" target="_blank"&gt;Google&lt;/a&gt; with.  It didn’t take long to stumble across this page: &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361469" target="_blank"&gt;MS Forums: .NET 3.5 SP1 breaks use of WPF under IIS&lt;/a&gt;.  &lt;/p&gt;  &lt;p&gt;Although we weren’t doing anything with IIS, the rest of the symptoms sounded exactly like what we were dealing with.  We took the advice given in the first community comment that indicated we should run the executable in XP SP2 compatibility mode and applied that the the TFSBuildService executable.  The next build succeeded and we were back to coding.&lt;/p&gt;  &lt;p&gt;The good news is that MS intends to fix this issue with a future patch/service pack, but not until sometime next year, so for now, you’re stuck with forcing compatibility mode on your failing executables.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-8892762150774413519?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/8892762150774413519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2008/12/xamlparseexception-error-while-running.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/8892762150774413519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/8892762150774413519'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2008/12/xamlparseexception-error-while-running.html' title='TeamBuild Error Running UnitTests with WPF Objects'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-3652355314454234745</id><published>2008-12-04T12:23:00.004-06:00</published><updated>2008-12-25T09:21:05.427-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='Unity'/><category scheme='http://www.blogger.com/atom/ns#' term='IoC'/><category scheme='http://www.blogger.com/atom/ns#' term='TDD'/><title type='text'>Mocking the Unity Container</title><content type='html'>&lt;p&gt;While trying to get some tests running for my current project (WPF, VS2008, C#, MSTest, RhinoMocks 3.5, Vista 64bit), I ran into an issue where I can’t mock out the Unity Container. &lt;/p&gt;  &lt;p&gt;I was following the advice on &lt;a href="http://randypatterson.com/2008/03/30/LazyInstantiationWithUnityApplicationBlock.aspx" target="_blank"&gt;Randy's Blog&lt;/a&gt;, but when I hit the line where I’m creating a stub of the IUnityContainer, the test blows up with the error below, and like others have mentioned, when in debug, the error doesn’t surface. Here’s the error I’m seeing:&lt;/p&gt;  &lt;p&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Initialization method Test.Presenter.GivenPresenter.TestAnythingAndSeeItFail threw exception. System.BadImageFormatException: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B).&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;Seems I’m not the only one running into this error:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.nabble.com/BadImageFormatException,-but-not-when-debugging-td18742529.html" target="_blank"&gt;http://www.nabble.com/BadImageFormatException,-but-not-when-debugging-td18742529.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://groups.google.com/group/RhinoMocks/browse_thread/thread/b2235a13f920c616" target="_blank"&gt;http://groups.google.com/group/RhinoMocks/browse_thread/thread/b2235a13f920c616&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Edit:&lt;/p&gt;  &lt;p&gt;After a failed attempt to created a fake based on IUnityContainer, I ran across Roy Osherove’s post on creating an &lt;a href="http://weblogs.asp.net/rosherove/archive/2008/04/14/creating-a-automockingcontainer-with-microsoft-unity-pretty-darn-simple.aspx" target="_blank"&gt;AutoMockingUnityContainer&lt;/a&gt; which worked perfectly for my test needs.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-3652355314454234745?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/3652355314454234745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2008/12/rhinomocks-iunitycontainer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/3652355314454234745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/3652355314454234745'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2008/12/rhinomocks-iunitycontainer.html' title='Mocking the Unity Container'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-772945181992163867</id><published>2008-12-03T18:52:00.003-06:00</published><updated>2008-12-25T09:20:10.177-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TFS'/><category scheme='http://www.blogger.com/atom/ns#' term='eScrum'/><title type='text'>Installing eScrum 1.1 for TFS 2008</title><content type='html'>&lt;p&gt;I just wanted to take a few moments to note some of the struggle points I encountered while installing the eScrum 1.1 template on my company’s TFS 2008 box.  The environment is a single-server TFS2008 install on a Windows 2008 server and a separate Windows 2008 Server running a MOSS farm that will serve up the SharePoint bits for our TeamProjects.&lt;/p&gt;  &lt;p&gt;One issue I had was that the configuration utility that launches at the end of the install didn’t seem to let me do anything – I would either get an exception window or an error that the “website installed unsuccessfully” (huh?).&lt;/p&gt;  &lt;p&gt;I decided to just close the utility and dig through the eScrum_readme.rtf file to see if I could figure out what was up.  This file is your best friend while you’re fumbling though the eScrum configuration.&lt;/p&gt;  &lt;p&gt;Not seeing anything in particular about none of the configuration utility tools working, I relaunched the configuration utility as Administrator and this time succeeded in install the website, but not the SharePoint template.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Getting the eScrum Website working&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I then referred back to the read-me document and followed the post-installation steps to configure the app-pool.  The only confusing item there is that the example script command they show actually had the website ID in the sample, instead of “&amp;lt;website&amp;gt;” as the next step hints at how to locate, but no biggie, it was pretty clear what they meant.    The shortcut for locating this on a Vista/Windows 2008 box is at the very bottom of the read-me.&lt;/p&gt;  &lt;p&gt;When I then tried to browse the local site, I kept getting errors about the &lt;em&gt;Session&lt;/em&gt; member in the httpModules section of the web.config being a duplicate, so I removed that entry and then received a new error (I forgot to write down the exact error unfortunately).   However, this time, the webpage had a command that it indicated I should run from a command-window, and this command cleared up my issue and I had the website running.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Getting the SharePoint Template Uploaded&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Our environment had an existing MOSS Farm that we wanted to utilize, so I ran the STSADM utility from the SharePoint box and added the eScrum_tfs2008.stp template.  Quick and easy.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Uploading the eScrum Project Template for TFS&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;At this point, the last thing I had to do was upload the  eScrum template to the TFS machine.   I couldn’t get the Configuration Tool to upload this for me, so I had to do things manually.  I ended up expanding the contents of eScrumProcessTemplate.zip into a folder and pointing to that in order to get the project template uploaded to my TFS server.  The read-me indicated that I should have been able to do the upload from the zip file, but the upload manager wouldn’t enable the Upload button so I used the unzip then upload method.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Adding your project to the eScrum website project list&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The last thing you’ll need to do in order to use the eScrum website with your project(s) is edit the eScrum UI’s web.config as outlined in the read-me.  After that, you’re off and running.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-772945181992163867?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/772945181992163867/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2008/12/notes-on-installing-escrum-11-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/772945181992163867'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/772945181992163867'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2008/12/notes-on-installing-escrum-11-on.html' title='Installing eScrum 1.1 for TFS 2008'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-2574140099886357994</id><published>2008-12-01T18:39:00.003-06:00</published><updated>2008-12-25T09:21:38.550-06:00</updated><title type='text'>I'm Back....</title><content type='html'>Ok, it's been a &lt;strong&gt;LONG&lt;/strong&gt; while since I added anything to this blog, but I've decided to dust it off and start getting a bit more active with posting, so stay tuned.....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-2574140099886357994?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/2574140099886357994/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2008/12/ok-its-been-long-while-since-i-added.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/2574140099886357994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/2574140099886357994'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2008/12/ok-its-been-long-while-since-i-added.html' title='I&apos;m Back....'/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-115513124241080457</id><published>2006-08-09T08:34:00.000-05:00</published><updated>2006-08-09T09:02:21.930-05:00</updated><title type='text'></title><content type='html'>&lt;span style="color: rgb(255, 0, 0);font-weight: bold;font-size:130%;"&gt;Why isn't my HTML table taking up the whole window when I set width and height to 100%?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I seems like every time I start back with webpages from WinForms or services, I want to create a simple table that takes up the entire page, so I do something like this:&lt;br /&gt;&amp;lt;table style="height: 100%; width: 100%;background-color: Gray"&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;foo&amp;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&lt;br /&gt;I would expect my entire browser window to now show up with a gray background due to the table I added filling the entire window. What I actually see is a gray square in the upper-left portion of the browser which is grey, with my "foo" text displayed.&lt;br /&gt;&lt;br /&gt;It seems that this "problem" is actually the expected behaviour with the above snippet. The rendered HTML is sitting within a HTML and BODY tag that we have yet to address, so it's filling 100% of the BODY width/height.&lt;br /&gt;&lt;br /&gt;Here is one way to correct this issue - create a stylesheet and add the following declaration:&lt;br /&gt;html, body&lt;br /&gt;{&lt;br /&gt;  margin: 0;&lt;br /&gt;  padding: 0;&lt;br /&gt;  height: 100%;&lt;br /&gt;  width: 100%;&lt;br /&gt;  border: none;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;When you apply this stylesheet to your page and refresh in your browser you should now see a gray background over your entire browser window.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-115513124241080457?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/115513124241080457/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2006/08/why-isnt-my-html-table-taking-up-whole.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/115513124241080457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/115513124241080457'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2006/08/why-isnt-my-html-table-taking-up-whole.html' title=''/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-115288071037198651</id><published>2006-07-14T07:33:00.000-05:00</published><updated>2006-07-14T08:02:41.273-05:00</updated><title type='text'></title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span style="font-weight: bold;font-size:13;" &gt;The Unproductive Programmer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As a consultant in the IT World, I never know what I'm kind of client environment I'm going to end up in. I'm not talking about the politics and interpersonal aspects you find in the workplace, but rather the technological ecosystem. What kinds of computers will this client provide? What do the development/test/production systems look like? Do we have a test/stage environment? The list goes on.&lt;br /&gt;&lt;br /&gt;In my current company, we generally take what the client provides, and my current client has provided some rather dusty, old machines for us. My machine has 512MB RAM and a 2.8 GHz P4 processor. Doesn't sound too bad until you consider that in a normal workday, I'll have VisualStudio2003 with ReSharper, Outlook (outbreak as my colleague Neal Ford likes to call it), and a VMWare instance of WinXP which I use for changes to the legacy VB6 system they have here.&lt;br /&gt;&lt;br /&gt;The combination of VMWare and VS2003 proves quite deadly at 512MB RAM. I'm lucky if I can get both of these apps to stay open at the same time. Usually, if I have VS2003 open and try to open VMWare, as VMWare is launching, it will just disappear (watching my system resources, the available physical RAM dips to about 2MB!).&lt;br /&gt;&lt;br /&gt;I suspect that in a given 8 hour workday, I spend at minimum, 10% of my time waiting for my computer to do something, and more likely, around 20% of the time waiting.&lt;br /&gt;&lt;br /&gt;So, how much is this "cost saving" hardware really costing my client? Let's say I'm billing $60/hour (since this makes the math easy) -&lt;br /&gt;&lt;br /&gt;Optimistic Lost Productivity:&lt;br /&gt;$60/hour * (8 hours * 10% lost productivity) = $48/day in "lost" time&lt;br /&gt;&lt;br /&gt;Wow, that can really add up over the course of a 6 month client engagement -&lt;br /&gt;130 days * $48/day = $6,240 in lost productivity time over the course of the 6 months&lt;br /&gt;&lt;br /&gt;A more modern machine like a nicely spec'd out Dell Precision 490 that I configured to a decent level of performance, and included 2 17" monitors, would be about $3000 to purchase, or maybe more cost effectively, lease at say, $120/month. Suffice to say; moving a team of 5 developers from "old tech" so something along these lines should decrease the lost productivity exponentially.&lt;br /&gt;&lt;br /&gt;I guess I don't know what forces are at play that would "save" all this money by keeping all these out-dated computers around and have people spending countless hours waiting for their machines to catch-up.&lt;br /&gt;&lt;!--[if !supportLineBreakNewLine]--&gt;&lt;br /&gt;&lt;!--[endif]--&gt;&lt;span style=";font-family:Arial;font-size:10;"  &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-115288071037198651?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/115288071037198651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2006/07/unproductive-programmer-as-consultant.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/115288071037198651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/115288071037198651'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2006/07/unproductive-programmer-as-consultant.html' title=''/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-115133756847803991</id><published>2006-06-26T10:56:00.002-05:00</published><updated>2008-12-22T20:16:35.048-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ReSharper'/><title type='text'></title><content type='html'>Ah CollapseAll, one my favorite macros for Visual Studio, and one I'm surprised every developer doesn't have hot-keyed or at least a custom tool-bar button created for.&lt;br /&gt;&lt;br /&gt;If you've ever worked in a decently scoped project for some length of time, you've probably experienced a point in time where your project/file structure in the Solution Explorer grows past the bounds of your screen. If you're fortunate enough to have ReSharper and to have vast knowledge of your codebase, this isn't that big of an issue - just hit one of the various keyboard shortcuts (Ctrl+F12, Ctrl+E, Ctrl+N, etc) and locate that file.&lt;br /&gt;&lt;br /&gt;For those of us in the "unfortunate" bucket, we probably rely a bit more on the Solution Explorer. We have to go scrolling around and collapsing various projects until we narrow in on the project/files we're looking for. Not a big deal when you have project or two, but becomes a major P.I.T.A. when you've got 20 projects of various sizes in various states of expanded state.&lt;br /&gt;&lt;br /&gt;A solution for this is the handy CollapseAll macro that someone came up with long ago (not sure who gets credit for this, but thanks!).&lt;br /&gt;&lt;br /&gt;(See &lt;a href="http://www.milkcarton.com/blog/2007/05/20/Using+Visual+Studio+Macros+To+Increase+Productivity.aspx"&gt;Chris'&lt;/a&gt; blog for some full details on adding the macro)&lt;br /&gt;&lt;br /&gt;One thing I'll add, is that I generally like to add a new button that I stick over the Solution Explorer. To go about this, do the following:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;In VisualStudio, select View/Toolbars/Customize&lt;/li&gt;&lt;li&gt;Create a new group - call it "MyMacros" and hit "OK" - a new button group will appear next to the toolbars dialog&lt;/li&gt;&lt;li&gt;In the Customize Toolbars dialog, select the "Commands" tab. Under "Categories" select "Macros" and now in the "Commands" listbox, locate your macro and drag that list-item to the floating button group&lt;/li&gt;&lt;li&gt;If you right-click the button, you can rename it to something a bit more concise, like "CollapseAll", you can also select an icon, etc for the button&lt;/li&gt;&lt;li&gt;Drag the button-group to the toolbar somewhere handy, like over the Solution Explorer.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-115133756847803991?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/115133756847803991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2006/06/ah-collapseall-one-my-favorite-macros.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/115133756847803991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/115133756847803991'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2006/06/ah-collapseall-one-my-favorite-macros.html' title=''/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23748967.post-114192664930195045</id><published>2006-03-09T11:41:00.000-06:00</published><updated>2006-04-25T20:22:48.206-05:00</updated><title type='text'></title><content type='html'>We've been using Visual Studio 2005 Professional on my current project, along with Resharper 2.0.  This combination has been the cause of countless issues along the way.  One machine has been subjected to every build of Resharper 2.0 since 213.&lt;br /&gt;&lt;br /&gt;Each build seems to have its good and bad points, but all come up short.  My biggest gripe is that Alt+Enter functionality is missing.  Well, that's not exactly true.  One or two of our machines, at various stages, have managed to get Alt+Enter functionality.&lt;br /&gt;&lt;br /&gt;I'm eagerly awaiting the build of Resharper 2.0 that gives me back the environment enhancements I've come to rely upon in Visual Studio 2003.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Update&lt;br /&gt;&lt;/span&gt;Turns out that the issues we were having were due to a bad Ghost Image for our Windows XP machines.  Once we went through the process of reloading software from DVDs, all was well in ReSharper land. &lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23748967-114192664930195045?l=mocella.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mocella.blogspot.com/feeds/114192664930195045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mocella.blogspot.com/2006/03/weve-been-using-visual-studio-2005.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/114192664930195045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23748967/posts/default/114192664930195045'/><link rel='alternate' type='text/html' href='http://mocella.blogspot.com/2006/03/weve-been-using-visual-studio-2005.html' title=''/><author><name>Tony Mocella</name><uri>http://www.blogger.com/profile/12419576161922235601</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_9wmVJvGIiEM/STcrkYuKtDI/AAAAAAAABK0/FC6gUfM6khM/S220/TonyMocellaHeadShotSmall.jpg'/></author><thr:total>0</thr:total></entry></feed>
