<?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-4504841978562309153</id><updated>2012-02-16T09:18:44.440Z</updated><category term='regasm'/><category term='DataGridView'/><category term='interop'/><category term='eloquera'/><category term='visual inheritance'/><category term='Image'/><category term='registry'/><category term='finalize'/><category term='vs2008'/><category term='ps'/><category term='incentive'/><category term='ghostscript'/><category term='using'/><category term='threading'/><category term='c#'/><category term='data bound'/><category term='test'/><category term='wp7'/><category term='IWin32Window'/><category term='winmerge'/><category term='gs'/><category term='pinvoke'/><category term='tips'/><category term='assemblyfileversion'/><category term='drag'/><category term='mercurial.ini'/><category term='.net'/><category term='knowntype'/><category term='comexception'/><category term='windows phone'/><category term='sort'/><category term='sqldmo.dll'/><category term='reporting'/><category term='modeless'/><category term='tab'/><category term='DataGridViewRow'/><category term='winforms'/><category term='dlr'/><category term='p4merge'/><category term='suo'/><category term='ra0000'/><category term='com'/><category term='msi'/><category term='merge-tools'/><category term='pdf'/><category term='visual studio'/><category term='.net remoting'/><category term='sql 2005'/><category term='db4o'/><category term='disposable pattern'/><category term='custom'/><category term='wow6432node'/><category term='juneau'/><category term='revit'/><category term='regsvr32'/><category term='revit api'/><category term='asp.net'/><category term='dev'/><category term='kdiff3'/><category term='gac'/><category term='unknown command'/><category term='gotcha'/><category term='setup'/><category term='designer'/><category term='late to the game'/><category term='dll'/><category term='client'/><category term='80041054'/><category term='reportviewer'/><category term='dynamic'/><category term='objectarx'/><category term='dispose'/><category term='gc'/><category term='load'/><category term='export'/><category term='autocad'/><category term='ssdt'/><category term='form'/><category term='toolbox'/><category term='concurrent'/><category term='sql-dmo'/><category term='changeset'/><category term='drop'/><category term='datacontract'/><category term='pcscad'/><category term='unit test'/><category term='ninject'/><category term='vs2010'/><category term='remoting'/><category term='BitmapImage'/><category term='parallel'/><category term='datagridviewcomboboxcolumn'/><category term='source control'/><category term='postscript'/><category term='vs2005'/><category term='ipc'/><category term='thread affinity'/><category term='oodb'/><category term='axum'/><category term='ps2pdf'/><category term='collapse extension'/><category term='focus'/><category term='pcscustom'/><category term='wcf'/><category term='crash'/><category term='expandoobject'/><category term='tricks'/><category term='extensions'/><category term='office'/><category term='visual studio 2008'/><category term='silverlight'/><category term='.installstate'/><category term='shared add-in'/><category term='deployment'/><category term='sorting'/><category term='multithreading'/><category term='version'/><category term='assemblyversion'/><category term='sql server'/><category term='versioning'/><category term='bitbucket'/><category term='outlook'/><category term='inactive'/><category term='user control'/><category term='ImageSource'/><category term='custom action'/><category term='qa'/><category term='extdiff'/><category term='server gc'/><category term='clr'/><category term='activex'/><category term='factory pattern'/><category term='hacks'/><category term='generics'/><category term='application.run'/><category term='garbage collection'/><category term='code tab'/><category term='features'/><category term='microsoft'/><category term='add-in'/><category term='knowntypeattribute'/><category term='team'/><category term='usercontrol'/><category term='dmo'/><category term='BadImageFormatException'/><category term='mercurial'/><category term='bound'/><category term='db'/><title type='text'>Adam Houldsworth's Blog</title><subtitle type='html'>C# Development</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>59</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-1898062417697760970</id><published>2011-08-08T13:33:00.003+01:00</published><updated>2011-08-08T13:46:58.228+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='juneau'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='ssdt'/><category scheme='http://www.blogger.com/atom/ns#' term='vs2010'/><title type='text'>Juneau CTP - Generate Scripts</title><content type='html'>Perhaps the most obvious feature that is going to be (ab)used by developers using this tool is script generation.&amp;nbsp; Admit it, it's the only reason you call anymore...&lt;br /&gt;&lt;br /&gt;I have a database project that compiles (your first challenge on an established enterprise database, believe me!).&amp;nbsp; From this I created a snapshot:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-mHrv0F114vE/Tj-6RbOR2cI/AAAAAAAAACg/YQjxQVShnjo/s1600/Snapshot+Menu.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="127" src="http://4.bp.blogspot.com/-mHrv0F114vE/Tj-6RbOR2cI/AAAAAAAAACg/YQjxQVShnjo/s320/Snapshot+Menu.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;I then made some changes (Refactor &amp;gt; Rename a column that is involved in an index and some stored procedures), and then created another snapshot:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-wP_zF3m3AxI/Tj-6R3uHLyI/AAAAAAAAACk/nsRyj0kS9ek/s1600/Snapshots.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-wP_zF3m3AxI/Tj-6R3uHLyI/AAAAAAAAACk/nsRyj0kS9ek/s1600/Snapshots.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;What you can do now is compare these using the "Database Files" option of the dialog (the snapshot files are in a Snapshots folder inside the project structure on disk):&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-skAE_ObZhRA/Tj-6QUDb7XI/AAAAAAAAACY/v0PZcNXxoUE/s1600/Comparing+Snapshots.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="158" src="http://3.bp.blogspot.com/-skAE_ObZhRA/Tj-6QUDb7XI/AAAAAAAAACY/v0PZcNXxoUE/s320/Comparing+Snapshots.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This compares as you would expect, however, any useful actions such as "Generate Script" or "Update Target" are not available:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-VLhkmw_zAyI/Tj-6RJykTtI/AAAAAAAAACc/WaVQScYzyew/s1600/Disabled+Generate.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-VLhkmw_zAyI/Tj-6RJykTtI/AAAAAAAAACc/WaVQScYzyew/s1600/Disabled+Generate.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I can understand the latter, as there is no "target" to update - a snapshot is only the database model serialized.&amp;nbsp; The former, however, seems as though it should be enabled, and even more, enabled in all situations.&amp;nbsp; I'm not sure why it isn't, there is not much content on the net yet and I've not put my Microsoft Connect log-in through pre-flight checks to find out.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Annoyingly, I can't seem to find a workaround.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;I tried a few things:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Comparing a snapshot file to a database project.&lt;/li&gt;&lt;li&gt;Importing the snapshot into a second database project and comparing two projects.&lt;/li&gt;&lt;/ul&gt;None of these gave me any useful actions.&amp;nbsp; I'm going to continue playing with it to see what I can dig up - but, VS has just locked up.&amp;nbsp; Typical!&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Well, found out how to get the "Generate Script" button to wake up, point your comparison at a live database and it should let you generate your scripts.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-1898062417697760970?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/1898062417697760970/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/08/juneau-ctp-generate-scripts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1898062417697760970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1898062417697760970'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/08/juneau-ctp-generate-scripts.html' title='Juneau CTP - Generate Scripts'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-mHrv0F114vE/Tj-6RbOR2cI/AAAAAAAAACg/YQjxQVShnjo/s72-c/Snapshot+Menu.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-1998513373036003564</id><published>2011-07-28T09:27:00.002+01:00</published><updated>2011-07-28T10:30:50.433+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql server'/><category scheme='http://www.blogger.com/atom/ns#' term='juneau'/><category scheme='http://www.blogger.com/atom/ns#' term='ssdt'/><category scheme='http://www.blogger.com/atom/ns#' term='vs2010'/><title type='text'>Juneau CTP First Impressions</title><content type='html'>I've been tasked at work to play with this tool, as we are going through a big consolidation of code branches and database versions, to unify our database upgrade path.&amp;nbsp; It's otherwise known as SQL Server Development Tools, SSDT.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The Good:&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;You can import existing databases.&lt;/li&gt;&lt;li&gt;Can detect differences between versions and output scripts.&lt;/li&gt;&lt;li&gt;Ties in with source control through Visual Studio.&lt;/li&gt;&lt;li&gt;Go To Definition, Find in Files, refactoring.&lt;/li&gt;&lt;li&gt;Compile-time support.&lt;/li&gt;&lt;/ul&gt;&lt;strong&gt;The Bad:&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Slow build times.&lt;/li&gt;&lt;li&gt;Slow UI at times.&lt;/li&gt;&lt;li&gt;Whenever you double-click a file, it loads a floating window not a docked tab.&lt;/li&gt;&lt;/ul&gt;&lt;strong&gt;The Ugly:&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Appears to be highlighting lots of our SQL that doesn't compile, but won't ever run (due to if statements etc).&amp;nbsp; &lt;em&gt;Ok... so this is our fault&lt;/em&gt; :-)&lt;/li&gt;&lt;li&gt;Lots of warnings (thousands in our&amp;nbsp;enterprise-scale database) about ambiguous object references (column names etc).&lt;/li&gt;&lt;li&gt;Errors that the SQL parser doesn't complain about, in stored procedures that you don't know what the return conditions are - so you can't fix them all that easily.&lt;/li&gt;&lt;/ul&gt;On the surface, it looks good.  I say this with complete ignorance about the other tools available on the market, I haven't used any of them.  All I can say for sure is having this stuff in VS 2010 is a big selling point.&lt;br /&gt;&lt;br /&gt;We begin at a fortunate starting point, we have a process for creating clean, blank, databases with initial static data.  This allows me to define a starting point in Juneau (via importing).&amp;nbsp; If you have installed Juneau (I did so from the Web Platform Installer), you will notice a new Project template in Visual Studio:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-u4oae9-tbpQ/Ti7Gx1zv97I/AAAAAAAAACI/QX07JjN4g8M/s1600/New+Project+Template.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="172" src="http://1.bp.blogspot.com/-u4oae9-tbpQ/Ti7Gx1zv97I/AAAAAAAAACI/QX07JjN4g8M/s320/New+Project+Template.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This is important.  The database is realised in the project as code, this allows code-based actions to function: object definitions (Go To Definition support), versioning, and refactoring.&lt;br /&gt;&lt;br /&gt;Once created, I can take an existing database and import it - cool.&amp;nbsp; I can then compile this using Ctrl+Shift+B - cool.&amp;nbsp; I can go to definition on procedures, views, tables, temporary tables, variables, etc - cool.&amp;nbsp; I can snapshot... well, I can't as it isn't compiling!&lt;br /&gt;&lt;br /&gt;The only limitation I wish wasn't a limitation is Find All References.&amp;nbsp; This works within the database structure, but it has no link to a C# project that calls into the database.&amp;nbsp; OK this isn't that easy to achieve perhaps, but it would be very powerful.&lt;br /&gt;&lt;br /&gt;I personally think it looks good, but it feels much like a CTP :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-1998513373036003564?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/1998513373036003564/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/07/juneau-ctp-first-impressions_28.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1998513373036003564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1998513373036003564'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/07/juneau-ctp-first-impressions_28.html' title='Juneau CTP First Impressions'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-u4oae9-tbpQ/Ti7Gx1zv97I/AAAAAAAAACI/QX07JjN4g8M/s72-c/New+Project+Template.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-6733163512442837033</id><published>2011-07-27T11:03:00.000+01:00</published><updated>2011-07-27T11:03:47.931+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wp7'/><category scheme='http://www.blogger.com/atom/ns#' term='silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='unit test'/><category scheme='http://www.blogger.com/atom/ns#' term='windows phone'/><title type='text'>WP7 Unit Testing</title><content type='html'>This is perhaps the cutest unit test runner I've seen in a while. &amp;nbsp;There is a unit test runner specifically for Windows Phone 7 using the Microsoft Silverlight testing code. &amp;nbsp;It runs inside the emulator.&lt;br /&gt;&lt;br /&gt;The bits are available for download (from Jeff Wilcox's blog):&lt;br /&gt;&lt;br /&gt;Bits: &lt;a href="http://media.jeff.wilcox.name/blog/ut/SL3_UTF_May.zip"&gt;http://media.jeff.wilcox.name/blog/ut/SL3_UTF_May.zip&lt;/a&gt;&lt;br /&gt;Blog: &lt;a href="http://www.jeff.wilcox.name/2010/05/sl3-utf-bits/"&gt;http://www.jeff.wilcox.name/2010/05/sl3-utf-bits/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can add this to your project manually, but I ended up using Nuget:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-9uCagfvSIxM/Ti_hENBqmNI/AAAAAAAAACU/Dy647xPuLQw/s1600/nuget.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="151" src="http://3.bp.blogspot.com/-9uCagfvSIxM/Ti_hENBqmNI/AAAAAAAAACU/Dy647xPuLQw/s320/nuget.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Wiring it into your project is as easy as adding a new Windows Phone Application project, adding&amp;nbsp;the Nuget&amp;nbsp;reference (at which point it includes a series of files to get the runner embedded), and adding tests. &amp;nbsp;This is your testing project hence forth.&lt;br /&gt;&lt;br /&gt;Set as start-up and go.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-6rOGiipF4lY/Ti_gHUusf9I/AAAAAAAAACM/U4shh-66LaE/s1600/screenshot_7-27-2011_10.45.16.435.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/-6rOGiipF4lY/Ti_gHUusf9I/AAAAAAAAACM/U4shh-66LaE/s320/screenshot_7-27-2011_10.45.16.435.png" width="174" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-pLkJc_g24o8/Ti_gIrcEPEI/AAAAAAAAACQ/WkfVjyFMSUA/s1600/screenshot_7-27-2011_10.44.31.253.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://4.bp.blogspot.com/-pLkJc_g24o8/Ti_gIrcEPEI/AAAAAAAAACQ/WkfVjyFMSUA/s320/screenshot_7-27-2011_10.44.31.253.png" width="174" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-6733163512442837033?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/6733163512442837033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/07/wp7-unit-testing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6733163512442837033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6733163512442837033'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/07/wp7-unit-testing.html' title='WP7 Unit Testing'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-9uCagfvSIxM/Ti_hENBqmNI/AAAAAAAAACU/Dy647xPuLQw/s72-c/nuget.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-7281741720342769162</id><published>2011-05-25T11:45:00.000+01:00</published><updated>2011-05-25T11:45:08.439+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mercurial'/><category scheme='http://www.blogger.com/atom/ns#' term='extensions'/><category scheme='http://www.blogger.com/atom/ns#' term='kdiff3'/><category scheme='http://www.blogger.com/atom/ns#' term='mercurial.ini'/><category scheme='http://www.blogger.com/atom/ns#' term='extdiff'/><category scheme='http://www.blogger.com/atom/ns#' term='merge-tools'/><category scheme='http://www.blogger.com/atom/ns#' term='winmerge'/><category scheme='http://www.blogger.com/atom/ns#' term='p4merge'/><title type='text'>Mercurial Stress Relief</title><content type='html'>Reduce your stress levels when using Mercurial by configuring a few easily accessible diff tools and your favourite merge tool before you get knee-deep in it.&lt;br /&gt;&lt;br /&gt;In your Mercurial.ini file, enable the built-in [extdiff] extension:&lt;br /&gt;&lt;br /&gt;[extensions]&lt;br /&gt;extdiff =&lt;br /&gt;&lt;br /&gt;Then flesh out the available diff tools you want to use. &amp;nbsp;In my example, I offer up P4Merge, WinMerge, and KDiff3:&lt;br /&gt;&lt;br /&gt;[extdiff]&lt;br /&gt;p4diff = "Path to p4merge.exe"&lt;br /&gt;windiff = "Path to winmergeu.exe"&lt;br /&gt;kdiff = "Path to kdiff3.exe"&lt;br /&gt;&lt;br /&gt;Then at the command prompt you can:&lt;br /&gt;&lt;br /&gt;hg p4diff -r5:3 MyProject/Program.cs&lt;br /&gt;&lt;br /&gt;hg windiff -r5:3 MyProject/Program.cs&lt;br /&gt;&lt;br /&gt;hg kdiff&amp;nbsp;-r5:3 MyProject/Program.cs&lt;br /&gt;&lt;br /&gt;This will present the diff tool on Program.cs between local revisions 5 and 3. &amp;nbsp;Surprisingly cool and much better than the Mercurial diff splurge you get in the command console.&lt;br /&gt;&lt;br /&gt;I also suggest wiring in your favourite merge tool, currently mine is p4merge because of it's ability to have you select all three potential choices and see them all in place - allows you to read the code a lot faster and make more sense of it.&lt;br /&gt;&lt;br /&gt;Add this to your Mercurial.ini:&lt;br /&gt;&lt;br /&gt;[merge-tools]&lt;br /&gt;p4.priority = 100&lt;br /&gt;p4.premerge = True&lt;br /&gt;p4.executable = "Path to p4merge.exe"&lt;br /&gt;p4.gui = True&lt;br /&gt;p4.args = $base $local $other $output&lt;br /&gt;p4.binary = False&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-7281741720342769162?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/7281741720342769162/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/05/mercurial-stress-relief.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7281741720342769162'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7281741720342769162'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/05/mercurial-stress-relief.html' title='Mercurial Stress Relief'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-3902114583724356100</id><published>2011-05-24T14:27:00.001+01:00</published><updated>2011-11-16T20:18:16.791Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='dynamic'/><category scheme='http://www.blogger.com/atom/ns#' term='expandoobject'/><category scheme='http://www.blogger.com/atom/ns#' term='dlr'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><title type='text'>ExpandoObject Runtime Members</title><content type='html'>If you've ever played with the &lt;a href="http://msdn.microsoft.com/en-us/library/system.dynamic.expandoobject.aspx"&gt;ExpandoObject&lt;/a&gt;&amp;nbsp;then you likely immediately wondered how to get members into it at runtime, instead of at compile-time.&lt;br /&gt;&lt;br /&gt;It is actually very simple and relatively elegant. &amp;nbsp;You simply cast your dynamic ExpandoObject into an IDictionary&lt;string, object=""&gt; reference, and then you can add string literals to it as if they were members. &amp;nbsp;Then when you go to access your dynamic reference, you can hard-code the reference in it and it will resolve to the same member:&lt;/string,&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://stackoverflow.com/questions/2974008/adding-unknown-at-design-time-properties-to-an-expandoobject"&gt;http://stackoverflow.com/questions/2974008/adding-unknown-at-design-time-properties-to-an-expandoobject&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-3902114583724356100?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/3902114583724356100/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/05/expandoobject-runtime-members.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/3902114583724356100'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/3902114583724356100'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/05/expandoobject-runtime-members.html' title='ExpandoObject Runtime Members'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-4839732211847461227</id><published>2011-05-20T14:45:00.000+01:00</published><updated>2011-05-20T14:45:45.095+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mercurial'/><category scheme='http://www.blogger.com/atom/ns#' term='collapse extension'/><category scheme='http://www.blogger.com/atom/ns#' term='changeset'/><category scheme='http://www.blogger.com/atom/ns#' term='test'/><category scheme='http://www.blogger.com/atom/ns#' term='unit test'/><title type='text'>Mercurial Tactics</title><content type='html'>Today I stumbled across a powerful little way to use Mercurial that helps narrow down debugging situations on large code-bases.&lt;br /&gt;&lt;br /&gt;I happened to be making small commits in Mercurial, this has the effect of making quite a large changeset history. &amp;nbsp; &amp;nbsp;I then stumbled across a bug when I got to my testing cycle that was introduced by me.&lt;br /&gt;&lt;br /&gt;Using the changesets I could update my code-base to older changesets and run my unit tests. &amp;nbsp;Based on finding the first changeset that caused the unit test to fail, and coupled with the fact I did small commits meaning less files to search, I was able to fairly quickly identify the line of code introducing the data bug.&lt;br /&gt;&lt;br /&gt;To avoid the downside of very small and logically pointless changesets, you can group related changesets together using the Collapse extension. &amp;nbsp;This can only work on changesets that have not yet been pushed to the server!&lt;br /&gt;&lt;br /&gt;Also, once collapsed, they cannot be expanded, so make sure you are happy with the testing and quality of your code before you collapse and push.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-4839732211847461227?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/4839732211847461227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/05/mercurial-tactics.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/4839732211847461227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/4839732211847461227'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/05/mercurial-tactics.html' title='Mercurial Tactics'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-7390774370478722269</id><published>2011-03-23T11:52:00.000Z</published><updated>2011-03-23T11:52:42.645Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='axum'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='microsoft'/><title type='text'>Axum Ends</title><content type='html'>In hindsight, it was somewhat inevitable. &amp;nbsp;The Axum incubation project has come to an end:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://blogs.msdn.com/b/maestroteam/archive/2011/02/28/the-state-of-axum.aspx"&gt;http://blogs.msdn.com/b/maestroteam/archive/2011/02/28/the-state-of-axum.aspx&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;However, as the link mentions, some ideas have continued. &amp;nbsp;Along with Axum was the fantastic push from Microsoft to get parallel programming into the mainstream of .NET development through library and language support (TPL, async), but it was never going to address the &lt;a href="http://en.wikipedia.org/wiki/Axum_(programming_language)"&gt;actor model design that Axum provided&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After using the hint from the Axum post&amp;nbsp;for ".NET data flow constructs", I find this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://blogs.msdn.com/b/pfxteam/archive/2010/10/28/10081950.aspx"&gt;http://blogs.msdn.com/b/pfxteam/archive/2010/10/28/10081950.aspx&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Roll-on message passing and &lt;a href="http://www.stackless.com/"&gt;tasklets&lt;/a&gt; in C#!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-7390774370478722269?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/7390774370478722269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/03/axum-ends.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7390774370478722269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7390774370478722269'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2011/03/axum-ends.html' title='Axum Ends'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-7135024712162929344</id><published>2010-11-04T13:09:00.000Z</published><updated>2010-11-04T13:09:48.956Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='mercurial'/><category scheme='http://www.blogger.com/atom/ns#' term='bitbucket'/><category scheme='http://www.blogger.com/atom/ns#' term='late to the game'/><category scheme='http://www.blogger.com/atom/ns#' term='source control'/><title type='text'>Using Mercurial and BitBucket</title><content type='html'>Source control is, aside from your IDE of choice, likely going to be the single most important tool in your development box.&amp;nbsp; It allows you to keep full history on the evolution of your code base.&lt;br /&gt;&lt;br /&gt;More importantly, it allows you to undo those too-many-drinks, not-enough-sleep,&amp;nbsp;not-enough-time induced changes that you foolishly commit.&lt;br /&gt;&lt;br /&gt;Knowing this, and fully appreciating it in the workplace, I find that at home it's a whole different story: think, wing and a prayer.&lt;br /&gt;&lt;br /&gt;Using this as the impetus, I decided to look into Git - with the idea of getting into the new "distributed" source control systems.&amp;nbsp; As soon as you start looking at Git, you hear about Mercurial.&amp;nbsp; As soon as you have multiple choices, you likely Google "Git vs. Mercurial".&amp;nbsp; Doing so might land you here:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://importantshock.wordpress.com/2008/08/07/git-vs-mercurial/"&gt;http://importantshock.wordpress.com/2008/08/07/git-vs-mercurial/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This is actually a good read and concludes: Git is powerful and massively configurable, geared towards Linux styled development; Mercurial trades the configuration for ease of use.&amp;nbsp; Feature-wise, there are some differences, but nothing that stopped me using one for the other.&lt;br /&gt;&lt;br /&gt;I chose Mercurial in the end, as the title suggests, as I wanted the ease of use and the fact that Mercurial seems less hostile towards Windows ;-)&lt;br /&gt;&lt;br /&gt;Along with Mercurial, I chose to also get into it's associated hosting site: &lt;a href="http://www.bitbucket.org/"&gt;http://www.bitbucket.org/&lt;/a&gt;.&amp;nbsp; Free to use for limited users; paid options also.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Mercurial - Distributed&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;This is, perhaps, the single most important part of my experience with it.&amp;nbsp; There is a concept of a central repository, either locally, server-based, or web-based.&amp;nbsp; I'm currently web-based.&lt;br /&gt;&lt;br /&gt;It's cool because you maintain a version of the repository on your computer (or wherever you happen to work out of).&amp;nbsp; This version includes any changesets in the repository&amp;nbsp;when you 'clone' (up to the version you clone from), and any of your own changesets that you later add.&lt;br /&gt;&lt;br /&gt;You can clone as much as you like, meaning if you need to suddenly change direction and try something else, you can either re-clone the repository or clone your own branch.&amp;nbsp; Either way, clones don't pollute each other and use the idea of changesets (defined by when you 'commit') when merging across branches of the repository.&lt;br /&gt;&lt;br /&gt;When you are done, you can 'push' your changes back to the repository.&amp;nbsp; I currently do this from home, any pushes to the repository on BitBucket&amp;nbsp;and I guarantee that they compile.&amp;nbsp; At work, when I program on my own stuff at lunch, I push changes to a fork of my repository - a bitbucket feature.&amp;nbsp; I can then 'pull' changes from my fork into my main repository whenever.&amp;nbsp; I do this because at work I cannot guarantee I have the time to fix any bugs before pushing to the server.&lt;br /&gt;&lt;br /&gt;If for whatever reason things don't work or you need to revert a changeset, you can do so.&amp;nbsp; You can also remove changesets historically... yes, a merging hell situation may have just flashed in your mind right then; it did with me.&lt;br /&gt;&lt;br /&gt;A brilliant introduction and subsequent tutorial to Mercurial is available (worth a read, I used it and it got me up and running in an evening):&lt;br /&gt;&lt;br /&gt;&lt;a href="http://hginit.com/"&gt;http://hginit.com/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;BitBucket&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;This is just cool and is&amp;nbsp;working very well with the way I program and the way I want to use a DVCS.&lt;br /&gt;&lt;br /&gt;The site also offers usability features such as forking;&amp;nbsp;proposing/accepting pull requests; bug and change tracking; a wiki; and changeset history views.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Future&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Currently, I can't really offer any advice on gotchas and whatnot, I've only just started using it.&amp;nbsp; One thing I am considering though, is to use &lt;a href="http://www.fogcreek.com/kiln/"&gt;Kiln&lt;/a&gt;&amp;nbsp;as my new Mercurial tool (currently I'm command-lining it); it appears to be free for one user (branded "for students and startups").&amp;nbsp; It offers hosting options and a UI, which could be immensely useful for reviewing changes, or comparing branches graphically.&lt;br /&gt;&lt;br /&gt;Definitely worth 30 minutes of your time looking at!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-7135024712162929344?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/7135024712162929344/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/11/using-mercurial-and-bitbucket.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7135024712162929344'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7135024712162929344'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/11/using-mercurial-and-bitbucket.html' title='Using Mercurial and BitBucket'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-8916332680043273089</id><published>2010-10-23T13:43:00.001+01:00</published><updated>2011-04-18T09:45:47.709+01:00</updated><title type='text'>64bit Custom Actions</title><content type='html'>In a C# Setup / Deployment Project, you can add custom pieces of code that run at certain points in order to fulfill a specific requirement - these are called Custom Actions.&lt;br /&gt;&lt;br /&gt;When you live in the 32bit world, life is good. When you want to move into the 64bit world, you may find that your installer MSI suddenly starts reporting a BadImageFormatException.&lt;br /&gt;&lt;br /&gt;Straight to the point, this is because your 64bit code is being called from a 32bit DLL internally within the MSI. The culprit is &lt;b&gt;InstallUtilLib.dll&lt;/b&gt;:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;%WINDIR%\Microsoft.NET\Framework\*version*&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;To fix the issue, you need to embed the &lt;b&gt;64bit InstallUtilLib.dll&lt;/b&gt; from:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;%WINDIR%\Microsoft.NET\Framework64\*version*&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;However, Visual Studio doesn't let you break open MSI files. For some reason it tries to run them. You need to use a tool such as &lt;b&gt;Orca:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.technipages.com/download-orca-msi-editor.html"&gt;http://www.technipages.com/download-orca-msi-editor.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To crack open the MSI.&amp;nbsp; Basically, the steps to do this are simple:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;In Orca, open the MSI for the 64bit release.&lt;/li&gt;&lt;li&gt;In the left-hand pane, find the entry called "Binary"; highlight it.&lt;/li&gt;&lt;li&gt;In the right-hand pane, find the entry called "InstallUtil".&lt;/li&gt;&lt;li&gt;Double-click the "Binary Data" cell; this will open a dialog.&lt;/li&gt;&lt;li&gt;Browse to the 64bit InstallUtilLib.dll under Framework64; then click OK.&lt;/li&gt;&lt;ol&gt;&lt;li&gt;If your development machine isn't 64bit and you don't have this folder, you can grab the file from another PC - likely the client PC wanting to install your application.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;"This will overwrite the current contents of the stream.&amp;nbsp; Continue?"; click OK.&lt;/li&gt;&lt;li&gt;File -&amp;gt; Save.&lt;/li&gt;&lt;li&gt;Done.&lt;/li&gt;&lt;/ol&gt;Your MSI will now install correctly on a 64bit client PC, including running any of your custom actions.&lt;br /&gt;&lt;br /&gt;It's unfortunate that this is a manual step, but I've yet to determine if it can be automated - feel free to drop a comment if you know.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-8916332680043273089?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/8916332680043273089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/10/64bit-custom-actions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/8916332680043273089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/8916332680043273089'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/10/64bit-custom-actions.html' title='64bit Custom Actions'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-5012606189609433495</id><published>2010-10-16T16:03:00.010+01:00</published><updated>2010-10-16T17:31:49.548+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ninject'/><category scheme='http://www.blogger.com/atom/ns#' term='factory pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='late to the game'/><title type='text'>Ninject 2.0 – First Encounter</title><content type='html'>As of now I'm starting a feature: "Late to the Game"; for new things that I take ages to get around to trying.&lt;br /&gt;&lt;br /&gt;This time around, it's &lt;a href="http://ninject.org/"&gt;Ninject 2.0&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I am currently working through a home project called Money Tracker, to enable me to keep tabs on my money (what little there is :-) and also as a learning tool for various development and design patterns I've recently come into contact with.&lt;br /&gt;&lt;br /&gt;My first use of Ninject, and possibly getting it wrong first time around, was to use Ninject's binding as the class factory for Business types.&amp;nbsp; This isn't atypical Dependency Injection, usually this is constructor/property/method injection, however the idea is similar - it allows me to swap out the Business types underneath the interface. &lt;br /&gt;&lt;br /&gt;Ninject allows you to inherit from NinjectModule, an abstract class that exposes a Load method.&amp;nbsp; I decided to expose this class in a shared assembly that references both the interface and implementation assemblies.&amp;nbsp; This is where I started failing to see the point in using Ninject and chalked it up to me not using it for its intended use…&lt;br /&gt;&lt;br /&gt;This is the code:&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MoneyTracker&lt;br /&gt;{&lt;br /&gt;&lt;span class="kwrd"&gt;    using&lt;/span&gt; System;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;    using&lt;/span&gt; Ninject;&lt;br /&gt;&lt;span class="kwrd"&gt;    using&lt;/span&gt; Ninject.Modules;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;    using&lt;/span&gt; MoneyTracker.Business;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;    public&lt;/span&gt; &lt;span class="kwrd"&gt;sealed&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; BusinessFactory : NinjectModule&lt;br /&gt;    {&lt;br /&gt;&lt;span class="kwrd"&gt;        internal&lt;/span&gt; BusinessFactory()&lt;br /&gt;        { }&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;        public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Load()&lt;br /&gt;        {&lt;br /&gt;            Bind&amp;lt;IAccount&amp;gt;().To&amp;lt;Account&amp;gt;();&lt;br /&gt;            Bind&amp;lt;ITransaction&amp;gt;().To&amp;lt;Transaction&amp;gt;();&lt;br /&gt;            Bind&amp;lt;ITransactionType&amp;gt;().To&amp;lt;TransactionType&amp;gt;();&lt;br /&gt;            Bind&amp;lt;IUser&amp;gt;().To&amp;lt;User&amp;gt;();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;        private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; StandardKernel _kernel;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;        public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; T Create&amp;lt;T&amp;gt;()&lt;br /&gt;        {&lt;br /&gt;            _kernel = _kernel ?? &lt;span class="kwrd"&gt;new&lt;/span&gt; StandardKernel(&lt;span class="kwrd"&gt;new&lt;/span&gt; BusinessFactory());&lt;br /&gt;&lt;span class="kwrd"&gt;            return&lt;/span&gt; _kernel.Get&amp;lt;T&amp;gt;();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;As you can see, I wrap this in a static method such that from the caller’s perspective, we have the following:&lt;br /&gt;&lt;pre class="csharpcode"&gt;IAccount acc = BusinessFactory.Create&amp;lt;IAccount&amp;gt;();&lt;br /&gt;acc.Name = &lt;span class="str"&gt;"Adam"&lt;/span&gt;;&lt;/pre&gt;The Ninject magic is all happening in the Bind method of the NinjectModule class.&amp;nbsp; The designers opted to use code to allow compile-time checking and strong typing to be featured.&amp;nbsp; This means that any errors in your bindings should be apparent prior to running the application – surprisingly useful if you ask me; XML configuration files are often useful, but runtime errors are annoying.&lt;br /&gt;&lt;br /&gt;The caller could alternatively use Ninject directly, but I decided to wrap it inside a domain-specific class factory because it then gives me flexibility if I decide to remove Ninject later, I won’t have to go changing a lot of calling code.&amp;nbsp; All I will have to do is implement my factory again without Ninject’s built-in mapping functionality.&lt;br /&gt;&lt;br /&gt;Ninject offers a lot more than what I’ve shown here.&amp;nbsp; In particular, you can bind to create constructor/property/method injection by applying an InjectAttribute to the relevant member; Ninject uses this as a plug-in point to inject the desired types at runtime, when the containing class is created.&lt;br /&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-5012606189609433495?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/5012606189609433495/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/10/ninject-20-first-encounter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5012606189609433495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5012606189609433495'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/10/ninject-20-first-encounter.html' title='Ninject 2.0 – First Encounter'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-1842576486330642466</id><published>2010-07-13T15:48:00.000+01:00</published><updated>2010-07-13T15:48:38.319+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='clr'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><title type='text'>Host the .NET CLR Yourself</title><content type='html'>I have an interest in things surrounding C#, the CLR/CLI, the .NET Frameworks etc, so often I find myself reading articles, whitepapers or blog posts on things outside of my day-to-day remit.&lt;br /&gt;&lt;br /&gt;I was reading this performance article:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms973838#dotnetperftechs_topic10"&gt;Performance Considerations for Run-Time Technologies in the .NET Framework&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;At the bottom is an interesting little code chunk - the CLR (server variety, multi-core optimised) being hosted by a custom C++ executable and running managed code from a non-standard entry point.&amp;nbsp; This gets me thinking about the potential uses for manually hosting things.&lt;br /&gt;&lt;br /&gt;Doing a little searching I came across an old MSDN Mag article:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163567.aspx"&gt;CLR Inside Out - CLR Hosting APIs&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;Turns out they've thought of this themselves and I'm way behind the times as usual!&lt;br /&gt;&lt;br /&gt;Apparently you can also host the CLR without having the .NET Framework installed... though you'd be hard-pressed to write any code to go in that (it looks interesting either way):&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.codeproject.com/KB/dotnet/HostCLRwithoutDotNet.aspx"&gt;Hosting CLR in Unmanaged Code without Dependency on .NET Framework&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.codeproject.com/KB/COM/simpleclrhost.aspx"&gt;Creating a Host Application for the .NET CLR&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;Further reading:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb822049.aspx"&gt;.NET Framework Versions and Dependencies&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-1842576486330642466?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/1842576486330642466/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/07/host-net-clr-yourself.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1842576486330642466'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1842576486330642466'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/07/host-net-clr-yourself.html' title='Host the .NET CLR Yourself'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-6847243431216537948</id><published>2010-07-06T13:16:00.005+01:00</published><updated>2010-07-06T13:32:48.861+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='garbage collection'/><category scheme='http://www.blogger.com/atom/ns#' term='server gc'/><category scheme='http://www.blogger.com/atom/ns#' term='gc'/><title type='text'>Server Garbage Collection Mode</title><content type='html'>Well, I didn't even realise there were Garbage Collection "modes".&amp;nbsp; I was reading the following parallel white paper:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://services.social.microsoft.com/feeds/FeedItem?feedId=639a99a9-ff25-4062-b61d-a86ea9d66a06&amp;amp;itemId=1b21d73b-64ca-40a3-b223-9d6190af5943&amp;amp;title=Parallel+Programming+in+.NET+4%3a+Coding+Guidelines&amp;amp;uri=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fB%2fC%2fF%2fBCFD4868-1354-45E3-B71B-B851CD78733D%2fParallelProgramsinNET4_CodingGuidelines.pdf&amp;amp;k=IEQ0nRkCa5MddZRhy8uBw6rsQhbjXbYDr2e%2fCWtl0OA%3d"&gt;Parallel Programming in .NET 4 - Coding Guidelines&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.hanselman.com/blog/UsingTheServerRatherThanWorkstationGarbageCollectorWithTheNETFrameworkCLR.aspx"&gt;Scott Hanselman Blog Post - Bonus Reading&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;On page 15 it refers to a consideration for using the &lt;strong&gt;&lt;em&gt;Server GC &lt;/em&gt;&lt;/strong&gt;and proceeds to give an example:&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;configuration&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;runtime&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;gcServer&lt;/span&gt; &lt;span class="attr"&gt;enabled&lt;/span&gt;&lt;span class="kwrd"&gt;="true"&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;runtime&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;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;To summarise, the main benefit of the Server GC mode is that it has heaps for each core, so garbage collection can occur in parallel.&amp;nbsp; This is beneficial if your application is heavily multi-threaded, however I would surmise that for the most-part a standard "background worker" threaded application will notice little benefit (in fact, they mention for standard scenarios to leave the GC mode well alone).&lt;br /&gt;&lt;br /&gt;Further searching yields a few sources on the various GC modes and their costs/benefits:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/b/maoni/archive/2004/09/25/234273.aspx"&gt;Using GC Efficiently - Part 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/b/clyon/archive/2007/03/12/new-in-orcas-part-3-gc-latency-modes.aspx"&gt;New In Orcas Part 3 - GC Latency Modes&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;And further reading the general topic area:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms228973.aspx"&gt;Constrained Execution Regions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/b/maoni/archive/2004/06/15/156626.aspx"&gt;Using GC Efficiently - Part 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/b/maoni/archive/2004/12/19/327149.aspx"&gt;Using GC Efficiently - Part 3&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/b/maoni/archive/2005/05/06/415296.aspx"&gt;Using GC Efficiently - Part 4&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-6847243431216537948?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/6847243431216537948/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/07/server-garbage-collection-mode.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6847243431216537948'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6847243431216537948'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/07/server-garbage-collection-mode.html' title='Server Garbage Collection Mode'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-2249387893354793911</id><published>2010-06-23T14:56:00.004+01:00</published><updated>2010-09-04T06:50:36.959+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='knowntypeattribute'/><category scheme='http://www.blogger.com/atom/ns#' term='datacontract'/><category scheme='http://www.blogger.com/atom/ns#' term='visual inheritance'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='knowntype'/><category scheme='http://www.blogger.com/atom/ns#' term='wcf'/><title type='text'>WCF DataContract Inheritance - KnownTypeAttribute</title><content type='html'>Pretty much a self-blogging title.&amp;nbsp; To include the ability to create an object heirarchy via inheritance and have it serialise across WCF (in my case, as XML) you need to (on the base class no less!) specify the KnownTypeAttribute passing the typeof(DerivedClass) for each derived class there is.&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.knowntypeattribute.aspx"&gt;MSDN entry for this attribute&lt;/a&gt; has even more cryptic examples.&lt;br /&gt;&lt;br /&gt;Is this a little backwards, or is it just me?&lt;br /&gt;&lt;br /&gt;Further reading:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms730167.aspx"&gt;Data Contract Known Types - MSDN&lt;/a&gt;&amp;nbsp;- various uses of KnownTypeAttribute.&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms751512.aspx"&gt;Known Types - MSDN&lt;/a&gt;&amp;nbsp;- specific use of KnownTypeAttribute for inheritance.&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms729813.aspx"&gt;Data Member Order -&amp;nbsp;MSDN&lt;/a&gt;&amp;nbsp;- shows sample XML of derived objects.&lt;br /&gt;&lt;br /&gt;It feels backwards because it can also be used to promote a type to another type when deserialising.&amp;nbsp; This is possible because the schema used when deserialising does not have any knowledge of type hierarchy.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Update:&lt;/strong&gt; turns out I didn't need the KnownTypeAttribute because my base class and derived class both shared a Namespace of "".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-2249387893354793911?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/2249387893354793911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/06/wcf-datacontract-inheritance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2249387893354793911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2249387893354793911'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/06/wcf-datacontract-inheritance.html' title='WCF DataContract Inheritance - KnownTypeAttribute'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-2435579601727386657</id><published>2010-06-04T14:23:00.002+01:00</published><updated>2010-06-04T14:25:32.196+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='db4o'/><category scheme='http://www.blogger.com/atom/ns#' term='eloquera'/><category scheme='http://www.blogger.com/atom/ns#' term='oodb'/><category scheme='http://www.blogger.com/atom/ns#' term='db'/><title type='text'>Eloquera DB</title><content type='html'>I spotted a thread on StackOverflow asking if anyone had experience in &lt;a href="http://www.db4o.com/"&gt;&lt;strong&gt;db4o&lt;/strong&gt;&lt;/a&gt; or &lt;a href="http://eloquera.com/page/home.aspx"&gt;&lt;strong&gt;Eloquera&lt;/strong&gt;&lt;/a&gt;...&lt;br /&gt;&lt;br /&gt;I've heard of db4o, the open source object-oriented database.&amp;nbsp; However,&amp;nbsp;I've&amp;nbsp;never heard of or even stumbled across&amp;nbsp;Eloquera DB. After browsing their site and downloading the application, it appears to be able to fill a gap I've currently got - a valid alternative to VistaDb/SQL-CE for desktop databases.&amp;nbsp; Also, looking at the site blog, it appears as though I'm years late to the game.&lt;br /&gt;&lt;br /&gt;It also ticks another two boxes for me at the moment - it's (apparently) &lt;strong&gt;entirely C# &lt;/strong&gt;and it's object-oriented.&lt;br /&gt;&lt;br /&gt;I'll hopefully make another post about using it (currently its all free) later, when my new Dell arrives!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-2435579601727386657?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/2435579601727386657/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/06/eloquera-db.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2435579601727386657'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2435579601727386657'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/06/eloquera-db.html' title='Eloquera DB'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-6909475933375294081</id><published>2010-03-31T16:36:00.004+01:00</published><updated>2010-04-01T08:03:13.961+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wow6432node'/><category scheme='http://www.blogger.com/atom/ns#' term='registry'/><category scheme='http://www.blogger.com/atom/ns#' term='BadImageFormatException'/><category scheme='http://www.blogger.com/atom/ns#' term='revit'/><category scheme='http://www.blogger.com/atom/ns#' term='interop'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='setup'/><category scheme='http://www.blogger.com/atom/ns#' term='pinvoke'/><title type='text'>64bit Registry from 32bit Application</title><content type='html'>Most of you are likely familiar with Microsoft.Win32.Registry.&amp;nbsp; Fantastically simple to use and tends to work.&amp;nbsp; Until you encounter the situation where you are stuck on a 32bit application (due in no small part to 3rd party DLLs, the bastards) and you need to look into the 64bit registry.&lt;br /&gt;&lt;br /&gt;The problem is, 32bit applications are silently redirected into the Wow6432Node area of the registry.&amp;nbsp; You have no say in this if you use the aforementioned class.&lt;br /&gt;&lt;br /&gt;The alternative I employed was provided by a forum post, a little pinvoke.net and a dash of MSDN:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://stackoverflow.com/questions/252297/why-is-regopenkeyex-returning-error-code-2-on-vista-64bit"&gt;http://stackoverflow.com/questions/252297/why-is-regopenkeyex-returning-error-code-2-on-vista-64bit&lt;/a&gt; &lt;br /&gt;&lt;a href="http://www.pinvoke.net/default.aspx/advapi32/RegOpenKeyEx.html"&gt;http://www.pinvoke.net/default.aspx/advapi32/RegOpenKeyEx.html&lt;/a&gt; &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms724878(VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms724878(VS.85).aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You use P/Invoke to chat to some older Registry API methods and specify that you don't want to be redirected.&lt;br /&gt;&lt;br /&gt;You then have to contend with these methods and some considerably less intuitive UIntPtr handles to get the values you require.&amp;nbsp; I needed two string values and a little method to see if a registry key actually existed.&amp;nbsp; After a little time, I created a complete working chunk of code from the three disparate sources (enjoy):&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;UIntPtr&lt;/span&gt; HKEY_LOCAL_MACHINE = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;UIntPtr&lt;/span&gt;(0x80000002u);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;UIntPtr&lt;/span&gt; HKEY_CURRENT_USER = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;UIntPtr&lt;/span&gt;(0x80000001u);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: green;"&gt;// http://msdn.microsoft.com/en-us/library/ms724878(VS.85).aspx&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; KEY_READ = (&lt;span style="color: blue;"&gt;int&lt;/span&gt;)&lt;span style="color: blue;"&gt;unchecked&lt;/span&gt;(0x00020019);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; KEY_WOW64_64KEY = (&lt;span style="color: blue;"&gt;int&lt;/span&gt;)&lt;span style="color: blue;"&gt;unchecked&lt;/span&gt;(0x0000100);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;[&lt;span style="color: #2b91af;"&gt;DllImport&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"advapi32.dll"&lt;/span&gt;, CharSet = &lt;span style="color: #2b91af;"&gt;CharSet&lt;/span&gt;.Auto)]&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;extern&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; RegOpenKeyEx(&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;In&lt;/span&gt;] &lt;span style="color: #2b91af;"&gt;UIntPtr&lt;/span&gt; hKey,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;In&lt;/span&gt;] &lt;span style="color: blue;"&gt;string&lt;/span&gt; subKey,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; ulOptions,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;In&lt;/span&gt;] &lt;span style="color: blue;"&gt;int&lt;/span&gt; samDesired,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;Out&lt;/span&gt;] &lt;span style="color: blue;"&gt;out&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;UIntPtr&lt;/span&gt; hkResult);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;[&lt;span style="color: #2b91af;"&gt;DllImport&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"advapi32.dll"&lt;/span&gt;, CharSet = &lt;span style="color: #2b91af;"&gt;CharSet&lt;/span&gt;.Unicode, EntryPoint = &lt;span style="color: #a31515;"&gt;"RegQueryValueExW"&lt;/span&gt;, SetLastError = &lt;span style="color: blue;"&gt;true&lt;/span&gt;)]&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;extern&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; RegQueryValueEx(&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;In&lt;/span&gt;] &lt;span style="color: #2b91af;"&gt;UIntPtr&lt;/span&gt; hKey,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;In&lt;/span&gt;] &lt;span style="color: blue;"&gt;string&lt;/span&gt; lpValueName,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; lpReserved,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;Out&lt;/span&gt;] &lt;span style="color: blue;"&gt;out&lt;/span&gt; &lt;span style="color: blue;"&gt;uint&lt;/span&gt; lpType,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;Out&lt;/span&gt;] &lt;span style="color: #2b91af;"&gt;StringBuilder&lt;/span&gt; lpData,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;In&lt;/span&gt;, &lt;span style="color: #2b91af;"&gt;Out&lt;/span&gt;] &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: blue;"&gt;uint&lt;/span&gt; lpcbData);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;[&lt;span style="color: #2b91af;"&gt;DllImport&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"advapi32.dll"&lt;/span&gt;, SetLastError = &lt;span style="color: blue;"&gt;true&lt;/span&gt;)]&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;extern&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; RegCloseKey(&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;In&lt;/span&gt;] &lt;span style="color: #2b91af;"&gt;UIntPtr&lt;/span&gt; hKey);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; RegKeyExists(&lt;span style="color: blue;"&gt;string&lt;/span&gt; key)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;UIntPtr&lt;/span&gt; keyHandle = &lt;span style="color: #2b91af;"&gt;UIntPtr&lt;/span&gt;.Zero;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ | KEY_WOW64_64KEY, &lt;span style="color: blue;"&gt;out&lt;/span&gt; keyHandle);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (result == 0)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; RegCloseKey(keyHandle);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; result == 0;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; RegKeyValue(&lt;span style="color: blue;"&gt;string&lt;/span&gt; key, &lt;span style="color: blue;"&gt;string&lt;/span&gt; value)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;UIntPtr&lt;/span&gt; keyHandle = &lt;span style="color: #2b91af;"&gt;UIntPtr&lt;/span&gt;.Zero;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ | KEY_WOW64_64KEY, &lt;span style="color: blue;"&gt;out&lt;/span&gt; keyHandle);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (result == 0)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;uint&lt;/span&gt; size = 1024;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;uint&lt;/span&gt; type;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;string&lt;/span&gt; keyValue = &lt;span style="color: blue;"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;StringBuilder&lt;/span&gt; keyBuffer = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;StringBuilder&lt;/span&gt;();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (RegQueryValueEx(keyHandle, value, 0, &lt;span style="color: blue;"&gt;out&lt;/span&gt; type, keyBuffer, &lt;span style="color: blue;"&gt;ref&lt;/span&gt; size) == 0)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; keyValue = keyBuffer.ToString();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; RegCloseKey(keyHandle);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; keyValue;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;My actual situation was installing an add-in for Revit 2010.&amp;nbsp; To see what Revit flavours are installed, you look at the Uninstall list in the registry, these are some Revit keys:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;const&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; REVIT_KEYS = &lt;span style="color: #a31515;"&gt;"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RAC_2010_32 = &lt;span style="color: #a31515;"&gt;"{572FBF5D-3BAA-42FF-A468-A54C2C0A17C3}"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RAC_2010_64 = &lt;span style="color: #a31515;"&gt;"{2A8EEE2F-4A9E-43D8-AA07-EC8A316B2DEB}"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RME_2010_32 = &lt;span style="color: #a31515;"&gt;"{5C8281B1-B927-495A-A0FF-AB4BDFAE505C}"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RME_2010_64 = &lt;span style="color: #a31515;"&gt;"{A1BD042B-8A6F-4E37-92A3-78921BB45B05}"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RST_2010_32 = &lt;span style="color: #a31515;"&gt;"{939D29FC-B82D-42A7-BB1E-8E3F121505CC}"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RST_2010_64 = &lt;span style="color: #a31515;"&gt;"{BC9C0A08-DEA4-4138-A7FB-8F68866DB0C1}"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RAC_2009_32 = &lt;span style="color: #a31515;"&gt;"{A3A37DA6-70C0-497C-BCB1-148E9EC1D32E}"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RAC_2009_64 = &lt;span style="color: #a31515;"&gt;"{D2466208-7348-4214-B01E-7BC8729E2BD3}"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RME_2009_32 = &lt;span style="color: #a31515;"&gt;"{E3781DCB-A650-4E66-9B74-67A1B17F052C}"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RME_2009_64 = &lt;span style="color: #a31515;"&gt;"{4A98F976-01B5-40E8-A496-AEFD85C3A446}"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RST_2009_32 = &lt;span style="color: #a31515;"&gt;"{C4B3B3C3-2EE9-48D3-9BF5-4443F7ECF759}"&lt;/span&gt;,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RST_2009_64 = &lt;span style="color: #a31515;"&gt;"{B354FCF5-CF64-4fA2-AA84-9D9B2A6FA649}"&lt;/span&gt;;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;This is where it goes pear-shaped on 64bit.&amp;nbsp; I tried making my application explicitly 64bit but started receiving BadImageFormatException exceptions - I promptly gave up that avenue.&amp;nbsp; My installer now uses the P/Invoke route if its on a 64bit OS.&lt;br /&gt;&lt;br /&gt;Oh, interesting note, the usual trick of checking the OS bit-ness:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;bool&lt;/span&gt; os64 = &lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt;.Size == 8;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Doesn't do what you think it does.&amp;nbsp; The IntPtr.Size will relate to the version of the .NET CLR being used, which was 32bit in my case - so I was being reported the incorrect size for the OS.&amp;nbsp; I use the following method, using WMI, to check the bit-ness of the underlying processors (well, the first one I hit):&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;internal&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; Is64BitOS()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;ManagementObjectSearcher&lt;/span&gt; searcher =&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ManagementObjectSearcher&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"SELECT * FROM&amp;nbsp; Win32_Processor"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: #2b91af;"&gt;ManagementObject&lt;/span&gt; processor &lt;span style="color: blue;"&gt;in&lt;/span&gt; searcher.Get())&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;object&lt;/span&gt; dataWidth = processor.GetPropertyValue(&lt;span style="color: #a31515;"&gt;"DataWidth"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; (&lt;span style="color: blue;"&gt;ushort&lt;/span&gt;)dataWidth == 64;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Hopefully, this will help someone else.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;&lt;img border="0" id="BLOGGER_PHOTO_ID_5310516322517916706" src="http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; cursor: hand; height: 49px; margin: 5px; position: relative; width: 50px;" title="Image by Jeff Atwood and Jon Galloway." /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-6909475933375294081?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/6909475933375294081/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/03/64bit-registry-from-32bit-application.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6909475933375294081'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6909475933375294081'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/03/64bit-registry-from-32bit-application.html' title='64bit Registry from 32bit Application'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-2686623160481605312</id><published>2010-03-12T11:54:00.001Z</published><updated>2010-03-12T12:03:29.691Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='gs'/><category scheme='http://www.blogger.com/atom/ns#' term='ghostscript'/><category scheme='http://www.blogger.com/atom/ns#' term='ps2pdf'/><category scheme='http://www.blogger.com/atom/ns#' term='ps'/><category scheme='http://www.blogger.com/atom/ns#' term='pdf'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='postscript'/><title type='text'>Ghostscript PDF Printing</title><content type='html'>I have a setup where a virtual printer on my computer prints to file. I can specify the file name in code (via the application that is printing) and it gives me a ps file; works like a charm.&lt;br /&gt;&lt;br /&gt;My first problem was the limited page size available of certain PS drivers on Windows - I rectified this by downloading and installing a HP driver:&lt;br /&gt;&lt;br /&gt;http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareIndex.jsp?lang=en&amp;amp;cc=us&amp;amp;prodNameId=12609&amp;amp;prodTypeId=18972&amp;amp;prodSeriesId=24023&amp;amp;swLang=8&amp;amp;taskId=135&amp;amp;swEnvOID=228&lt;br /&gt;&lt;br /&gt;This printer is huge, so gives page sizes all the way up to A0 - for virtual printing, you arguably want as many as you can get your hands on as its never going to actually print.&lt;br /&gt;&lt;br /&gt;OK, so problem solved. The next problem was that I was making use of 'ps2pdf' for conversion, this nicely wraps the calls to 'gswin32.exe' so that you don't have to use all the ugly arguments yourself. Unfortunately, if you want to print the correct page size, you will need those ugly arguments.&lt;br /&gt;&lt;br /&gt;My A0 postscript file was continually printing in A4 :(&lt;br /&gt;&lt;br /&gt;Cut out the middle man and go straight for 'gswin32c.exe':&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;gswin32c -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=12345 -dDEVICEHEIGHTPOINTS=12345 -sOutputFile="c:\test.pdf" "c:\test.ps"&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The important thing here is the dDEVICEWIDTHPOINTS and dDEVICEHEIGHTPOINTS, as explained in the documentation, equate to 1/72nd of an inch.&amp;nbsp; Luckily, postscript is already giving us the correct points.&amp;nbsp; In your .ps file, you will find a line that looks like this:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;%%PageBoundingBox 45 45 12300 12300&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Read this out and note the numbers.&amp;nbsp; From left to right they attribute to: width height width height.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Note&lt;/strong&gt; that if you are printing landspace, the numbers look like they should be inverted - i.e. width will be smaller than height, but logic says it should be bigger.&amp;nbsp; Don't invert them, the conversion inverts it all later, so width will always be width regardless of orientation; same for height.&amp;nbsp; Try it and see.&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Add the pairs together to get your width and height, and plug this into the 'gswin32c' call; correct page sizing ensues.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-2686623160481605312?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/2686623160481605312/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/03/ghostscript-pdf-printing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2686623160481605312'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2686623160481605312'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/03/ghostscript-pdf-printing.html' title='Ghostscript PDF Printing'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-5426064968626969422</id><published>2010-03-09T20:40:00.001Z</published><updated>2010-03-18T08:53:37.364Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='ra0000'/><category scheme='http://www.blogger.com/atom/ns#' term='regasm'/><category scheme='http://www.blogger.com/atom/ns#' term='com'/><title type='text'>RegAsm RA0000 ...</title><content type='html'>My god, an entire day obliterated running in circles trying to get a class registered for COM via regasm.exe, all the while receiving:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;RA0000 The specified module could not be found ...&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Ummm, ok.&lt;br /&gt;&lt;br /&gt;Googling only yields, "I had this random error ... turns out its [assembly: ComVisible(true)] !",&amp;nbsp;unfortunately for me, turns out its not.&lt;br /&gt;&lt;br /&gt;I managed to get myself hung on this and other related things, such as "always sign COM exposed .NET DLLs" and other such ravings.&lt;br /&gt;&lt;br /&gt;Simply, there was code in my DLL that was causing the registration to struggle to resolve a type - I've no idea why this is the case, to be honest I won't know for a while as its put me behind.&amp;nbsp; I would assume that Fusion Log viewer will be able to answer this.&lt;br /&gt;&lt;br /&gt;I had to make another DLL devoid of everything aside from a reference to my main DLL and use it as a pass through call, so that I could register this shim DLL with COM and immediately pass the heavy lifting off to the main DLL that refused to register.&lt;br /&gt;&lt;br /&gt;In a future post, I'll post the code and my findings of why it had trouble resolving references.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-5426064968626969422?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/5426064968626969422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/03/regasm-ra0000.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5426064968626969422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5426064968626969422'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/03/regasm-ra0000.html' title='RegAsm RA0000 ...'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-1868612382800533341</id><published>2010-02-26T21:21:00.002Z</published><updated>2010-02-26T21:23:59.926Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='vs2005'/><category scheme='http://www.blogger.com/atom/ns#' term='visual studio'/><category scheme='http://www.blogger.com/atom/ns#' term='vs2008'/><title type='text'>Visual Studio Notes</title><content type='html'>This is my sticky post of Visual Studio related things; mostly problems.&amp;nbsp; &lt;strong&gt;All my sticky posts appear on the navigation bar to the right ---&amp;gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Alphabetical, because I'm nice.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; font-size: large;"&gt;&lt;u&gt;VS 2008&lt;/u&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://adamhouldsworth.blogspot.com/2010/02/vs2008-crash-on-load.html"&gt;Crash On Load&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://adamhouldsworth.blogspot.com/2009/03/vs2008-no-dataset-designer.html"&gt;No DataSet Designer&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://adamhouldsworth.blogspot.com/2010/02/vs2008-toolbox-missing-items.html"&gt;Toolbox Missing Items&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-1868612382800533341?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/1868612382800533341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/visual-studio-sticky.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1868612382800533341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1868612382800533341'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/visual-studio-sticky.html' title='Visual Studio Notes'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-198650568346219358</id><published>2010-02-26T20:35:00.001Z</published><updated>2010-03-30T16:59:25.553+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vs2008'/><category scheme='http://www.blogger.com/atom/ns#' term='toolbox'/><title type='text'>VS2008 Toolbox Missing Items</title><content type='html'>I'm sure you've had it before.&amp;nbsp; You are developing a WinForms application and have been happily using your controls direct from the toolbox, only to find one day you've been burgled and your controls are missing!&lt;br /&gt;&lt;br /&gt;Well, this happened to me today.&amp;nbsp; A quick Google yielded this from MSDN:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/490c9f52-f0c3-4fd3-9770-b8be9e0fd9d9"&gt;http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/490c9f52-f0c3-4fd3-9770-b8be9e0fd9d9&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It was actually the problem I was having too - my project file was seated under a solution folder.&amp;nbsp; Luckily for me, the solution folder was superfluous so it got binned.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-198650568346219358?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/198650568346219358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/vs2008-toolbox-missing-items.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/198650568346219358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/198650568346219358'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/vs2008-toolbox-missing-items.html' title='VS2008 Toolbox Missing Items'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-5467489795959598445</id><published>2010-02-25T10:30:00.015Z</published><updated>2011-07-29T21:54:24.540+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tricks'/><category scheme='http://www.blogger.com/atom/ns#' term='features'/><category scheme='http://www.blogger.com/atom/ns#' term='hacks'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='using'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><title type='text'>I Didn't Know That...</title><content type='html'>This is a sticky post about&amp;nbsp;features, tricks, hacks, styles,&amp;nbsp;etc to do with programming.&lt;br /&gt;&lt;br /&gt;I'll fess up now and say there is a large proportion on this list that I only found out shortly before it&amp;nbsp;made the list :)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; font-size: large;"&gt;C#&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family: inherit;"&gt;You can stack using statements of differing types, and comma-delimit those of the same type:&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: #2b91af;"&gt;SqlConnection&lt;/span&gt; conn = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;SqlConnection&lt;/span&gt;(data.MasterConnectionString))&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: #2b91af;"&gt;SqlCommand&lt;/span&gt; comm1 = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;SqlCommand&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;""&lt;/span&gt;, conn),&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; comm2 = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;SqlCommand&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;""&lt;/span&gt;, conn))&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; conn.Open();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; comm1.ExecuteNonQuery();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; comm2.ExecuteNonQuery();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&amp;nbsp;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Notice the use of bracketing. Comma-delimited usings share the same 'using ()' brackets, whereas stacked usings are bracketed individually and share only the curly braces {}.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;You can create your own in-line scope&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; HeavyMathsEnsues()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; i = 0;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; j = 1;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; i += j;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i += j; &lt;span style="color: green;"&gt;// Compile error: "The name 'j' does not exist in the current context."&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Simply use the brackets and notice that your variables are not available outside of it - I've yet to examine the IL produced to see if it pops the variable sooner, which could be useful for mathematically intensive methods that go through lots of temporary variables.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;You can chain the ?? operator&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Straight from StackOverflow:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;string result = value1 ?? value2 ?? value3 ?? String.Empty; &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The 'sealed' keyword&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;I knew this could be applied to a class, but I never tried applying it to methods and properties! If you do this when you override a virtual member, you can provide an implementation in a derived class and lock it such that further derived classes cannot override again.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Unexpected struct behaviour&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;When you sit and think about it, you can figure this out yourself.&amp;nbsp; I've personally had experience with the former and the latter was recently spoken about by a colleague.&lt;br /&gt;&lt;br /&gt;The first situation happens when you attempt to access a struct that is a member of another type, and then try to access properties of that struct.&lt;br /&gt;&lt;br /&gt;&lt;div style="background: white; color: black; font-family: Consolas; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;MyClass&lt;/span&gt; c = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;MyClass&lt;/span&gt;();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;c.StructMember.PropertyOne = 2;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;c.StructMember.PropertyTwo = 1;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;As structs are value types, when you attempt to access this struct you are actually getting a copy of it - returned from the housing type's getter.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;You may not realise until runtime that your code is actually grabbing a temporary copy, modifying it, then immediately binning it.&amp;nbsp; Going on to test the class member struct will show you that nothing has been modified.&lt;br /&gt;&lt;br /&gt;&lt;div style="background: white; color: black; font-family: Consolas; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;MyStruct&lt;/span&gt; s = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;MyStruct&lt;/span&gt;(1);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;MyInterface&lt;/span&gt; si = (&lt;span style="color: #2b91af;"&gt;MyInterface&lt;/span&gt;)s;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;si.IncrementMyValue();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;Console&lt;/span&gt;.WriteLine(si.MyValue); &lt;span style="color: green;"&gt;// Prints 2, correct.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;Console&lt;/span&gt;.WriteLine(s.MyValue); &lt;span style="color: green;"&gt;// Prints 1, not correct.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;s.IncrementMyValue();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;Console&lt;/span&gt;.Write(s.MyValue); &lt;span style="color: green;"&gt;// Prints 2, now correct.5&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;The second situation stems from the same point as the first: value type semantics.&amp;nbsp; If your struct implements an interface and that interface modifies the struct, then you may hit a problem that if you cast your struct reference to the interface type you are boxing a copy of the original struct.&amp;nbsp; Operating on the interface then works on a copy of the struct.&amp;nbsp; You don't get any issues if the struct reference is acted on directly.&lt;br /&gt;&lt;br /&gt;A good point to take from these two examples is that you should aim to make structs immutable - don't expose setters or allow fields/properties to change once it is instantiated.&amp;nbsp; This means that any changes required will need a new reference to a new struct, this is a deliberate developer step so it's quite explicit.&amp;nbsp; It also forces any interface methods into being side-effect free (won't/can't&amp;nbsp;modify state).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; font-size: large;"&gt;&lt;b&gt;&lt;u&gt;.NET Framework&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Math.Abs()&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;This will return a positive number given a positive or negative argument. &amp;nbsp;A nice alternative to spaghetti code that checks if a number is less than zero!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;&lt;img border="0" id="BLOGGER_PHOTO_ID_5310516322517916706" src="http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png" style="border: currentColor; height: 49px; margin: 5px; position: relative; width: 50px;" title="Image by Jeff Atwood and Jon Galloway." /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-5467489795959598445?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/5467489795959598445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/things-you-dont-know.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5467489795959598445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5467489795959598445'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/things-you-dont-know.html' title='I Didn&apos;t Know That...'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-8063573761208669035</id><published>2010-02-15T19:22:00.000Z</published><updated>2010-02-15T19:22:43.340Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='tab'/><category scheme='http://www.blogger.com/atom/ns#' term='designer'/><category scheme='http://www.blogger.com/atom/ns#' term='load'/><category scheme='http://www.blogger.com/atom/ns#' term='suo'/><category scheme='http://www.blogger.com/atom/ns#' term='crash'/><category scheme='http://www.blogger.com/atom/ns#' term='code tab'/><category scheme='http://www.blogger.com/atom/ns#' term='visual studio 2008'/><title type='text'>VS2008 Crash On Load</title><content type='html'>OK this was annoying.&amp;nbsp; I am in the throes of creating a base form and on my first pass with a derived class, the designer caused Visual Studio to crash.&lt;br /&gt;&lt;br /&gt;When I went to reload the solution again, it had remembered my open tabs and opened the tab that caused the crash - rinse and repeat 3 times...&lt;br /&gt;&lt;br /&gt;This sort of information (along with breakpoints, bookmarks, and other things) is held in the .suo file that sits alongside your .sln file and is user-specific.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://stackoverflow.com/questions/1354052/visual-studio-2008-moving-solution-files-sln-suo/1354066"&gt;It is safe to delete&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://dotnet.org.za/cjlotz/archive/2009/08/10/keep-an-eye-on-those-suo-files.aspx"&gt;It can sometimes degrade IDE performance&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;As far as I can surmise, there are also no .suo file editors available to manually remove the offending tab.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-8063573761208669035?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/8063573761208669035/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/vs2008-crash-on-load.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/8063573761208669035'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/8063573761208669035'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/vs2008-crash-on-load.html' title='VS2008 Crash On Load'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-7732695812342376549</id><published>2010-02-15T18:34:00.007Z</published><updated>2011-02-25T09:28:00.848Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='usercontrol'/><category scheme='http://www.blogger.com/atom/ns#' term='user control'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='generics'/><category scheme='http://www.blogger.com/atom/ns#' term='winforms'/><category scheme='http://www.blogger.com/atom/ns#' term='visual inheritance'/><category scheme='http://www.blogger.com/atom/ns#' term='DataGridView'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><title type='text'>WinForms Visual Inheritance Limitations</title><content type='html'>&lt;b&gt;Update:&lt;/b&gt;&amp;nbsp;with regards to the comments below from Shaul, and some information extracted from StackOverflow, another workaround has been found to support resources provided by the generic base control to any derived controls:&lt;br /&gt;&lt;br /&gt;Q/A:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://stackoverflow.com/questions/5115267/descendant-generic-forms-cannot-display-in-the-form-designer/5115521#5115521"&gt;http://stackoverflow.com/questions/5115267/descendant-generic-forms-cannot-display-in-the-form-designer/5115521#5115521&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Supporting information:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://stackoverflow.com/questions/1627431/fix-embedded-resources-for-generic-usercontrol"&gt;http://stackoverflow.com/questions/1627431/fix-embedded-resources-for-generic-usercontrol&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Note that in the case of a non-generic base control, resource inheritance works without any problems.&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;I have a small personal project going that involves a WinForms GUI.&amp;nbsp; I have a series of data listing and editing user controls that I decided to refactor.&amp;nbsp; There were 5 of each, and out of each they used roughly 80%-90% of the same code, just with naming changes.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.itarchitect.co.uk/articles/display.asp?id=461"&gt;A fantastic case of "same whitespace, different values"&lt;/a&gt;.&amp;nbsp; I read this a long time ago, but for some reason it stuck.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Supporting Generics&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;My first port of call was a base class for each of the two user controls.&amp;nbsp; However, I wanted to migrate even logic involving the business class to the base class, which involved knowing about the business class type.&lt;br /&gt;&lt;br /&gt;Step in: Generics.&lt;br /&gt;&lt;br /&gt;Step in: &lt;a href="http://stackoverflow.com/questions/1329362/c-generics-usercontrol"&gt;first problem&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Using generics causes the designer interface in Visual Studio to crash, as it breaks one of the rules about knowing the base class type.&amp;nbsp; Microsoft explicitly say generics are not supported.&amp;nbsp; Fair enough.&lt;br /&gt;&lt;br /&gt;The workaround for this (as specified in the previous link) is to create a concrete implementation of the generic base class using a dummy intermediary:&lt;br /&gt;&lt;br /&gt;- BaseControl&amp;lt;T&amp;gt; : UserControl&lt;br /&gt;&lt;em&gt;&lt;strong&gt;- CustomerControl_Design : BaseControl&amp;lt;Customer&amp;gt;&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;- CustomerControl : CustomerControl_Design&lt;br /&gt;&lt;br /&gt;The CustomerControl_Design class will not have any designer support, and you shouldn't actually need it.&amp;nbsp; But, your CustomerControl class now does - the peasents rejoice.&lt;br /&gt;&lt;br /&gt;I've wrapped the code in compiler tags, so that when it doesn't need design-time support, superfluous code is cut:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;#if&lt;/span&gt; DEBUG&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;namespace&lt;/span&gt; MyNamespace&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;CustomerEditorControl_Design&lt;/span&gt; : BaseEditorControl&amp;lt;Customer&amp;gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; CustomerEditorControl_Design()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;span style="color: blue;"&gt;base&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;#endif&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;CustomerEditorControl&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;#if&lt;/span&gt; DEBUG&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;span style="color: #2b91af;"&gt;CustomerEditorControl_Design&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;#else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; : BaseEditorControl&amp;lt;Customer&amp;gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;#endif&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Supporting Visual Inheritance&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The next phase in our base user control is to allow a derived class to use UI elements we define at the base level (if we define any at all).&lt;br /&gt;&lt;br /&gt;Step in: &lt;a href="http://msdn.microsoft.com/en-us/library/1z3efhd2.aspx"&gt;Visual Inheritance&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Step in: &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=284335&amp;amp;wa=wsignin1.0"&gt;second problem&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Luckily, there is a documented workaround.&amp;nbsp; Simply create a custom class that inherits from DataGridView and append the following attribute:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;[&lt;span style="color: #2b91af;"&gt;Designer&lt;/span&gt;(&lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af;"&gt;ControlDesigner&lt;/span&gt;))]&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;InheritableDataGridView&lt;/span&gt; : &lt;span style="color: #2b91af;"&gt;DataGridView&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; InheritableDataGridView()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;span style="color: blue;"&gt;base&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Note that the ControlDesigner is part of the System.Windows.Forms.Design namespace, which is not a default DLL: you need to add a reference to System.Design.dll.&lt;br /&gt;&lt;br /&gt;It removes the DataGridView fully-featured designer, but gives you inherited access to properties.&amp;nbsp; You can still edit columns, but only manually and you get no context-menu designer integration, and no auto-creation of bound columns.&lt;br /&gt;&lt;br /&gt;You can now expose some complex functionality through a base user control.&amp;nbsp; Its cut my code down a lot.&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;&lt;img border="0" id="BLOGGER_PHOTO_ID_5310516322517916706" src="http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png" style="border: none; cursor: hand; cursor: pointer; height: 49px; margin: 5px; position: relative; width: 50px;" title="Image by Jeff Atwood and Jon Galloway." /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-7732695812342376549?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/7732695812342376549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/winforms-visual-inheritance-limitations.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7732695812342376549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7732695812342376549'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/winforms-visual-inheritance-limitations.html' title='WinForms Visual Inheritance Limitations'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-6219102106332938752</id><published>2010-02-10T10:13:00.000Z</published><updated>2010-02-10T10:13:43.806Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='reportviewer'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='export'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='reporting'/><title type='text'>Microsoft ReportViewer Exporting</title><content type='html'>After a little Googling, I found how to get the ReportViewer control to export to multiple formats.&amp;nbsp; I'm making use of the WinForms control, &lt;a href="http://bobp1339.blogspot.com/2007/11/rendering-ssrs-2005-reports-with-web.html"&gt;though there is a way to do this via the web service&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;You attach your server and report details to the control:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;reportViewer.ServerReport.ReportServerUrl = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Uri&lt;/span&gt;(report.Server);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;reportViewer.ServerReport.ReportPath = report.Path;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Note that the reportViewer.RefreshReport method is asynchronous using a BackgroundWorker.&amp;nbsp; However, some methods, like ServerReport.SetParameters will incur a hit onto the server, which is not asynchronous.&amp;nbsp; According to a source I spotted (but cannot find again), the ReportViewer, like any WinForms control, is &lt;strong&gt;not&lt;/strong&gt; thread safe.&amp;nbsp; However, the LocalReport and ServerReport objects are.&amp;nbsp; Put any calls to server-hitting methods from these objects into a background worker if its giving you performance problems.&lt;br /&gt;&lt;br /&gt;Using the following chunk of code:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;byte&lt;/span&gt;[] render = reportViewer.ServerReport.Render(&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; export, &lt;span style="color: blue;"&gt;null&lt;/span&gt;, &lt;span style="color: blue;"&gt;out&lt;/span&gt; mimeType, &lt;span style="color: blue;"&gt;out&lt;/span&gt; encoding, &lt;span style="color: blue;"&gt;out&lt;/span&gt; fileNameExtension,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;out&lt;/span&gt; streamIds, &lt;span style="color: blue;"&gt;out&lt;/span&gt; warnings);&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;We can modify the export parameter to &lt;a href="http://msdn.microsoft.com/en-us/library/ms154606.aspx"&gt;one of the following&lt;/a&gt; strings (on a standard SSRS server installation):&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;PDF&lt;/li&gt;&lt;li&gt;CSV&lt;/li&gt;&lt;li&gt;EXCEL&lt;/li&gt;&lt;li&gt;MHTML&lt;/li&gt;&lt;li&gt;IMAGE&lt;/li&gt;&lt;li&gt;XML&lt;/li&gt;&lt;li&gt;WORD&lt;/li&gt;&lt;li&gt;HTML4.0&lt;/li&gt;&lt;li&gt;NULL&lt;/li&gt;&lt;/ul&gt;Get yourself a file name and set the correct extension (an out parameter of the Render method):&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;fileName = &lt;span style="color: #2b91af;"&gt;Path&lt;/span&gt;.ChangeExtension(fileName, fileNameExtension);&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;And the render stream can be written directly to a file:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: #2b91af;"&gt;FileStream&lt;/span&gt; fs = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;FileStream&lt;/span&gt;(fileName, &lt;span style="color: #2b91af;"&gt;FileMode&lt;/span&gt;.Create))&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fs.Write(render, 0, render.Length);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;And there you have it.&amp;nbsp; I've not gone further to see how in-depth you can go in controlling these renderers. I've also yet to figure out how to specify the image output; it defaults to TIFF, but supports others.&lt;br /&gt;&lt;br /&gt;I've been deliberately vague on the implementation, as I just wanted to show what export options were available.&amp;nbsp; If you need a full start-to-finish example, just drop me an email or post a comment.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;&lt;img border="0" id="BLOGGER_PHOTO_ID_5310516322517916706" src="http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; cursor: hand; height: 49px; margin: 5px; position: relative; width: 50px;" title="Image by Jeff Atwood and Jon Galloway." /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-6219102106332938752?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/6219102106332938752/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/microsoft-reportviewer-exporting.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6219102106332938752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6219102106332938752'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/microsoft-reportviewer-exporting.html' title='Microsoft ReportViewer Exporting'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-4273739668996032781</id><published>2010-02-06T15:50:00.000Z</published><updated>2010-02-06T15:50:53.240Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='dispose'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='disposable pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='finalize'/><title type='text'>IDisposable - Disposable Pattern</title><content type='html'>Even though this has been done to death, I'm putting it here in my own words because I always forget the reasoning.&lt;br /&gt;&lt;br /&gt;Given the &lt;a href="http://msdn.microsoft.com/en-us/library/b1yfkh5e(VS.71).aspx"&gt;disposable pattern&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;#region&lt;/span&gt; IDisposable Members&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; _disposed;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;~MyClass()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dispose(&lt;span style="color: blue;"&gt;false&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;virtual&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Dispose(&lt;span style="color: blue;"&gt;bool&lt;/span&gt; disposing)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (!_disposed)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (disposing)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// Disposing from the dispose method.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// Disposing either from dispose or finalize.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _disposed = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Dispose()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dispose(&lt;span style="color: blue;"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;GC&lt;/span&gt;.SuppressFinalize(&lt;span style="color: blue;"&gt;this&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;#endregion&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;When and why do you implement finalizer (~MyClass)?&amp;nbsp; And what code goes where in this virtual Dispose method?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;When:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;I always forget when and why to implement the finalizer.&amp;nbsp; In my situation, a lot of the code I write is in other processes, or triggered by other applications.&amp;nbsp; In these situations, if you hold onto unmanaged resources and cannot call Dispose due to the flow of the application, then you will need to implement the Finalizer because this will be called by the Garbage Collector (GC)&amp;nbsp;(in normal circumstances).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Why:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Because otherwise there are unmanaged resources not being held by anything - memory leak.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What (code):&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Managed objects are managed by the GC, so its not your responsibility to free them if you are finalizing. If the user calls Dispose, its then your responsibility to propagate the dispose call to managed objects. The dispose pattern then further&amp;nbsp;states that Dispose also cleans up unmanaged objects and tells the GC not to (GC.SuppressFinalize).&lt;br /&gt;&lt;br /&gt;Finalize is an object's final boarding call and is driven by the GC; you put code in here to prevent memory leaks only (freeing unmanaged objects).&amp;nbsp; Disposing is a .NET convention that allows us to design systems where we can programmatically call for an object to Dispose internal objects and free unmanaged references.&amp;nbsp; It is not illegal to not call Dispose, hence finalizing is also available to your code if the consumer ignores dispose.&lt;br /&gt;&lt;br /&gt;If you implement the finalizer, you can optionally&amp;nbsp;call GC.SuppressFinalize to stop the GC from finalizing your object if it has been disposed programmatically (assuming your code disposes everything it needs to).&amp;nbsp; This will simply stop your virtual dispose method from being called twice.&amp;nbsp; This is also guarded against using the _disposed flag.&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-4273739668996032781?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/4273739668996032781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/idisposable-disposable-pattern.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/4273739668996032781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/4273739668996032781'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/idisposable-disposable-pattern.html' title='IDisposable - Disposable Pattern'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-6857836674455990059</id><published>2010-02-02T10:39:00.000Z</published><updated>2010-02-02T10:39:43.863Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='pcscad'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='pcscustom'/><category scheme='http://www.blogger.com/atom/ns#' term='activex'/><title type='text'>Windowless ActiveX Exception</title><content type='html'>This one screwed me up for a day.&lt;br /&gt;&lt;br /&gt;We have an add-in for a product that is one giant Explorer Shell Extension.&amp;nbsp; The add-in was using an ActiveX control from &lt;a href="http://www.pcscad.com/"&gt;http://www.pcscad.com/&lt;/a&gt;; which, I will add straight away, &lt;strong&gt;isn't&lt;/strong&gt; the problem (and is in fact a fantastic control for MicroStation DGN files).&lt;br /&gt;&lt;br /&gt;However, its an ActiveX control, so our add-in hosts it on a hidden window.&amp;nbsp; Of late, and rather randomly, I've been getting the following exception during some code refactoring:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;&lt;em&gt;Unable to get the window handle for the 'AxPcscustom' control.&amp;nbsp; Windowless ActiveX controls are not supported.&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;Up until my refactoring, it had been working fine - so obviously I had introduced something.&amp;nbsp; However, to me the problem sounded like the message pump wasn't running, or handles were missing, or something else along those lines.&lt;br /&gt;&lt;br /&gt;So, a day goes by and I do a full roll-back of code - it starts working again.&amp;nbsp; I then start doing my refactorings, step-by-step, looking for the moment it breaks.&lt;br /&gt;&lt;br /&gt;It breaks because this is missing (I removed it because I show only one control that doesn't use themes):&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; EnableOSThemes()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;try&lt;/span&gt; { &lt;span style="color: #2b91af;"&gt;Application&lt;/span&gt;.EnableVisualStyles(); }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;catch&lt;/span&gt; (&lt;span style="color: #2b91af;"&gt;Exception&lt;/span&gt;) { }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;try&lt;/span&gt; { &lt;span style="color: #2b91af;"&gt;Application&lt;/span&gt;.SetCompatibleTextRenderingDefault(&lt;span style="color: blue;"&gt;false&lt;/span&gt;); }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;catch&lt;/span&gt; (&lt;span style="color: #2b91af;"&gt;Exception&lt;/span&gt;) { }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;I call this before I create any forms (well, actually its the first thing I call when I'm given control from the host application, there are two entry points).&lt;br /&gt;&lt;br /&gt;Admittedly, I'm very confused.&amp;nbsp; I played around a little a found that its the SetCompatibleTextRenderingDefault method that needs calling (comment it out and it breaks again), contrary to MSDN:&lt;br /&gt;&lt;blockquote&gt;You should never call this method if your Windows Forms code is hosted in another application, such as Internet Explorer. Only call this method in stand-alone Windows Forms applications.&lt;/blockquote&gt;Obviously, this code is doing something to correct the state and stop the exception from occurring; however I don't know what this is, so my hack solution is going to have to stay.&lt;br /&gt;&lt;br /&gt;Anyone got any ideas?&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;&lt;img border="0" id="BLOGGER_PHOTO_ID_5310516322517916706" src="http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; cursor: hand; height: 49px; margin: 5px; position: relative; width: 50px;" title="Image by Jeff Atwood and Jon Galloway." /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-6857836674455990059?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/6857836674455990059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/windowless-activex-exception.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6857836674455990059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6857836674455990059'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/02/windowless-activex-exception.html' title='Windowless ActiveX Exception'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-1036415073895284576</id><published>2010-01-25T12:10:00.003Z</published><updated>2010-01-25T14:36:13.283Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='inactive'/><category scheme='http://www.blogger.com/atom/ns#' term='focus'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='winforms'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='application.run'/><category scheme='http://www.blogger.com/atom/ns#' term='modeless'/><title type='text'>Show Inactive Form</title><content type='html'>If you would like to show a form without activating it (a strangely non-intuitive task) you will find various answers on the net:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/156046/show-a-form-without-stealing-focus-in-c"&gt;Using the ShowWindow interop&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.showwithoutactivation(VS.85).aspx"&gt;Using form properties, with limitations&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;I couldn't get the first one to work, because I couldn't plug it into the code and still be able to use:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;Application&lt;/span&gt;.Run(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;MainForm&lt;/span&gt;());&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Which is something I required to keep the thread alive (I was showing a notification form on a thread pool thread, the message pump is required to keep the form alive properly).&lt;br /&gt;&lt;br /&gt;The second one didn't work because another requirement of the form was to be the top-most form. &amp;nbsp;If TopMost is true, then ShowWithoutActivation is ignored for some reason. &amp;nbsp;This property does not force the form to remain inactive either, so after its created and shown, you can give it focus in other ways.&lt;br /&gt;&lt;br /&gt;The solution I landed on was to use CreateParams. &amp;nbsp;I have seen this used before to do things such as allowing control transparency. &amp;nbsp;So I searched and found this:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.codeguru.com/forum/showthread.php?t=469933"&gt;Adding NoActivate to a new form&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;This worked, I plugged this into my notification form base class and called Application.Run on it with great success.&lt;br /&gt;&lt;br /&gt;I'll have to post my notification form code sometime :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-1036415073895284576?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/1036415073895284576/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/show-inactive-form.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1036415073895284576'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1036415073895284576'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/show-inactive-form.html' title='Show Inactive Form'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-7452321132693126265</id><published>2010-01-24T14:29:00.007Z</published><updated>2010-02-26T21:26:18.406Z</updated><title type='text'>Links Bin</title><content type='html'>&lt;span style="font-family: inherit; font-size: small;"&gt;My Sticky Posts are listed on the right ---&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;strong&gt;&lt;span style="font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; font-size: large;"&gt;&lt;u&gt;General Dev&lt;/u&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.connectionstrings.com/"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;ConnectionStrings.com&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.pinvoke.net/"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;PInvoke.net&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.syncfusion.com/faq/windowsforms/Default.aspx"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Windows Forms FAQ&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://regexlib.com/RETester.aspx"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;RegexLib Tester&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.harding.edu/fmccown/vbnet_csharp_comparison.html"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;VB.NET &amp;amp; C# Comparison&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; font-size: large;"&gt;&lt;strong&gt;&lt;u&gt;Visual Studio&lt;/u&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/eehb4faa(VS.80).aspx"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Visual Studio 2005 Template Parameters&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/eehb4faa.aspx"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Visual Studio 2008 Template Parameters&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt; &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; font-size: large;"&gt;&lt;strong&gt;&lt;u&gt;ASP.NET&lt;/u&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://misfitgeek.com/blog/aspnet/unwinding-the-page-lifecycle-events/"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Page lifecycle events&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt; - &lt;/span&gt;&lt;a href="http://weblogs.asp.net/ricardoperes/archive/2010/01/04/asp-net-events.aspx"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;verbose version&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; font-size: large;"&gt;&lt;strong&gt;&lt;u&gt;Misc&lt;/u&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://support.microsoft.com/gp/lifeselect"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Microsoft Product Lifecycles&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-7452321132693126265?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/7452321132693126265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/links-page.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7452321132693126265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7452321132693126265'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/links-page.html' title='Links Bin'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-8929235071499349307</id><published>2010-01-19T13:47:00.004Z</published><updated>2010-01-20T11:11:40.606Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='revit api'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='ImageSource'/><category scheme='http://www.blogger.com/atom/ns#' term='revit'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='BitmapImage'/><category scheme='http://www.blogger.com/atom/ns#' term='Image'/><title type='text'>Image to BitmapImage</title><content type='html'>I use the Revit API occassionally at work, and its ribbon item images are all ImageSource types.&amp;nbsp; &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imagesource.aspx"&gt;Looking on MSDN&lt;/a&gt; we can see this is an abstract class, and that BitmapImage derives from it.&lt;br /&gt;&lt;br /&gt;This is a good candidate for what an image can convert into.&lt;br /&gt;&lt;br /&gt;A BitmapImage has no constructors for an easy conversion, but it does have a StreamSource property.&amp;nbsp; Just setting the property doesn't work, and &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.aspx"&gt;MSDN explains why&lt;/a&gt;:&lt;br /&gt;&lt;blockquote&gt;BitmapImage implements the ISupportInitialize interface to optimize initialization on multiple properties. Property changes can only occur during object initialization. Call BeginInit to signal that initialization has begun and EndInit to signal that initialization has completed. After initialization, property changes are ignored.&lt;br /&gt;&lt;/blockquote&gt;Simple enough.&amp;nbsp; Using this, we can simply make a blank object and initialize it on its StreamSource:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Drawing;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Drawing.Imaging;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.IO;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Media.Imaging;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ImageExtensions&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;BitmapImage&lt;/span&gt; ToBitmapImage(&lt;span style="color: blue;"&gt;this&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Image&lt;/span&gt; image)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;MemoryStream&lt;/span&gt; ms = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;MemoryStream&lt;/span&gt;();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; image.Save(ms, image.RawFormat);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;BitmapImage&lt;/span&gt; bi = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;BitmapImage&lt;/span&gt;();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; bi.BeginInit();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; bi.StreamSource = ms;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; bi.EndInit();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; bi;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Of note is not wrapping the MemoryStream in a using block.&amp;nbsp; You cannot dispose of the object as the BitmapImage holds a reference to it.&amp;nbsp; If you do, it will clear your image.&amp;nbsp; Also, you can see I've stuck it all in an extension method - a good enough choice for my current usage.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;&lt;img border="0" id="BLOGGER_PHOTO_ID_5310516322517916706" src="http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; cursor: hand; height: 49px; margin: 5px; position: relative; width: 50px;" title="Image by Jeff Atwood and Jon Galloway." /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-8929235071499349307?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/8929235071499349307/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/image-to-bitmapimage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/8929235071499349307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/8929235071499349307'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/image-to-bitmapimage.html' title='Image to BitmapImage'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-5308233743018151616</id><published>2010-01-07T15:13:00.002Z</published><updated>2010-01-07T15:29:45.811Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='version'/><category scheme='http://www.blogger.com/atom/ns#' term='assemblyfileversion'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='assemblyversion'/><category scheme='http://www.blogger.com/atom/ns#' term='versioning'/><title type='text'>Assembly Versioning Ruminations</title><content type='html'>First things first: &lt;a href="http://dictionary.reference.com/browse/rumination"&gt;rumination&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;No, I don't do a "word of the day" column.&lt;br /&gt;&lt;br /&gt;Assembly versioning is a sticky issue for a lot of developers - especially those responsible for it.&amp;nbsp; Its not clearly documented anywhere, its down to interpretation, its critical for tracking history, and its critical if your assemblies are strongly named.&lt;br /&gt;&lt;br /&gt;All in all, it can go very wrong very easily.&lt;br /&gt;&lt;br /&gt;Where I work we have no assembly versioning policy, so I've taken it upon myself to make one.&amp;nbsp; We have the issue where versioning is simply used to say "I'm more recent than you", nothing more and&amp;nbsp;nothing less.&amp;nbsp; Tie this into automated builds, managing components, and deployment and you suddenly get a right mess.&lt;br /&gt;&lt;br /&gt;My current idea is the following.&amp;nbsp; Populate the AssemblyFileVersion with the "I'm more recent than you" information:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Taking a fictituos 'Fantastic Application v2.5', the AssemblyFileVersion would be the following:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;2.5.710.1456&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;Breaking this down, we have:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;2.5 - the major and minor reserved for marketing purposes.&lt;/li&gt;&lt;li&gt;710:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;7 - the number of days since the 1st January (basically the current count of the days in the year).&amp;nbsp; This allows you to represent a month-day date in no more than 3 characters., but you have to manually decode the month.&lt;/li&gt;&lt;li&gt;10 - a two digit year.&lt;/li&gt;&lt;li&gt;This is important, because the versioning parts can only contain a maximum value of 65534, the biggest value from a leap year will be: 36610, miles short of our maximum and conveying all our information.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;1456 - the current time in 24 hour mode, hhmm, again short of the max.&lt;/li&gt;&lt;/ul&gt;This works for us, as AssemblyFileVersion isn't used by anything important, we can hijack it for our own (evil?) purposes.&lt;br /&gt;&lt;br /&gt;The AssemblyVersion is where the 'policy' starts.&amp;nbsp; If you strong-name your assemblies, the version number (among other things) determines if the binding is successful - so can potentially break an application, making it very important.&amp;nbsp; If you don't use strong naming, the assembly file name is used instead, making it much less important.&lt;br /&gt;&lt;br /&gt;Our policy stands as such (for full releases, not internal builds):&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Major and minor are marketing versions, developers need not apply.&lt;/li&gt;&lt;/ul&gt;&lt;ol&gt;&lt;li&gt;If the assembly features a breaking change since the last version.&lt;/li&gt;&lt;ol&gt;&lt;li&gt;If the major/minor doesn't change, make sure the build and/or revision number has.&lt;/li&gt;&lt;li&gt;If the major/minor has changed, do whatever you want with the build and revision numbers.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;&lt;br /&gt;If the assembly is backwards compatible with the previous version:&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Leave the version number alone and rely on the AssemblyFileVersion.&lt;/li&gt;&lt;li&gt;Change the version number (build or revision most likely) and implement a binding policy in a configuration file to redirect calls from callers using older versions.&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;Note if the assembly is not strong-named, you don't need to do binding redirections.&lt;br /&gt;&lt;br /&gt;Taking this policy and our previous application, we can do a release giving us:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;2.5.4359.20757&lt;/li&gt;&lt;/ul&gt;Visual Studio can give you a build and revision number automatically using the format:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;2.5.*&lt;/li&gt;&lt;/ul&gt;&lt;a href="http://blogs.msdn.com/carloc/archive/2008/02/22/the-meaning-of-version-numbers-in-a-compiled-assembly.aspx"&gt;This link explains how the build and revision are determined during a compile&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;For internal builds of assemblies that are strongly-named, don't change the version and instead rely on the AssemblyFileVersion to tell you what version you are working on.&amp;nbsp; Save all changes until the final release, unless you enjoy fixing your references everyday.&lt;br /&gt;&lt;ol&gt;&lt;/ol&gt;My preference is to use 1.1 and 2.2 - as this is the closest to the 'purest' solution I can see.&amp;nbsp; It gives us arbitrary build information, and allows us to manage the application's version to any of its users.&amp;nbsp; It also has the added bonus of letting the marketing people have a version they can market.&lt;br /&gt;&lt;br /&gt;In a future post I will detail how to automate populating this information; one, so you don't have to figure out a contorted date; and two, so you can put custom logic to make build and revision actually signify the build and any revisions...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-5308233743018151616?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/5308233743018151616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/assembly-versioning-ruminations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5308233743018151616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5308233743018151616'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/assembly-versioning-ruminations.html' title='Assembly Versioning Ruminations'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-8875316074175447315</id><published>2010-01-04T15:07:00.001Z</published><updated>2010-01-04T15:09:17.758Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='deployment'/><category scheme='http://www.blogger.com/atom/ns#' term='custom action'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='setup'/><category scheme='http://www.blogger.com/atom/ns#' term='msi'/><title type='text'>Get MSI Location During Setup</title><content type='html'>If you need to know the path to the MSI file during setup in a custom action, add this value to the custom action property "CustomActionData":&lt;br /&gt;&lt;br /&gt;/SourceDir="[SourceDir]\"&lt;br /&gt;&lt;br /&gt;You can name the /SourceDir anything you want, so long as it correlates with the code: &lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnAfterInstall(&lt;span style="color: #2b91af;"&gt;IDictionary&lt;/span&gt; savedState)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;string&lt;/span&gt; stagingLocation = &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Context.Parameters[&lt;span style="color: #a31515;"&gt;"SourceDir"&lt;/span&gt;];&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Useful if, like me, you supply external files with the MSI to aide in automated deployments (like distributing a pre-made configuration file instead of prompting the user for values).&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;&lt;img border="0" id="BLOGGER_PHOTO_ID_5310516322517916706" src="http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; cursor: hand; height: 49px; margin: 5px; position: relative; width: 50px;" title="Image by Jeff Atwood and Jon Galloway." /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-8875316074175447315?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/8875316074175447315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/get-msi-location-during-setup.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/8875316074175447315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/8875316074175447315'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/get-msi-location-during-setup.html' title='Get MSI Location During Setup'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-5858848884893107849</id><published>2010-01-02T18:54:00.007Z</published><updated>2011-06-11T08:44:41.392+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='custom'/><category scheme='http://www.blogger.com/atom/ns#' term='data bound'/><category scheme='http://www.blogger.com/atom/ns#' term='bound'/><category scheme='http://www.blogger.com/atom/ns#' term='datagridviewcomboboxcolumn'/><category scheme='http://www.blogger.com/atom/ns#' term='DataGridView'/><category scheme='http://www.blogger.com/atom/ns#' term='sorting'/><category scheme='http://www.blogger.com/atom/ns#' term='sort'/><title type='text'>Bound DataGridView Sorting</title><content type='html'>&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;b&gt;Update: Sample Application&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;b&gt;&lt;a href="https://bitbucket.org/adamh/datagridview-drag-drop"&gt;https://bitbucket.org/adamh/datagridview-drag-drop&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This is an old post I've been meaning to post since May, so here it is!&lt;br /&gt;&lt;br /&gt;This one is a little strange, yet completely understandable. &lt;br /&gt;&lt;br /&gt;I have an existing DataGridView with various bound items in it, a few of these items are lookup values - the grid uses a DataGridViewComboBoxColumn to cross-bind an ID with a list of ID/Lookup values. &lt;br /&gt;&lt;br /&gt;The fun starts (or ends depending on your outlook in life) when the client asks why can't I sort on this column? Or, why doesn't this column sort correctly? &lt;br /&gt;&lt;br /&gt;This is because in a bound DataGridView, the sorting action is delegated to the ApplySort of the underlying IBindingList. You can confirm this in Reflector if you disassemble the DataGridView and look through the SortInternal method. Simply, the grid code says "if you are data-bound, do this, else do that": 'this' is ApplySort, 'that' is Rows.Sort(IComparer, ListSortDirection). &lt;br /&gt;&lt;br /&gt;One obvious solution is to create a dummy column and marshal the values between that and the underlying data column, so that when the users sort the unbound column - it sorts as they would expect; alphabetically. &lt;br /&gt;&lt;br /&gt;My approach was slightly more contorted. In the derived DataGridView class we had (DataGridViewPlus), I created a new Sort method, taking an IComparer:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;virtual&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Sort(&lt;span style="color: #2b91af;"&gt;IComparer&amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af;"&gt;DataGridViewRow&amp;gt;&lt;/span&gt; comparer)&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;// We sort the grid rows using the provided comparer.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: #2b91af;"&gt;List&amp;lt;&lt;/span&gt;&lt;span style="color: #2b91af;"&gt;DataGridViewRow&amp;gt;&lt;/span&gt; sortedRows = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;DataGridViewRow&amp;gt;&lt;/span&gt;();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: #2b91af;"&gt;DataGridViewRow&lt;/span&gt; row &lt;span style="color: blue;"&gt;in&lt;/span&gt; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Rows)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sortedRows.Add(row);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; sortedRows.Sort(comparer);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;// We need to work with the DataView object.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: #2b91af;"&gt;BindingSource&lt;/span&gt; source = &lt;span style="color: blue;"&gt;this&lt;/span&gt;.DataSource &lt;span style="color: blue;"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;BindingSource&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: #2b91af;"&gt;DataView&lt;/span&gt; view = (source.Current &lt;span style="color: blue;"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;DataRowView&lt;/span&gt;).DataView;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;// We get the table structure - not any rows.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: #2b91af;"&gt;DataTable&lt;/span&gt; tempTable = view.Table.Clone();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;// Importantly, we import the rows in the same order as our sorted list.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: #2b91af;"&gt;DataGridViewRow&lt;/span&gt; row &lt;span style="color: blue;"&gt;in&lt;/span&gt; sortedRows)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tempTable.ImportRow((row.DataBoundItem &lt;span style="color: blue;"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;DataRowView&lt;/span&gt;).Row);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;// We can't simply copy the table across, so we clear and re-import.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; view.Table.Rows.Clear();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: #2b91af;"&gt;DataRow&lt;/span&gt; row &lt;span style="color: blue;"&gt;in&lt;/span&gt; tempTable.Rows)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; view.Table.ImportRow(row);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;I then created a nested class for a comparer specific to sorting rows based on the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.formattedvalue.aspx"&gt;FormattedValue&lt;/a&gt; of a cell:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;DataGridViewPlus&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;RowDisplayTextComparer&lt;/span&gt; : &lt;span style="color: #2b91af;"&gt;IComparer&lt;/span&gt;, &lt;span style="color: #2b91af;"&gt;IComparer&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af;"&gt;DataGridViewRow&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; #region&lt;/span&gt; Attributes &amp;amp; Properties&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; SortModifier = 1;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; _columnIndex = -1;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; #endregion&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; #region&lt;/span&gt; Constructors&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; RowDisplayTextComparer(&lt;span style="color: #2b91af;"&gt;ListSortDirection&lt;/span&gt; sortDirection, &lt;span style="color: blue;"&gt;int&lt;/span&gt; columnIndex)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (sortDirection == &lt;span style="color: #2b91af;"&gt;ListSortDirection&lt;/span&gt;.Descending)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; SortModifier = -1;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; SortModifier = 1;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _columnIndex = columnIndex;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; #endregion&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; #region&lt;/span&gt; IComparer&amp;lt;DataGridViewRow&amp;gt; Members&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; Compare(&lt;span style="color: #2b91af;"&gt;DataGridViewRow&lt;/span&gt; x, &lt;span style="color: #2b91af;"&gt;DataGridViewRow&lt;/span&gt; y)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; res = &lt;span style="color: blue;"&gt;string&lt;/span&gt;.Compare(&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; x.Cells[_columnIndex].FormattedValue.ToString(),&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; y.Cells[_columnIndex].FormattedValue.ToString());&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; res * SortModifier;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; #endregion&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; #region&lt;/span&gt; IComparer Members&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IComparer&lt;/span&gt;.Compare(&lt;span style="color: blue;"&gt;object&lt;/span&gt; x, &lt;span style="color: blue;"&gt;object&lt;/span&gt; y)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; Compare(x &lt;span style="color: blue;"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;DataGridViewRow&lt;/span&gt;, y &lt;span style="color: blue;"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;DataGridViewRow&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; #endregion&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;In the real world, you use it by handling the column header clicking yourself for the column that requires a little help:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; gridGroups_ColumnHeaderMouseClick(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: #2b91af;"&gt;DataGridViewCellMouseEventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (e.ColumnIndex != colGroupID.Index)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; colGroupID.HeaderCell.SortGlyphDirection = &lt;span style="color: #2b91af;"&gt;SortOrder&lt;/span&gt;.None;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: #2b91af;"&gt;ListSortDirection&lt;/span&gt; sort = &lt;span style="color: #2b91af;"&gt;ListSortDirection&lt;/span&gt;.Ascending;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (colGroupID.HeaderCell.SortGlyphDirection != &lt;span style="color: #2b91af;"&gt;SortOrder&lt;/span&gt;.None)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sort = colGroupID.HeaderCell.SortGlyphDirection == &lt;span style="color: #2b91af;"&gt;SortOrder&lt;/span&gt;.Ascending ? &lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: #2b91af;"&gt;ListSortDirection&lt;/span&gt;.Descending : &lt;span style="color: #2b91af;"&gt;ListSortDirection&lt;/span&gt;.Ascending;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; gridGroups.Sort(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;DataGridViewPlus&lt;/span&gt;.&lt;span style="color: #2b91af;"&gt;RowDisplayTextComparer&lt;/span&gt;(sort, colGroupID.Index));&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; colGroupID.HeaderCell.SortGlyphDirection = sort == &lt;span style="color: #2b91af;"&gt;ListSortDirection&lt;/span&gt;.Ascending ?&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;SortOrder&lt;/span&gt;.Ascending : &lt;span style="color: #2b91af;"&gt;SortOrder&lt;/span&gt;.Descending;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;I'm always open to constructive criticism about better ways to code the solution - so if you are reading this and think its naff, let me know :)&lt;br /&gt;&lt;br /&gt;Its also a&amp;nbsp;little rough around the edges - no null value checking in the comparer for instance. But:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;&lt;img border="0" id="BLOGGER_PHOTO_ID_5310516322517916706" src="http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; cursor: hand; height: 49px; margin: 5px; position: relative; width: 50px;" title="Image by Jeff Atwood and Jon Galloway." /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-5858848884893107849?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/5858848884893107849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/bound-datagridview-sorting.html#comment-form' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5858848884893107849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5858848884893107849'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/bound-datagridview-sorting.html' title='Bound DataGridView Sorting'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-2819318813395759632</id><published>2010-01-02T18:14:00.003Z</published><updated>2010-01-04T13:53:35.559Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='IWin32Window'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><title type='text'>IWin32Window Instances</title><content type='html'>This is an old post I've been meaning to post since July, so here it is!&lt;br /&gt;&lt;br /&gt;Following up from my previous blog about form parents, I suddenly found myself in need of getting an IWin32Window object instance from an arbitrary handle (either Int32 or IntPtr). &lt;br /&gt;&lt;br /&gt;As you can guess, the first thing you realise is that its an interface so you can't instantiate it. &lt;br /&gt;&lt;br /&gt;Obvious solution (and one I should have thought of really...), implement the interface on a wrapper class:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;WindowWrapper&lt;/span&gt; : &lt;span style="color: #2b91af;"&gt;IWin32Window&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt; _handle;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; WindowWrapper(&lt;span style="color: blue;"&gt;int&lt;/span&gt; windowHandle)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;span style="color: blue;"&gt;this&lt;/span&gt;(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt;(windowHandle))&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; { }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; WindowWrapper(&lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt; windowHandle)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Handle = windowHandle;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;IntPtr&lt;/span&gt; Handle&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; _handle; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;set&lt;/span&gt; { _handle = &lt;span style="color: blue;"&gt;value&lt;/span&gt;; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;God knows why I felt the need to post this; some form of penance for the fact that I had to Google it perhaps...&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;&lt;img border="0" id="BLOGGER_PHOTO_ID_5310516322517916706" src="http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; cursor: hand; height: 49px; margin: 5px; position: relative; width: 50px;" title="Image by Jeff Atwood and Jon Galloway." /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-2819318813395759632?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/2819318813395759632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/iwin32window-instances.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2819318813395759632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2819318813395759632'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/iwin32window-instances.html' title='IWin32Window Instances'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-7216614993495161932</id><published>2010-01-02T17:11:00.008Z</published><updated>2011-06-11T08:44:16.899+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='drag'/><category scheme='http://www.blogger.com/atom/ns#' term='drop'/><category scheme='http://www.blogger.com/atom/ns#' term='DataGridView'/><category scheme='http://www.blogger.com/atom/ns#' term='DataGridViewRow'/><title type='text'>DataGridView Multiple Row Drag Drop</title><content type='html'>&lt;div&gt;&lt;b&gt;Update: Sample Application&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;a href="https://bitbucket.org/adamh/datagridview-drag-drop"&gt;https://bitbucket.org/adamh/datagridview-drag-drop&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is an old post I've been meaning to post since May, so here it is!&lt;br /&gt;&lt;br /&gt;Sources:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic62979.aspx"&gt;Drag only selected rows.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.blogger.com/"&gt;Initiate drag when dragged far enough.&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;Using these two sources, I have created a derived DataGridView to expose drag'n'drop functionality via the known method of ItemDrag (renamed to RowDrag in my example).&lt;br /&gt;&lt;br /&gt;Its simple enough, though it does change the behaviour of the grid slightly. I suspect this is why it doesn't support drag and drop in the same way as other controls, as row interaction is not the same as item interaction in another control such as the ListView.&lt;br /&gt;&lt;br /&gt;Hopefully the code comments should explain the situation. There are a couple of flags and maintenance attributes in the class to cater for when the user looks like they are drag-dropping, but in fact are just clicking or drag-selecting.&lt;br /&gt;&lt;br /&gt;You can switch off drag'n'drop by setting the EnableDragDrop property to false. You subscribe to the drag operation by way of the RowDrag event (exactly the same usage as &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.listview(VS.80).aspx"&gt;ListView&lt;/a&gt;.&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.itemdrag(VS.80).aspx"&gt;ItemDrag&lt;/a&gt;; intentional). Simply call DoDragDrop on the grid as you would on other controls.&lt;br /&gt;&lt;br /&gt;It gives you a &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewselectedrowcollection(VS.80).aspx"&gt;DataGridViewSelectedRowCollection&lt;/a&gt;. If you have issues or get allergies when using this collection, you can always change it :)&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;[&lt;span style="color: #2b91af;"&gt;DebuggerNonUserCode&lt;/span&gt;()]&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;DataGridViewPlus&lt;/span&gt; : &lt;span style="color: #2b91af;"&gt;DataGridView&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/span&gt; Attributes &amp;amp; Properties&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; _enableDragDrop = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; _suppressDragSelection = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; _clickedRow = -1;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Rectangle&lt;/span&gt; _dragBounds = &lt;span style="color: #2b91af;"&gt;Rectangle&lt;/span&gt;.Empty;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;MouseEventArgs&lt;/span&gt; _mouseDownArgs = &lt;span style="color: blue;"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;Category&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"Behavior"&lt;/span&gt;), &lt;span style="color: #2b91af;"&gt;DefaultValue&lt;/span&gt;(&lt;span style="color: blue;"&gt;false&lt;/span&gt;),&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;span style="color: #2b91af;"&gt;Description&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"Enable or disable drag/drop functionality."&lt;/span&gt;)]&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; EnableDragDrop&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; _enableDragDrop; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;set&lt;/span&gt; { _enableDragDrop = &lt;span style="color: blue;"&gt;value&lt;/span&gt;; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;Category&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"Behavior"&lt;/span&gt;), &lt;span style="color: #2b91af;"&gt;DefaultValue&lt;/span&gt;(&lt;span style="color: blue;"&gt;false&lt;/span&gt;),&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;span style="color: #2b91af;"&gt;Description&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"Enable or disable drag selection of rows.&amp;nbsp; Disabling this will make dragging of unselected rows smoother."&lt;/span&gt;)]&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; SuppressDragSelection&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; _suppressDragSelection; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;set&lt;/span&gt; { _suppressDragSelection = &lt;span style="color: blue;"&gt;value&lt;/span&gt;; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;Category&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"Action"&lt;/span&gt;), &lt;span style="color: #2b91af;"&gt;Description&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"Occurs when the user begins dragging a row."&lt;/span&gt;)]&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;event&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ItemDragEventHandler&lt;/span&gt; RowDrag;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/span&gt; Constructors&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; DataGridViewPlus()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; InitializeComponent();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/span&gt; Methods&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnMouseDown(&lt;span style="color: #2b91af;"&gt;MouseEventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (_enableDragDrop)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; row = &lt;span style="color: blue;"&gt;this&lt;/span&gt;.HitTest(e.X, e.Y).RowIndex;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// We only drag selected rows so the user can drag multiple rows.&amp;nbsp; If we call&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// base.OnMouseDown(e), the click will deselect all rows apart from the current row.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; row &amp;gt;= 0 &amp;amp;&amp;amp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; row &amp;lt; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Rows.Count &amp;amp;&amp;amp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (_suppressDragSelection || &lt;span style="color: blue;"&gt;this&lt;/span&gt;.SelectedRows.Contains(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.Rows[row]))&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; )&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; _clickedRow = row;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: #2b91af;"&gt;Size&lt;/span&gt; dragSize = &lt;span style="color: #2b91af;"&gt;SystemInformation&lt;/span&gt;.DragSize;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; _dragBounds = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Rectangle&lt;/span&gt;(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Point&lt;/span&gt;(&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; e.X - (dragSize.Width / 2),&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; e.Y - (dragSize.Height / 2)), dragSize);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; _mouseDownArgs = e; &lt;span style="color: green;"&gt;// Record for future use if they abort drag/drop and are just clicking.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;// If we are not suppressing it means this row has been selected, so we exit before base.OnMouseDown.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (!_suppressDragSelection) &lt;span style="color: blue;"&gt;return&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; _dragBounds = &lt;span style="color: #2b91af;"&gt;Rectangle&lt;/span&gt;.Empty;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnMouseDown(e);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnMouseMove(&lt;span style="color: #2b91af;"&gt;MouseEventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnMouseMove(e);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (_enableDragDrop)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; row = &lt;span style="color: blue;"&gt;this&lt;/span&gt;.HitTest(e.X, e.Y).RowIndex;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (row &amp;lt; 0) &lt;span style="color: green;"&gt;// Ignore column headers.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; _dragBounds = &lt;span style="color: #2b91af;"&gt;Rectangle&lt;/span&gt;.Empty;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; ((e.Button &amp;amp; &lt;span style="color: #2b91af;"&gt;MouseButtons&lt;/span&gt;.Left) == &lt;span style="color: #2b91af;"&gt;MouseButtons&lt;/span&gt;.Left)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;// If the mouse has been click-dragged outside our grid.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (_dragBounds != &lt;span style="color: #2b91af;"&gt;Rectangle&lt;/span&gt;.Empty &amp;amp;&amp;amp; !_dragBounds.Contains(e.X, e.Y))&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;ItemDragEventArgs&lt;/span&gt; dragArgs = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ItemDragEventArgs&lt;/span&gt;(&lt;span style="color: #2b91af;"&gt;MouseButtons&lt;/span&gt;.Left, &lt;span style="color: blue;"&gt;this&lt;/span&gt;.SelectedRows);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; OnRowDrag(dragArgs);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnMouseUp(&lt;span style="color: #2b91af;"&gt;MouseEventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;// The drag drop operation was not concluded.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (_dragBounds.Contains(e.X, e.Y))&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (_clickedRow &amp;gt;= 0 &amp;amp;&amp;amp; _clickedRow &amp;lt; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Rows.Count)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;// Let the grid continue processing the click we hijacked earlier...&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;// Hopefully it will be on the same row!&amp;nbsp; Tolerance is good enough.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnMouseDown(_mouseDownArgs);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; _mouseDownArgs = &lt;span style="color: blue;"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnMouseUp(e);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;virtual&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnRowDrag(&lt;span style="color: #2b91af;"&gt;ItemDragEventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (RowDrag != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; RowDrag(&lt;span style="color: blue;"&gt;this&lt;/span&gt;, e);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;As always with code:&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;&lt;img border="0" id="BLOGGER_PHOTO_ID_5310516322517916706" src="http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; cursor: hand; height: 49px; margin: 5px; position: relative; width: 50px;" title="Image by Jeff Atwood and Jon Galloway." /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-7216614993495161932?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/7216614993495161932/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/datagridview-multiple-row-drag-drop.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7216614993495161932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7216614993495161932'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2010/01/datagridview-multiple-row-drag-drop.html' title='DataGridView Multiple Row Drag Drop'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-8687645431199378924</id><published>2009-12-22T15:17:00.004Z</published><updated>2009-12-22T16:11:14.587Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql-dmo'/><category scheme='http://www.blogger.com/atom/ns#' term='comexception'/><category scheme='http://www.blogger.com/atom/ns#' term='sqldmo.dll'/><category scheme='http://www.blogger.com/atom/ns#' term='regsvr32'/><category scheme='http://www.blogger.com/atom/ns#' term='80041054'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='setup'/><category scheme='http://www.blogger.com/atom/ns#' term='dmo'/><category scheme='http://www.blogger.com/atom/ns#' term='client'/><title type='text'>Install SQL-DMO for Clients</title><content type='html'>&lt;a href="http://msdn.microsoft.com/en-us/library/ms131540.aspx"&gt;SQL-DMO (Data Management Objects)&lt;/a&gt; is not the best choice, but has regardless been adopted in one of our little applications.&lt;br /&gt;&lt;br /&gt;Previously, it has always (to my knowledge) installed perfectly fine on many client machines. However, after having taken over the project (for some other improvements) I come to find myself having major deployment problems with the SQLDMO.dll file. The file is used in a setup Custom Action to allow the user to configure database details on install.&lt;br /&gt;&lt;br /&gt;Whenever the application attempts to bind to the DLL, it throws a COMException along the lines of:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {10020100-E260-11CF-AE68-00AA004A34D5} failed due to the following error: 80040154.&lt;/li&gt;&lt;/ul&gt;Any attempts to register this file fail (via regsvr32). There are various answers to how to get it registered; I tried a few and none worked.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;LoadLibrary (snip) failed - The specified module could not be found.&lt;/li&gt;&lt;/ul&gt;To cut a long story short, you need to install "Microsoft SQL Server 2005 Backward Compatibility Components" (which contains SQL-DMO):&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=d09c1d60-a13c-4479-9b91-9e8b9d835cdc&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=d09c1d60-a13c-4479-9b91-9e8b9d835cdc&amp;amp;displaylang=en&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Unfortunately, there are no standalone redistributables just for SQL-DMO.&amp;nbsp; However, you can specify to only install the DMO parts in the installer, but this is down to the install-ee.&lt;br /&gt;&lt;br /&gt;You will then find that you don't need to register the DLL in your setup, and your application starts working.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-8687645431199378924?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/8687645431199378924/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/12/install-sql-dmo-for-clients.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/8687645431199378924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/8687645431199378924'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/12/install-sql-dmo-for-clients.html' title='Install SQL-DMO for Clients'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-4737619595986389798</id><published>2009-12-17T19:55:00.012Z</published><updated>2010-01-02T17:02:19.306Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='ipc'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='remoting'/><category scheme='http://www.blogger.com/atom/ns#' term='.net remoting'/><title type='text'>.NET Remoting IPC Configuration Returns</title><content type='html'>&lt;a href="http://adamhouldsworth.blogspot.com/2009/03/net-remoting-ipc-configuration.html"&gt;Many months ago I had a problem with IPC remoting configuration and naming of the ports&lt;/a&gt;. I mentioned I would post the final configuration files and never managed to get around to it.&lt;br /&gt;&lt;br /&gt;Well, after catching a comment 10 days late asking me if I'd ever posted the config details, here they are.&lt;br /&gt;&lt;br /&gt;The 'service':&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;system.runtime.remoting&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;application&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;service&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;wellknown&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;mode&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;SingleCall&lt;/span&gt;"&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;TheServer.RemotedType, TheServer&lt;/span&gt;"&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;/span&gt;&lt;span style="color: red;"&gt;objectUri&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;HostedType&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;service&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;channels&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;channel&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;ref&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;ipc&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;/span&gt;&lt;span style="color: red;"&gt;portName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;TheServer_Port&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;channels&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;application&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;system.runtime.remoting&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;And the 'client':&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;div style="background: white; color: black; font-family: Courier New; font-size: 10pt;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;system.runtime.remoting&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;application&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;client&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;wellknown&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;TheServer.RemotedType, TheServer&lt;/span&gt;"&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;/span&gt;&lt;span style="color: red;"&gt;url&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;ipc://TheServer_Port/HostedType&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;client&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;channels&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;channel&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;ref&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;ipc&lt;/span&gt;"&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;/span&gt;&lt;span style="color: red;"&gt;portName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;TheClient_Port_1&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;channels&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;application&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;system.runtime.remoting&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Note here that the client uses the server DLL to get the type. I managed to get the type stuff correct, I just kept mucking up the port names.&lt;br /&gt;&lt;br /&gt;The port names for each entity are immaterial, so long as they aren't the same. Again with the type uri 'HostedType'. However, the fully qualified type name 'TheServer.RemotedType, TheServer' is important, as is the client's URI as it obviously needs to match what the service is offering.&lt;br /&gt;&lt;br /&gt;Hope this helps someone in future. And as always:&lt;br /&gt;&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;&lt;img border="0" id="BLOGGER_PHOTO_ID_5310516322517916706" src="http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; cursor: hand; height: 49px; margin: 5px; position: relative; width: 50px;" title="Image by Jeff Atwood and Jon Galloway." /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-4737619595986389798?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/4737619595986389798/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/12/net-remoting-ipc-configuration-returns.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/4737619595986389798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/4737619595986389798'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/12/net-remoting-ipc-configuration-returns.html' title='.NET Remoting IPC Configuration Returns'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-2952477974128284242</id><published>2009-12-14T15:15:00.002Z</published><updated>2009-12-14T15:16:29.549Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='version'/><category scheme='http://www.blogger.com/atom/ns#' term='outlook'/><category scheme='http://www.blogger.com/atom/ns#' term='registry'/><category scheme='http://www.blogger.com/atom/ns#' term='add-in'/><category scheme='http://www.blogger.com/atom/ns#' term='assemblyversion'/><category scheme='http://www.blogger.com/atom/ns#' term='com'/><title type='text'>C# Outlook Add-in Dev</title><content type='html'>I was developing one of our Outlook Add-ins the other day and noticed the version was off, I was working under our release version number instead of our beta version number (an internal thing we have).&lt;br /&gt;&lt;br /&gt;I changed this, rebuilt the application (amongst some other changes) and proceeded to install.  Only to find it didn't work.&lt;br /&gt;&lt;br /&gt;I was running Outlook 2007, I looked inside the Trust Centre and noticed my add-in was 'inactive'.  Trying to activate it did nothing, the window simply closed and when I went back into check the list - still 'inactive'.&lt;br /&gt;&lt;br /&gt;Annoying.&lt;br /&gt;&lt;br /&gt;4 hours later and its home time, so I gave up for the weekend.&lt;br /&gt;&lt;br /&gt;Monday morning, I come in thinking 'great, another chunk of time about to be wasted with this thing'.  However, I remembered changing the version number.  On the off chance (and because my head wasn't in the Outlook troubleshooting mindset) I tried changing it back (it was 0.1.1.2) to 3.2.0.0.  Lo and behold, it worked.&lt;br /&gt;&lt;br /&gt;I wrote myself a little utility to find instances of my assembly in the registry and it turns out that when you uninstall the add-in, it doesn't clear some keys buried in HKLM\Classes\TypeLib and possibly HKCR\TypeLib.&lt;br /&gt;&lt;br /&gt;On the upside, I'm now inspired to write a little registry listener using WMI to keep tabs on my registry during development.  And I'm pretty sure this problem has bitten me in the past, I just didn't realise it at the time.&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-2952477974128284242?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/2952477974128284242/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/12/c-outlook-add-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2952477974128284242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2952477974128284242'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/12/c-outlook-add-in.html' title='C# Outlook Add-in Dev'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-5734688564848854233</id><published>2009-12-03T14:41:00.002Z</published><updated>2009-12-03T14:43:33.136Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='qa'/><category scheme='http://www.blogger.com/atom/ns#' term='dev'/><category scheme='http://www.blogger.com/atom/ns#' term='team'/><category scheme='http://www.blogger.com/atom/ns#' term='incentive'/><title type='text'>Software Development Incentives</title><content type='html'>Random post!&lt;br /&gt;&lt;br /&gt;Where I used to work, we tried an incentives scheme that we came up with in-house to motivate the developers (all 3 of us) and the QA staff (all 2-3 of them) to produce better quality code from the start instead of catching it all in QA, and to produce better tests and bug reports.&lt;br /&gt;&lt;br /&gt;You have 2 pots of 'bonus' (money, sweets, prizes, etc); one belongs to QA and one belongs to the dev team.  Whenever a bug is found the dev pot gets reduced and this reduction added to the QA pot.  Vice versa for any QA false-positives or dev bug fixes that aren't part of a bug fixing cycle.  If the project overruns, anything removed from the dev pot is not added to the QA pot, and vice versa - so all teams only lose out.&lt;br /&gt;&lt;br /&gt;At the end of a given development cycle, the team pot is split amongst the team.&lt;br /&gt;&lt;br /&gt;The best way to balance this is to make the QA pot smaller, as it can only grow from where it starts, whereas the dev pot can only shrink from where it starts.&lt;br /&gt;&lt;br /&gt;When the QA pot stops gaining because the developers are on form, the incentives can be reviewed to factor in better test procedures or automated testing etc and possibly give rewards for 100% successful test runs, or for savings on time spent in QA.&lt;br /&gt;&lt;br /&gt;A similar idea can be applied to customer support, though this is team-agnostic.&lt;br /&gt;&lt;br /&gt;It worked quite well, but I left the company before the pay-out :(&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-5734688564848854233?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/5734688564848854233/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/12/software-development-incentives.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5734688564848854233'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5734688564848854233'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/12/software-development-incentives.html' title='Software Development Incentives'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-7243491754682524461</id><published>2009-11-25T11:47:00.000Z</published><updated>2009-11-25T11:47:14.587Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='.installstate'/><category scheme='http://www.blogger.com/atom/ns#' term='custom action'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='setup'/><title type='text'>C# Setup .InstallState</title><content type='html'>Sometimes you may find that your &lt;application name&gt;.InstallState file doesn't clear up on an uninstall (nor does it delete the main application folder):&lt;br /&gt;&lt;br /&gt;&lt;a href="http://support.microsoft.com/kb/934388"&gt;http://support.microsoft.com/kb/934388&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The knowledge base gives a particular answer, however I found this answer originally:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://moiashvin-tech.blogspot.com/2008/05/removing-installstate-files-after.html"&gt;http://moiashvin-tech.blogspot.com/2008/05/removing-installstate-files-after.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Basically, if you have a custom action running on the Install stage, you need to add it to the Uninstall stage too.  Do this by overriding OnBeforeUninstall and simply call base.&lt;br /&gt;&lt;br /&gt;I make it a matter of course to override all parts and call base, and associate my custom action with all stages, just to avoid ambiguity.&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-7243491754682524461?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/7243491754682524461/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/11/c-setup-installstate.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7243491754682524461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7243491754682524461'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/11/c-setup-installstate.html' title='C# Setup .InstallState'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-7016341649059188725</id><published>2009-11-23T10:58:00.000Z</published><updated>2009-11-23T10:58:49.267Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='unknown command'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='objectarx'/><category scheme='http://www.blogger.com/atom/ns#' term='autocad'/><title type='text'>AutoCAD ObjectARX "Unknown Command"</title><content type='html'>Specific topic this time.&lt;br /&gt;&lt;br /&gt;At work we currently have a little application that sits inside AutoCAD using the ObjectARX SDK.&lt;br /&gt;&lt;br /&gt;I made a simple application that gave the user a single command named "SWAPBLOCK" via the CommandMethod attribute in code.  You then specify the CommandClass assembly attribute and you are good to go.&lt;br /&gt;&lt;br /&gt;Until it doesn't work and you get an "Unknown Command" error message... not much on the net about this.&lt;br /&gt;&lt;br /&gt;I found the answer buried in a forum post - don't copy local any of the AutoCAD DLL references in your solution - ie don't have 'AcMgd.dll', 'AcRibbon.dll', 'Autodesk.AutoCAD.Interop.dll', etc in your bin directory.&lt;br /&gt;&lt;br /&gt;It works for me, but not sure why - which is the next annoyance :)&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-7016341649059188725?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/7016341649059188725/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/11/autocad-objectarx-unknown-command.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7016341649059188725'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7016341649059188725'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/11/autocad-objectarx-unknown-command.html' title='AutoCAD ObjectARX &quot;Unknown Command&quot;'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-3482367933951476047</id><published>2009-10-28T15:45:00.009Z</published><updated>2009-11-11T10:46:25.835Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='thread affinity'/><category scheme='http://www.blogger.com/atom/ns#' term='multithreading'/><category scheme='http://www.blogger.com/atom/ns#' term='interop'/><category scheme='http://www.blogger.com/atom/ns#' term='threading'/><category scheme='http://www.blogger.com/atom/ns#' term='com'/><title type='text'>Thread Affinity</title><content type='html'>Wait a second, let me just brush the dust off my blog...&lt;br /&gt;&lt;br /&gt;There we are. Not to break tradition, again I'm here because of an annoyance I finally solved.&lt;br /&gt;&lt;br /&gt;At work I often make add-ins for an application. The application has an API that provides an interop DLL. The API and the application as a whole can sometimes be slow if you are doing something demanding.&lt;br /&gt;&lt;br /&gt;Recently I had to make an Outlook 2003 Add-in that pushed emails towards this application - so I had to use the applications API. Not wanting to block Outlook, I put all of the relevant API chat onto another thread. However, for some reason the background thread seemed to play havoc with the main thread - jittering would ensue.&lt;br /&gt;&lt;br /&gt;I have experienced this in other applications that use the API with multithreading, and brushed it off as some unexplained issue with the API.&lt;br /&gt;&lt;br /&gt;Unfortunately I couldn't do that with the Outlook add-in as performance was very important for the client. So after Googling high and low, I stumbled across thread affinity when exposing an application to COM Interop.&lt;br /&gt;&lt;br /&gt;It comes about because under the hood, a Single Thread Appartment COM component uses a message pump to listen for requests. This message pump is created on the same thread as the co-class: it is said to have Affinity with the Thread it was created on.&lt;br /&gt;&lt;br /&gt;Cut a long story short, I was creating some of the COM elements on thread A and trying to background it all to thread B - not knowing that execution on certain COM classes went back onto thread A...&lt;br /&gt;&lt;br /&gt;Needless to say, all sorted now and I'm slowing back-tracking a fix for this issue into past projects.&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-3482367933951476047?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/3482367933951476047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/10/thread-affinity.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/3482367933951476047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/3482367933951476047'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/10/thread-affinity.html' title='Thread Affinity'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-7526404599693268240</id><published>2009-07-17T12:31:00.004+01:00</published><updated>2009-07-17T12:38:38.496+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='outlook'/><category scheme='http://www.blogger.com/atom/ns#' term='office'/><category scheme='http://www.blogger.com/atom/ns#' term='add-in'/><category scheme='http://www.blogger.com/atom/ns#' term='shared add-in'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><title type='text'>C# Outlook Shared Add-In</title><content type='html'>My blog posts seem to be a random collection of annoying encounters at the moment...&lt;br /&gt;&lt;br /&gt;We have an Outlook 2003 Shared Add-In that has been working and installing perfectly fine on client machines for a while now.&lt;br /&gt;&lt;br /&gt;The client then attempted to get it installed on a 64-Bit machine, only to have it not work - no clues as to why.&lt;br /&gt;&lt;br /&gt;So I spend a while toying with it, noticing all the while that I can get things working on my dev box, but not on the live box.  On the live box its as if it doesn't exist.&lt;br /&gt;&lt;br /&gt;Turns out it doesn't.  I had been getting hung up on the &lt;a href="http://support.microsoft.com/kb/908002"&gt;KB908002&lt;/a&gt; fix, thinking a prerequisite for deployment was missing, and completely didn't think that my class simply wasn't registered.&lt;br /&gt;&lt;br /&gt;I changed the MSI and removed the "Primary Output from [my add-in]" to adding the physical release DLL, then on the properties tab setting 'Register' to 'vsdraCOM' - working like a charm.&lt;br /&gt;&lt;br /&gt;Moral of the story, although the setup project gives you the 'Registry' view, it doesn't show you all the Guid-related goings-on that may or may not be transpiring to wire your classes into the system.&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-7526404599693268240?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/7526404599693268240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/07/c-outlook-shared-add-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7526404599693268240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7526404599693268240'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/07/c-outlook-shared-add-in.html' title='C# Outlook Shared Add-In'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-1409438016726590309</id><published>2009-07-09T21:58:00.007+01:00</published><updated>2009-07-09T22:23:33.326+01:00</updated><title type='text'>Microsoft Axum Co Routine</title><content type='html'>Finally, some code.&lt;br /&gt;&lt;br /&gt;Don't get too excited, its fairly basic :)  What is happening is I kick off an agent 'one', whose sole purpose is to increment the number and pass it to agent 'two', whose sole purpose is to increment the number and pass it back.&lt;br /&gt;&lt;br /&gt;What it proves is that you don't run out of stack space - in a normal system you would get a stack overflow in no time flat.  Referring to a question I asked on the Axum forum, I think this is one of two situations - use of a linked stack that does not reside in the usual memory space; or the send being asynchronous so that when it passes from one agent to the next, there is only one line before the method exits anyway.  I suppose a better test would be to include a sleep period to see if I eventually run out of memory.&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;pre &gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;System&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;System&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;.&lt;/span&gt;&lt;span style="color: #2b91af;"&gt;Concurrency&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&lt;/pre&gt;&lt;pre &gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Microsoft&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;.&lt;/span&gt;&lt;span style="color: #2b91af;"&gt;Axum&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&lt;/pre&gt;&lt;pre &gt;&lt;span style="color: blue;"&gt;namespace&lt;/span&gt; CoRoutine&lt;/pre&gt;&lt;pre &gt;&lt;span style="font-weight: bold;"&gt;{&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;domain&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Program&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;channel&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Foo&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;input&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; value;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;channel&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Bar&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;input&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; value;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;output&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; res;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;reader&lt;/span&gt; &lt;span style="color: blue;"&gt;agent&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;OneAgent&lt;/span&gt; : &lt;span style="color: blue;"&gt;channel&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Foo&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;OneAgent&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;()&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; val &lt;span style="color: blue;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;receive&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;(&lt;/span&gt;&lt;span style="color: purple;"&gt;PrimaryChannel&lt;/span&gt;&lt;span style="color: blue;"&gt;::&lt;/span&gt;value);&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;Console&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;.WriteLine(val.ToString());&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;var&lt;/span&gt; &lt;span style="color: purple;"&gt;two&lt;/span&gt; &lt;span style="color: blue;"&gt;=&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;TwoAgent&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;.CreateInNewDomain();&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: purple;"&gt;two&lt;/span&gt;&lt;span style="color: blue;"&gt;::&lt;/span&gt;value &lt;span style="color: blue;"&gt;&amp;lt;--&lt;/span&gt; val &lt;span style="color: blue;"&gt;+&lt;/span&gt; &lt;span style="color: maroon;"&gt;1&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;reader&lt;/span&gt; &lt;span style="color: blue;"&gt;agent&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;TwoAgent&lt;/span&gt; : &lt;span style="color: blue;"&gt;channel&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Foo&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;TwoAgent&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;()&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; val &lt;span style="color: blue;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;receive&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;(&lt;/span&gt;&lt;span style="color: purple;"&gt;PrimaryChannel&lt;/span&gt;&lt;span style="color: blue;"&gt;::&lt;/span&gt;value);&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;Console&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;.WriteLine(val.ToString());&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;var&lt;/span&gt; &lt;span style="color: purple;"&gt;one&lt;/span&gt; &lt;span style="color: blue;"&gt;=&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;OneAgent&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;.CreateInNewDomain();&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: purple;"&gt;one&lt;/span&gt;&lt;span style="color: blue;"&gt;::&lt;/span&gt;value &lt;span style="color: blue;"&gt;&amp;lt;--&lt;/span&gt; val &lt;span style="color: blue;"&gt;+&lt;/span&gt; &lt;span style="color: maroon;"&gt;1&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;reader&lt;/span&gt; &lt;span style="color: blue;"&gt;agent&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ThreeAgent&lt;/span&gt; :&amp;nbsp; &lt;span style="color: blue;"&gt;channel&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Bar&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ThreeAgent&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;()&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// Don't do anything.&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;agent&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;MainAgent&lt;/span&gt; : &lt;span style="color: blue;"&gt;channel&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Microsoft&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;.&lt;/span&gt;&lt;span style="color: #2b91af;"&gt;Axum&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;.&lt;/span&gt;&lt;span style="color: #2b91af;"&gt;Application&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;MainAgent&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;()&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;var&lt;/span&gt; &lt;span style="color: purple;"&gt;one&lt;/span&gt; &lt;span style="color: blue;"&gt;=&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;OneAgent&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;.CreateInNewDomain();&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// Kick off the co-routine.&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: purple;"&gt;one&lt;/span&gt;&lt;span style="color: blue;"&gt;::&lt;/span&gt;value &lt;span style="color: blue;"&gt;&amp;lt;--&lt;/span&gt; &lt;span style="color: maroon;"&gt;0&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// Force a wait.&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;var&lt;/span&gt; &lt;span style="color: purple;"&gt;three&lt;/span&gt; &lt;span style="color: blue;"&gt;=&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;ThreeAgent&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;.CreateInNewDomain();&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;int&lt;/span&gt; res &lt;span style="color: blue;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;receive&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;(&lt;/span&gt;&lt;span style="color: purple;"&gt;three&lt;/span&gt;&lt;span style="color: blue;"&gt;::&lt;/span&gt;res);&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: purple;"&gt;PrimaryChannel&lt;/span&gt;&lt;span style="color: blue;"&gt;::&lt;/span&gt;ExitCode &lt;span style="color: blue;"&gt;&amp;lt;--&lt;/span&gt; &lt;span style="color: maroon;"&gt;0&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre &gt;&lt;span style="font-weight: bold;"&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;My current code makes use of agents.  It is faily inefficient as I create agents each time I need to call one and am using channels.  I think a better approach would be to create a simple data network using asynchronous methods as this achieves a similar thing, but is lighter weight.&lt;br /&gt;&lt;a href='http://www.codinghorror.com/blog/archives/000818.html'&gt;&lt;img style='border:none;position:relative;margin:5px;cursor:pointer;cursor:hand;width:50px; height:49px;' src='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png' border='0' id='BLOGGER_PHOTO_ID_5310516322517916706' title='Image by Jeff Atwood and Jon Galloway.'/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-1409438016726590309?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/1409438016726590309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/07/microsoft-axum-co-routine.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1409438016726590309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1409438016726590309'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/07/microsoft-axum-co-routine.html' title='Microsoft Axum Co Routine'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-1275839149510373997</id><published>2009-07-08T10:13:00.004+01:00</published><updated>2009-07-08T10:21:35.000+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='form'/><category scheme='http://www.blogger.com/atom/ns#' term='winforms'/><category scheme='http://www.blogger.com/atom/ns#' term='gotcha'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><title type='text'>Windows Forms Gotcha</title><content type='html'>Well, it might not be a gotcha, but it got me this morning.&lt;br /&gt;&lt;br /&gt;At work, I develop against a piece of software that is an Explorer Namespace Extension that exposes various triggers.  When I need to create and show forms, I don't have a .NET parent form as you traditionally would (from calling Application.Run).  So I thought, just call Form.Show() and let it live in the Explorer window.&lt;br /&gt;&lt;br /&gt;For clarity this piece of code is Code A.  Another piece (below) is Code B.&lt;br /&gt;&lt;br /&gt;All is fine until Code B (running from the same trigger before Code A) created a fading notification form.  This form would live when its underlying trigger was long gone (a fortunate by-product of running in the Explorer process).  When I then went to create my form in Code A, calling .Show would grab the active form (the fading one from Code B in my case) as its parent.&lt;br /&gt;&lt;br /&gt;Code B's form would then exit, sending a closing message to Code A's form - not unexpected.&lt;br /&gt;&lt;br /&gt;It took me a while to see the association, as I was a step back thinking 'why can't I run Code A and Code B together...', my initial avenue was the various message pumps.  I didn't initially realise that Code A's parent was the notification form.&lt;br /&gt;&lt;br /&gt;Just goes to show, always know what window will grab your form!&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-1275839149510373997?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/1275839149510373997/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/07/windows-forms-gotcha.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1275839149510373997'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/1275839149510373997'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/07/windows-forms-gotcha.html' title='Windows Forms Gotcha'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-5979049106725564526</id><published>2009-06-09T09:59:00.003+01:00</published><updated>2009-06-09T10:07:23.715+01:00</updated><title type='text'>Microsoft Axum Playtime Pt. 3</title><content type='html'>It's amazing how awkward life is when you don't have broadband at home...&lt;br /&gt;&lt;br /&gt;Small post this time just to clarify my previous two.  I asked a couple of questions on the Axum forums and got very informative responses.&lt;br /&gt;&lt;br /&gt;Turns out the "linked stack" method is used in Axum in places - hence allowing co-routines and memory-effective blocking (note, not memory-&lt;i&gt;efficient&lt;/i&gt;) via the 'receive' statement.&lt;br /&gt;&lt;br /&gt;Link goodness: &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/axum/thread/800fcb17-aaa7-4a30-923b-6cc15f89fcc3"&gt;my post&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The guys on this forum are very helpful and well in the know - there are lots of questions being thrown at them and the interest in Axum is steadily increasing.&lt;br /&gt;&lt;br /&gt;I think Axum as an incubation, however, is now under competition with some elements of the Parallel Extensions work being done in .NET Fx 4.0.  It's a recurring problem with .NET that there are similar yet subtly different technologies and frameworks being developed; I hope Axum doesn't stay in incubation on the argument that the Parallel Extensions offer the same thing.&lt;br /&gt;&lt;br /&gt;Axum could fill a very niche problem domain in a very accessible way (I say accessible as Stackless and Erlang already address this niche, though aren't backed by .NET, which is increasing in popularity all the time).&lt;br /&gt;&lt;br /&gt;Sorry, still no code - definately next time!&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-5979049106725564526?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/5979049106725564526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/06/microsoft-axum-playtime-pt-3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5979049106725564526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/5979049106725564526'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/06/microsoft-axum-playtime-pt-3.html' title='Microsoft Axum Playtime Pt. 3'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-3152803990547220848</id><published>2009-05-12T08:20:00.003+01:00</published><updated>2009-05-12T08:32:32.819+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='axum'/><category scheme='http://www.blogger.com/atom/ns#' term='parallel'/><category scheme='http://www.blogger.com/atom/ns#' term='microsoft'/><category scheme='http://www.blogger.com/atom/ns#' term='concurrent'/><title type='text'>Microsoft Axum Playtime Pt. 2</title><content type='html'>After my previous post on a simple co-routine, I have slept on it and think I realise what is happening.  I am not sure how Axum creates or handles threads (page 31 in the Programmer's Guide makes it sound like Stackless Python), but I do know that the "receive" statement is blocking, but sending isn't.  &lt;br /&gt;&lt;br /&gt;My co-routine pairs receive an integer once, print it to the Console and then call the opposite in the pair - the receive blocks and the send doesn't.  What could be happening is agent A kicks of agent B and immediately returns, thereby popping any stack (if there is a stack to pop?) and allowing a co-routine to be possible without a stack overflow in the conventional sense.&lt;br /&gt;&lt;br /&gt;Unfortunately, I still don't have any code available as I've lost my download of the code-to-HTML add-in for VS2008 and I can't remember what its called...&lt;br /&gt;&lt;br /&gt;It would be nice to hear more about Axum's internals, and I hope this makes it out of incubation - it will be a great addition to the .NET language collection.&lt;br /&gt;&lt;br /&gt;I had fun last night torturing all 4 of my cores (not something I've actually been able to do yet!) and was even more impressed with how evenly the work was distributed.  There is an example in the Programmer's Guide about using a round-robin style call via the "alternate" operator (page 25) that is suitable for load balancing across endpoints - I can't help but picture a stack of 360's churning through a new Axum.NET version of folding@home :)&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-3152803990547220848?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/3152803990547220848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/05/microsoft-axum-playtime-pt-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/3152803990547220848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/3152803990547220848'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/05/microsoft-axum-playtime-pt-2.html' title='Microsoft Axum Playtime Pt. 2'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-6662660581325191003</id><published>2009-05-11T22:04:00.006+01:00</published><updated>2009-05-11T22:28:17.829+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='axum'/><category scheme='http://www.blogger.com/atom/ns#' term='parallel'/><category scheme='http://www.blogger.com/atom/ns#' term='microsoft'/><category scheme='http://www.blogger.com/atom/ns#' term='concurrent'/><title type='text'>Microsoft Axum Playtime</title><content type='html'>Well, I haven't posted in a while and my current posts are on topics that are a little over-done - so today is a nice change.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/devlabs/dd795202.aspx"&gt;Microsoft Axum&lt;/a&gt;.  The blurb is a little vague on the details.  I know a little about Erlang and Stackless Python, basically that they are both concurrent languages (the latter forgoing a memory stack) and work by passing messages and not blocking; also meaning that co-routines are possible.&lt;br /&gt;&lt;br /&gt;Stackless also uses a scheduler to pass its micro threads through to see if they need processing; they do nothing if they don't need to.  This makes it great for waiting for other things like I/O to finish (see &lt;a href="http://www.eveonline.com/devblog.asp?a=blog&amp;bid=488"&gt;CCP's Eve Online&lt;/a&gt;).  However my limited foray into stackless concluded that it was fantastic at maximising how one core can be used - I never got around to multi-threading a test application and didn't find any such examples.&lt;br /&gt;&lt;br /&gt;So Axum appears on &lt;a href="http://blogs.msdn.com/somasegar/archive/2009/05/08/building-parallel-applications-using-axum.aspx"&gt;Somasegar's blog&lt;/a&gt; and I download it to have a play.  Sorry about the lack of sample code on this one, but its easy enough to create - I'll try and post it next (can't guarantee anything as I spend too much time reading &lt;a href="http://www.hanselman.com/blog/"&gt;Scott Hanselman's blog&lt;/a&gt; about his prolific machine paving and Hansel-oriented goings on and have just bought my first house).&lt;br /&gt;&lt;br /&gt;My first attempt was a co-routine to see if the work done "under the hood" was akin to work done by &lt;a href="http://www.stackless.com/"&gt;Christian Tismer on Stackless&lt;/a&gt;.  Seems as though it was up to the task.  I made a simple application using agents where one agent passes to another, which passes back to the first - incrementing a number.  I print this number to the Console and watch and wait for the stack overflow.  Nothing.&lt;br /&gt;&lt;br /&gt;The following screens are from my quad core.  I edited the code to have 3 pairs of such co-routine callers as described above, each pair added about 15-20% extra load on the CPUs evenly (also note the stable RAM usage):&lt;br /&gt;&lt;div style="text-align:center"&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_MCYUtL3s0Zc/SgiVbSDFp_I/AAAAAAAAAA4/NceM-F0_xk0/s1600-h/CPUMem.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 263px;" src="http://1.bp.blogspot.com/_MCYUtL3s0Zc/SgiVbSDFp_I/AAAAAAAAAA4/NceM-F0_xk0/s400/CPUMem.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5334678054554150898" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_MCYUtL3s0Zc/SgiVbDFmj3I/AAAAAAAAAAw/biCcKuH5DUY/s1600-h/CPUMemGraph.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 351px; height: 400px;" src="http://1.bp.blogspot.com/_MCYUtL3s0Zc/SgiVbDFmj3I/AAAAAAAAAAw/biCcKuH5DUY/s400/CPUMemGraph.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5334678050538164082" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I would pay cold, hard, cash to get this working on an Xbox 360... 3 PowerPC cores anyone?&lt;br /&gt;&lt;br /&gt;Definately look into this if you love .NET like I do.  So that's C#, F#, and Axum - imperative, functional, concurrent...&lt;br /&gt;&lt;br /&gt;Shame .NET moves too fast for individuals to keep up with!&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-6662660581325191003?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/6662660581325191003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/05/microsoft-axum-playtime.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6662660581325191003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6662660581325191003'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/05/microsoft-axum-playtime.html' title='Microsoft Axum Playtime'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_MCYUtL3s0Zc/SgiVbSDFp_I/AAAAAAAAAA4/NceM-F0_xk0/s72-c/CPUMem.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-2511101654588352381</id><published>2009-04-25T11:29:00.012+01:00</published><updated>2009-04-25T15:31:41.076+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gac'/><category scheme='http://www.blogger.com/atom/ns#' term='dll'/><title type='text'>Explore the GAC, again</title><content type='html'>My colleague at work spotted this one.  &lt;a href="http://adamhouldsworth.blogspot.com/2009/03/explore-gac.html"&gt;The first method I found is here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Unregister shfusion.dll, usually found here (though there is an earlier version for pre-2.0):&lt;br /&gt;&lt;ul&gt;&lt;li&gt;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll&lt;/li&gt;&lt;/ul&gt;Using this command in the "Run..." dialog:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;regsvr32 -u C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;And behold your GAC is a folder because the shell extension isn't there.  Re-register to return the GAC to its former glory:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;regsvr32 -i C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;On re-registering it whines about not being able to find an entry point, but when you navigate to your GAC again you will see the shell extension is up and running.&lt;br /&gt;&lt;br /&gt;Much easier than the method I posted about last month.  Enjoy!&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-2511101654588352381?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/2511101654588352381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/04/explore-gac-again.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2511101654588352381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2511101654588352381'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/04/explore-gac-again.html' title='Explore the GAC, again'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-2442570278049756290</id><published>2009-04-20T10:16:00.003+01:00</published><updated>2009-04-25T15:30:20.948+01:00</updated><title type='text'>Data Binding Pitfall Pt. 2</title><content type='html'>An impromptu extension to my &lt;a href="http://adamhouldsworth.blogspot.com/2009/04/data-binding-pitfall.html"&gt;previous post&lt;/a&gt;.  I encountered the same problem again when I loaded the same form for a second time (after having closed it).  This time I reviewed the effects of the background thread on setting the BindingSource.DataSource property.&lt;br /&gt;&lt;br /&gt;I changed my code to cache the data in local variables and then set the data sources in the BackgroundWorker's RunWorkerCompleted - now the problem is gone again.&lt;br /&gt;&lt;br /&gt;Unfortunately this leaves me still wondering where the actual bug is (without stepping into the .NET code), and whether my previous fix had any effect at all.&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-2442570278049756290?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/2442570278049756290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/04/data-binding-pitfall-pt-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2442570278049756290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/2442570278049756290'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/04/data-binding-pitfall-pt-2.html' title='Data Binding Pitfall Pt. 2'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-487686211946811444</id><published>2009-04-07T08:35:00.006+01:00</published><updated>2009-04-07T08:51:15.764+01:00</updated><title type='text'>Data Binding Pitfall</title><content type='html'>I ran into a rather annoying code bug today with data binding.  I was getting the following exception:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;System.ArgumentException:&lt;br /&gt;&lt;i&gt;&lt;b&gt;Column 'x' does not belong to table y.&lt;/b&gt;&lt;/i&gt;&lt;/li&gt;&lt;/ul&gt;In my code, this was happening during the long chain of .NET method calls that comprise data binding.  It was strange initially, because the DataSet did actually contain the column and the data within it was sound.  So through my code, no exceptions occurred.&lt;br /&gt;&lt;br /&gt;My data binding situation was a DataGridView with a DataGridViewComboBoxColumn (DisplayStyle set to Nothing).  The grid bound to a child table in a DataSet that contained a column of IDs (foreign keys into another table), and the combo box provided the lookup for said IDs.&lt;br /&gt;&lt;br /&gt;It turned out my problem was the order in which I was setting the DataSource properties of various items.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;When the form loads, I fetch and bind the parent DataSet table (not the grid's actual data source).&lt;/li&gt;&lt;li&gt;I then fetch child data into the same DataSet (the IDs into this child table).&lt;/li&gt;&lt;li&gt;The child table hangs off a BindingSource linked to a relationship on the main DataSet table, so its automatically bound.&lt;/li&gt;&lt;li&gt;I then fetch and bind the lookup list into a separate BindingSource.&lt;/li&gt;&lt;/ul&gt;Its the fetching (and subsequent binding) of child data before the lookup list that was causing the problems.  Sounds obvious in hindsight, but it wasn't causing any issues during my code; just when the binding was processed later on (presumably in the same order I set things in).&lt;br /&gt;&lt;br /&gt;I changed it to fetch and bind the lookup data before fetching and binding the child data.&lt;br /&gt;&lt;/br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-487686211946811444?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/487686211946811444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/04/data-binding-pitfall.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/487686211946811444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/487686211946811444'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/04/data-binding-pitfall.html' title='Data Binding Pitfall'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-6115070791507503608</id><published>2009-04-03T08:40:00.003+01:00</published><updated>2009-04-03T08:44:43.194+01:00</updated><title type='text'>DataGridView Designer Quirk</title><content type='html'>I've finally gotten around to noting down this quirk after suffering through it who-knows how many times.&lt;br /&gt;&lt;br /&gt;I specify a data source for my DataGridView, and it will pre-populate the columns.  I actually don't want the columns, just the data from the source, so I remove them all and add some unbound columns (which are in-fact rebound as lookup columns using a DataGridViewComboBoxColumn).&lt;br /&gt;&lt;br /&gt;Whenever I do a rebuild, or a clean build, it will re-populate all of the data source's columns that I had removed... !&lt;br /&gt;&lt;br /&gt;Apparently the designer doesn't like it when none of its columns are used; I changed the columns to make use of one of the underlying bound columns and now everything is fine.&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-6115070791507503608?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/6115070791507503608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/04/datagridview-designer-quirk.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6115070791507503608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6115070791507503608'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/04/datagridview-designer-quirk.html' title='DataGridView Designer Quirk'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-6779708590887728070</id><published>2009-03-23T10:27:00.015Z</published><updated>2009-03-25T10:34:38.504Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='.net remoting'/><title type='text'>.NET Remoting IPC Configuration</title><content type='html'>&lt;div style="text-align:justify"&gt;It's that time again where I go-a-Googlin' for the format of how to configure various aspects of .NET Remoting in configuration files.  This time its for an Inter-Process Communication channel, but unfortunately this time Google is not playing ball with my (some may say expert) Google searching skills.&lt;br /&gt;&lt;br /&gt;Over the course of my journey (trying different configurations), I encountered other annoying travelers such as:&lt;br /&gt;&lt;ul style="text-align:left"&gt;&lt;li&gt;Failed to connect to an IPC Port: The system cannot find the file specified.&lt;/li&gt;&lt;/ul&gt;And:&lt;br /&gt;&lt;ul style="text-align:left"&gt;&lt;li&gt;Remoting configuration failed with the exception 'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.Runtime.Remoting.RemotingException: Failed to create an IPC Port: Access is denied.&lt;/li&gt;&lt;/ul&gt;After a little trial-and-error, I managed to get it working.  Then I did what I usually do, which is to go back through the fix and break parts of it to see which of the many 'fixes' that I applied actually need to stick around.&lt;br /&gt;&lt;br /&gt;It turns out my problems were:&lt;ul&gt;&lt;li&gt;In my configuration file I specified "portname" instead of "portName".&lt;/li&gt;&lt;li&gt;I used the same port name for both the client and server.  They have to be different.  Also, client port names have to be different from each other.&lt;/li&gt;&lt;/ul&gt;That's about it.  One 'fix' I ruled out was:&lt;ul&gt;&lt;li&gt;Inserting a 'clientProviders' and 'serverProviders' formatter for the client and server respectively (I was using binary, which then changed my hosted object name to be suffixed with .rem).&lt;/li&gt;&lt;/ul&gt;I will post the final configuration file next time, because I also want to post a few more examples of other configurations.&lt;br /&gt;&lt;br /&gt;Some time in the near future I want to publish a more extensive list of configurations, with accompanying scenarios, and a sample application to demonstrate the many variations of .NET Remoting - even though you are meant to use WCF :)&lt;br /&gt;&lt;br/&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-6779708590887728070?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/6779708590887728070/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/net-remoting-ipc-configuration.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6779708590887728070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6779708590887728070'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/net-remoting-ipc-configuration.html' title='.NET Remoting IPC Configuration'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-6975873844020318834</id><published>2009-03-16T19:54:00.006Z</published><updated>2009-03-22T19:58:52.328Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='visual studio 2008'/><title type='text'>Hijack Visual Studio Toolbox Icons</title><content type='html'>I was making a DataGridViewDateTimePickerColumn (as you do) and I wanted to make it look nice for myself in the ol' IDE.  Looking at the existing columns for the DGV, the icons are simply those of the actual underlying controls.&lt;br /&gt;&lt;br /&gt;So I set about screen-printing and &lt;a href="http://www.paint.net/"&gt;Paint.NET&lt;/a&gt;-ing to get the DateTimePicker image as an image, only to later find that you can hijack a type's icon by specifying the type in this &lt;a href="http://msdn.microsoft.com/en-us/library/zs3w86y9.aspx"&gt;ToolboxBitmapAttribute constructor&lt;/a&gt; (triggering a search in the type's assembly for the relevant resource).&lt;br /&gt;&lt;br /&gt;Cute.&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-6975873844020318834?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/6975873844020318834/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/hijack-visual-studio-icons.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6975873844020318834'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6975873844020318834'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/hijack-visual-studio-icons.html' title='Hijack Visual Studio Toolbox Icons'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-7800472683676832811</id><published>2009-03-10T08:39:00.005Z</published><updated>2009-03-22T19:58:31.453Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='gac'/><title type='text'>ADODB.dll Deployment Woes</title><content type='html'>"Could not load file or assembly 'ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."&lt;br /&gt;&lt;br /&gt;What a nice greeting to a live deployment on a brand-new server that had the .NET Fx 2.0 Redistributable installed on it.  Our application was working fine on the development server, but not on the live server.&lt;br /&gt;&lt;br /&gt;Apparently its because the GAC install of ADODB.dll only happens with the Framework SDK, not the Redistributable.  Copy-local on the assembly reference solves the issue, but as my development environment made this issue transparent to me during development, and the 'test' server wasn't a carbon-copy of the live server - it still caused time to be lost going live.&lt;br /&gt;&lt;br /&gt;Annoying how the framework you develop on is different from the redistributable it gives you... why call it a redistributable if you aren't redistributing the same thing?&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-7800472683676832811?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/7800472683676832811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/adodbdll-deployment-woes.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7800472683676832811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7800472683676832811'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/adodbdll-deployment-woes.html' title='ADODB.dll Deployment Woes'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-4749645141775147605</id><published>2009-03-09T18:41:00.006Z</published><updated>2009-03-22T19:58:12.866Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><title type='text'>Type.GetType Type Strings</title><content type='html'>Loads of posts lately, mostly because these posts actually sit on my desk in the form of a 'Dev Notes.doc' and I'm slowly blogging them.&lt;br /&gt;&lt;br /&gt;Got stumped by this one for a short while not too long ago.  I had a nested class that I was trying to load into an AppDomain via its type name string, which I thought when walking the namespace stack was dot '.' delimited - which of course it is, but I made the mistake of continuing the dot notation into the 'parent-nested class' part.&lt;br /&gt;&lt;br /&gt;Instead you're meant to use a plus '+', as documented &lt;a href="http://msdn.microsoft.com/en-us/library/aa332510.aspx"&gt;extensively on MSDN&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;So in my case, we had a namespace 'AdamsNamespace', a parent class 'AdamsParent', and a nested class 'TheNestedClass'.  My original attempt was this:&lt;ul&gt;&lt;li&gt;AdamsNamespace.AdamsParent.TheNestedClass&lt;/li&gt;&lt;/ul&gt;Instead its this:&lt;ul&gt;&lt;li&gt;AdamsNamespace.AdamsParent+TheNestedClass&lt;/li&gt;&lt;/ul&gt;&amp;lt;Homer&amp;gt; D'oh! &amp;lt;/Homer&amp;gt;&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-4749645141775147605?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/4749645141775147605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/typegettype-type-strings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/4749645141775147605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/4749645141775147605'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/typegettype-type-strings.html' title='Type.GetType Type Strings'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-3670972939377829690</id><published>2009-03-09T17:45:00.016Z</published><updated>2009-03-22T19:58:39.618Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='gac'/><title type='text'>Explore the GAC</title><content type='html'>Not sure why I haven't searched this before, but today I needed to get a DLL out of the GAC to send someone the resulting DLL.&lt;br /&gt;&lt;br /&gt;How?  Well actually with a lot of faffing:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Go to your GAC folder in a command prompt. Mine is C:\Windows\assembly&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Alter the attributes of the desktop.ini file using the following command:&lt;br /&gt;&lt;b&gt;&lt;i&gt;attrib -s -r -h -a desktop.ini&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the name of the file using the following command:&lt;br /&gt;&lt;b&gt;&lt;i&gt;rename desktop.ini desktop.old&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;Now you can browse the GAC as a regular folder. The DLLs themselves are buried within the 'GAC' folder, then the corresponding 'assembly name'-named folder (as appeared in the usual GAC), then the corresponding 'file version plus public key token'-named folder (again as appeared in the usual GAC) to find the DLL.&lt;br /&gt;&lt;br /&gt;To restore the regular GAC, rename the desktop.old back to desktop.ini - this is now your GAC switch; I made a couple of batch files to toggle this for future use.&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-3670972939377829690?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/3670972939377829690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/explore-gac.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/3670972939377829690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/3670972939377829690'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/explore-gac.html' title='Explore the GAC'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-8818541894276006872</id><published>2009-03-08T17:16:00.006Z</published><updated>2009-03-22T19:57:48.035Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='visual studio 2008'/><title type='text'>VS2008 No DataSet Designer</title><content type='html'>Odd error today.  I opened Visual Studio 2008 (SP1), tried to open one of my website's datasets and got an error telling me it couldn't load the designer.  At the same time, my Server Explorer decided to bomb out.&lt;br /&gt;&lt;br /&gt;I Googled it quickly and noted a few people saying to repair/re-install - I tried both to no avail.&lt;br /&gt;&lt;br /&gt;I then spotted &lt;a href="http://social.msdn.microsoft.com/forums/en-US/vssetup/thread/83fe32f2-bc10-4806-a5ce-e389572580cd"&gt;this&lt;/a&gt; post - thankfully, it worked.&lt;br /&gt;&lt;br /&gt;The only annoying thing now is did I just waste an afternoon re-installing?&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-8818541894276006872?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/8818541894276006872/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/vs2008-no-dataset-designer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/8818541894276006872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/8818541894276006872'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/vs2008-no-dataset-designer.html' title='VS2008 No DataSet Designer'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-6694460966495429945</id><published>2009-03-07T18:21:00.016Z</published><updated>2009-03-22T19:57:28.627Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql 2005'/><title type='text'>SQL Nested Sproc Call</title><content type='html'>How many times have I wanted to do this? I found an article &lt;a href="http://www.aspfree.com/c/a/ASP.NET-Code/Call-Stored-procedure-from-within-another-stored-procedure-return-values/"&gt;here&lt;/a&gt; that showed an extremely easy and clean way to call a stored procedure from within a stored procedure:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;br/&gt;&lt;pre&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;CREATE PROCEDURE &lt;/span&gt;[dbo].[getDataByName]&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;(&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @name &lt;span style="color: blue;"&gt;varchar&lt;/span&gt;(50),&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @deleted &lt;span style="color: blue;"&gt;bit &lt;/span&gt;= 0 &lt;span style="color: green;"&gt;--parameter to pass through&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;)&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;AS&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;DECLARE &lt;/span&gt;@id &lt;span style="color: blue;"&gt;int&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SELECT &lt;/span&gt;@id = DataID &lt;span style="color: blue;"&gt;FROM &lt;/span&gt;MyData &lt;span style="color: blue;"&gt;WHERE &lt;/span&gt;[Name] = @name&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;EXEC &lt;/span&gt;getData @id, @deleted&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;/pre&gt;&lt;br/&gt;&lt;/div&gt;&lt;br /&gt;As you can guess, the "nested" stored procedure is called getData and takes an @id int and @deleted bit. The parameters are simply comma delimited (I always used to try wrapping them in brackets for some reason...) and it handles output parameters too.&lt;br /&gt;&lt;br /&gt;In my example, the EXEC call automatically passes back the result set through the outer stored procedure (getDataByName) back to my calling code.&lt;br /&gt;&lt;br /&gt;The end result behaves similar to an overloaded method in C# (obviously without the same method name), in that the logic used is in one place (getData).&lt;br /&gt;&lt;br /&gt;I plan on using this to have other stored procedures call maintenance code when relevant data is affected.&lt;br /&gt;&lt;a href='http://www.codinghorror.com/blog/archives/000818.html'&gt;&lt;img style='border:none;position:relative;margin:5px;cursor:pointer;cursor:hand;width:50px; height:49px;' src='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s200/Works+on+My+Machine+Small.png' border='0' id='BLOGGER_PHOTO_ID_5310516322517916706' title='Image by Jeff Atwood and Jon Galloway.'/&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-6694460966495429945?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/6694460966495429945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/sql-2005-nested-stored-procedure-call.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6694460966495429945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6694460966495429945'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/sql-2005-nested-stored-procedure-call.html' title='SQL Nested Sproc Call'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MCYUtL3s0Zc/SbK-dYGYHCI/AAAAAAAAAAU/f-2_7nqGQNE/s72-c/Works+on+My+Machine+Small.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-6146505939007187893</id><published>2009-03-07T15:55:00.042Z</published><updated>2009-03-22T19:57:10.012Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='asp.net'/><title type='text'>ASP.NET Eval Usage</title><content type='html'>Stumbled across a use I've never seen before when I wanted to hide the Delete button for system entries.  I tried emitting markup during the &lt;a href="http://msdn.microsoft.com/en-us/library/4hx47hfe.aspx"&gt;Eval&lt;/a&gt; call like so:&lt;br /&gt;&lt;br /&gt;&lt;div class="cb"&gt;&lt;br/&gt;&lt;pre&gt;&lt;span style="color:#2b91af;"&gt;   44&lt;/span&gt;&lt;span style="BACKGROUND: #ffee62;"&gt;&amp;nbsp;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;#&lt;/span&gt;Eval(&lt;span style="color:#a31515;"&gt;"IsSystemEntry"&lt;/span&gt;).ToString() == &lt;span style="color:#a31515;"&gt;"True"&lt;/span&gt; ? &lt;/pre&gt;&lt;pre&gt;&lt;span style="color:#2b91af;"&gt;   45&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt;.Empty &lt;/pre&gt;&lt;pre&gt;&lt;span style="color:#2b91af;"&gt;   46&lt;/span&gt;   :&lt;/pre&gt;&lt;pre&gt;&lt;span style="color:#2b91af;"&gt;   47&lt;/span&gt; &lt;span style="color:#a31515;"&gt;"&amp;lt;asp:LinkButton ID=\"cmdDelete\" runat=\"server\" CommandName=\"Delete\" Text=\"Delete\" /&amp;gt;"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="color:#2b91af;"&gt;   48&lt;/span&gt; &lt;span style="BACKGROUND: #ffee62"&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br/&gt;&lt;/div&gt;&lt;br /&gt;The Eval is mapping to a bool on a DataSet and is within an ItemTemplate of the ASP.NET 3.5 ListView control. &lt;br /&gt;&lt;br /&gt;I was surprised when this worked first time for me, so it's definately earnt the "&lt;a href="http://jcooney.net/archive/2007/02/01/42999.aspx"&gt;Works on My Machine&lt;/a&gt;" certificate (self-certified, of course :)&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;&lt;img id="BLOGGER_PHOTO_ID_5310475901988329394" title="Image by Jeff Atwood and Jon Galloway." style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN: 0px 10px 10px 0px; BORDER-LEFT: medium none; WIDTH: 200px; CURSOR: hand; BORDER-BOTTOM: medium none; HEIGHT: 193px" alt="" src="http://4.bp.blogspot.com/_MCYUtL3s0Zc/SbKZsl5JV7I/AAAAAAAAAAM/y1uOhsc-F2s/s320/Works+on+My+Machine.png" border="0" /&gt;&lt;/a&gt;&lt;/center&gt;I'm not sure what would happen if I needed to use another Eval or Bind call in the Delete button somewhere... haven't tried that yet.&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-6146505939007187893?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/6146505939007187893/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/aspnet-eval-usage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6146505939007187893'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/6146505939007187893'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/aspnet-eval-usage.html' title='ASP.NET Eval Usage'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_MCYUtL3s0Zc/SbKZsl5JV7I/AAAAAAAAAAM/y1uOhsc-F2s/s72-c/Works+on+My+Machine.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4504841978562309153.post-7517395406806900470</id><published>2009-03-07T15:40:00.001Z</published><updated>2009-03-07T16:16:45.922Z</updated><title type='text'>Hello, World</title><content type='html'>Yes, geek reference intended.  First post on my first "dev blog".&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4504841978562309153-7517395406806900470?l=adamhouldsworth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamhouldsworth.blogspot.com/feeds/7517395406806900470/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/hello-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7517395406806900470'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4504841978562309153/posts/default/7517395406806900470'/><link rel='alternate' type='text/html' href='http://adamhouldsworth.blogspot.com/2009/03/hello-world.html' title='Hello, World'/><author><name>Adam</name><uri>http://www.blogger.com/profile/09389531666445329960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
