<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-3002872373515344423</atom:id><lastBuildDate>Mon, 29 Sep 2025 06:39:43 +0000</lastBuildDate><category>c#</category><category>nhibernate</category><category>iis7</category><category>mongodb</category><category>nosql</category><category>server2008</category><category>sqlserver2008</category><category>windows7</category><category>.net</category><category>activedirectory</category><category>activereports</category><category>audio</category><category>chrome</category><category>database</category><category>dns</category><category>domaincontroller</category><category>elmah</category><category>email</category><category>extensions</category><category>ftp</category><category>google</category><category>grapecity</category><category>hangouts</category><category>hosting</category><category>icriteria</category><category>ie6</category><category>javascript</category><category>jquery</category><category>jquery validation</category><category>loopbackadapter</category><category>msdeploy</category><category>mvc</category><category>networking</category><category>queryover</category><category>reflection</category><category>server2003</category><category>sql</category><category>ssl</category><category>virtualization</category><category>webdesign</category><title>Methodic Madness</title><description>A Dev Blog with a Method</description><link>http://www.methodicmadness.com/</link><managingEditor>noreply@blogger.com (JP)</managingEditor><generator>Blogger</generator><openSearch:totalResults>27</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-4966703750256461839</guid><pubDate>Mon, 25 Jul 2016 14:31:00 +0000</pubDate><atom:updated>2016-07-25T10:33:02.779-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">chrome</category><category domain="http://www.blogger.com/atom/ns#">google</category><category domain="http://www.blogger.com/atom/ns#">hangouts</category><title>Multiple Google Hangouts Accounts on Desktop</title><description>If you&#39;re like me, you have many many google apps accounts, for business, personal, or varying other purposes. For me, this works fine on my android device, where the Hangouts app is designed to support as multiple identities just fine. However, on my desktop, where I spend most of my day, the Hangouts Chrome app lacks this support.&lt;br /&gt;
&lt;br /&gt;
There is an &lt;a href=&quot;https://support.google.com/hangouts/answer/6101833?hl=en&quot;&gt;official work around&lt;/a&gt; suggested by Google&#39;s support team. Until recently, this work around was sufficient. By enabling the Chrome app launcher, I could open the Hangouts app from each account by changing profiles from the hamburger menu in the app launcher. However, Google is &lt;a href=&quot;http://blog.chromium.org/2016/03/retiring-chrome-app-launcher.html&quot;&gt;deprecating the Chrome app launcher&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Without the app launcher, getting Hangouts open with multiple profiles requires opening a chrome window, opening the app page, and finding and clicking the Hangouts app, then repeat for each profile. This is too many steps to feel efficient for me, and since Hangouts is an integral tool for my daily business, I must have it open at all times, and I need a fast way to get it running.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Enter shortcuts.&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Today I finally found the best solution so far. Using Chrome app shortcuts.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Chrome.exe supports two very useful parameters: profile-directory, and app-id. When you choose &quot;Create shortcuts...&quot; from the right click menu on chrome://apps, the shortcuts created include these two parameters so that the resultant app shortcut is bound to the profile from which you created it.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLzYcaMHDgsm3VqqfILEAFrGaQV0Fe_Eh0KE9ewWc2VPhUD4NYvCbJ4EOKkaAp2S19rOvVUedJFoYNY8gqBXj4vsoe1k-6sVk6hq0T2XnZIIRl4C92k_Hf9E_PM2ZlAXQzXxEbig_q3c0/s1600/hangouts_shortcuts.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;135&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLzYcaMHDgsm3VqqfILEAFrGaQV0Fe_Eh0KE9ewWc2VPhUD4NYvCbJ4EOKkaAp2S19rOvVUedJFoYNY8gqBXj4vsoe1k-6sVk6hq0T2XnZIIRl4C92k_Hf9E_PM2ZlAXQzXxEbig_q3c0/s320/hangouts_shortcuts.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Choosing this option only offers one place to create the shortcut (Desktop) but fortunately, Chrome is smart enough to save an additional copy of the same shortcut in the Start Menu (specifically:&amp;nbsp;AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Chrome Apps) so there is no need to keep the desktop shortcut around. We can rename these shortcuts to help us quickly find and launch a Hangouts app for each profile.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUfWz_h4F6vohFt-i7HLZqlUT9FXcMqBq07oBAGwjTfA8O1jeBf0BQu2ZncL0AsVmhNcatzKp-Kl-20K7WZh_oaadvi83yHmsYTfuXEnkhueqMZAQhfmCkp9Ms5D6kYyQEYm4CtZ8_BXw/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;170&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUfWz_h4F6vohFt-i7HLZqlUT9FXcMqBq07oBAGwjTfA8O1jeBf0BQu2ZncL0AsVmhNcatzKp-Kl-20K7WZh_oaadvi83yHmsYTfuXEnkhueqMZAQhfmCkp9Ms5D6kYyQEYm4CtZ8_BXw/s320/Capture.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Incidentally, these shortcuts are profile bound not by any logical account id, but rather by account order. They use &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;--profile-directory=&quot;Default&quot;&lt;/span&gt; and&amp;nbsp;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;--profile-directory=&quot;Profile 1&quot; &lt;/span&gt;arguments to launch the app. So if you find yourself disconnecting and reconnecting your profiles in Chrome, your shortcuts may stop working or start launching the app with the wrong profile.&lt;/div&gt;
</description><link>http://www.methodicmadness.com/2016/07/multiple-google-hangouts-accounts-on.html</link><author>noreply@blogger.com (JP)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLzYcaMHDgsm3VqqfILEAFrGaQV0Fe_Eh0KE9ewWc2VPhUD4NYvCbJ4EOKkaAp2S19rOvVUedJFoYNY8gqBXj4vsoe1k-6sVk6hq0T2XnZIIRl4C92k_Hf9E_PM2ZlAXQzXxEbig_q3c0/s72-c/hangouts_shortcuts.PNG" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-163849080832050281</guid><pubDate>Wed, 14 Jan 2015 15:47:00 +0000</pubDate><atom:updated>2015-01-14T10:52:08.619-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">sql</category><title>SQL: Convert a Hash to a Varchar</title><description>For some reason this task always stumps me, so here is the solution:&lt;br /&gt;
&lt;pre class=&quot;brush:sql&quot;&gt;CONVERT([varchar](512), hashbytes(&#39;sha&#39;, col), 2)&lt;/pre&gt;
Thanks to &lt;a href=&quot;http://basitaalishan.com/2014/09/11/sql-server-converting-binary-data-to-a-hexadecimal-string/&quot;&gt;Basit&lt;/a&gt;</description><link>http://www.methodicmadness.com/2015/01/sql-convert-hash-to-varchar.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-9102985633807175434</guid><pubDate>Fri, 12 Oct 2012 16:08:00 +0000</pubDate><atom:updated>2012-10-12T12:08:42.752-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">javascript</category><category domain="http://www.blogger.com/atom/ns#">jquery</category><category domain="http://www.blogger.com/atom/ns#">jquery validation</category><title>JQuery Validate: Change Option Value</title><description>In my current project I have a default set of options that every form gets validated with. In fact, .validate(options) is called for every form.&lt;br /&gt;
&lt;br /&gt;
Today I needed to change one of the options that my form validator was initialized with. Sounds pretty simple, but for the life of me I couldn&#39;t find anything like setOption() or .validate(&quot;option&quot;, {}) like other plugins have.&lt;br /&gt;
&lt;br /&gt;
Turns out that Validate actually makes it &lt;i&gt;too &lt;/i&gt;simple. Where other plugins give you non-standardized functions to update the options, Validate gives you the options object directly... but they call it settings.&lt;br /&gt;
&lt;br /&gt;
I can disable the auto onsubmit validation by doing the following:&lt;br /&gt;
&lt;pre class=&quot;brush:javascript&quot;&gt;$(&quot;#myForm&quot;).validate().settings.onsubmit = false;&lt;/pre&gt;
This works because .validate() returns the current validator for the form, and the validator neatly exposes the settings collection.</description><link>http://www.methodicmadness.com/2012/10/jquery-validate-change-option-value.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-4871087323322753423</guid><pubDate>Wed, 25 Apr 2012 14:19:00 +0000</pubDate><atom:updated>2012-04-25T10:21:06.090-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c#</category><category domain="http://www.blogger.com/atom/ns#">extensions</category><category domain="http://www.blogger.com/atom/ns#">nhibernate</category><category domain="http://www.blogger.com/atom/ns#">queryover</category><title>Extending QueryOver With &quot;Or&quot;</title><description>QueryOver (introduced in NHibernate 3.0) offers type safe, Linq-esque, syntax for writing Nhibernate queries in your DAO. However, writing a multiple column disjunction with anything other than simple operators can easily become ugly and unwieldy.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
With QueryOver, we can do awesome things like:
&lt;br /&gt;
&lt;pre class=&quot;brush:c-sharp&quot;&gt;var bk = QueryOver.Of&amp;lt;Book&amp;gt;();
bk.Where(b =&amp;gt; b.Name == &quot;Of Mice And Men&quot;);&lt;/pre&gt;
Which is miles better than the ICriteria equivalent:
&lt;br /&gt;
&lt;pre class=&quot;brush:c-sharp&quot;&gt;var bk = DetachedCriteria.For&amp;lt;Book&amp;gt;();
bk.Add(Restrictions.Eq(&quot;Name&quot;, &quot;Of Mice And Men&quot;));&lt;/pre&gt;
QueryOver even allows search operators that do not translate directly to C# operators. &quot;LIKE&quot; for instance:
&lt;br /&gt;
&lt;pre class=&quot;brush:c-sharp&quot;&gt;bk.WhereRestrictionOn(b =&amp;gt; b.Name).IsInsensitiveLike(&quot;Of Mice&quot;);&lt;/pre&gt;
Which can also be written:
&lt;br /&gt;
&lt;pre class=&quot;brush:c-sharp&quot;&gt;bk.Where(Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.Name).IsInsensitiveLike(&quot;Of Mice&quot;));&lt;/pre&gt;
Allowing us to create a simple disjunction:
&lt;br /&gt;
&lt;pre class=&quot;brush:c-sharp&quot;&gt;bk.Where(Restrictions.Or(
    Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.Name).IsInsensitiveLike(search),
    Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.Summary).IsInsensitiveLike(search)
));&lt;/pre&gt;
So far, so elegant. &lt;br /&gt;
&lt;br /&gt;
The trouble starts when you need to create a disjunction using more than two &quot;On&quot; restrictions. Because &quot;Or()&quot; only accepts two arguments, things will rapidly spiral out of control if you try to extend this approach. Just look what it turns into with 5 fields.
&lt;br /&gt;
&lt;pre class=&quot;brush:c-sharp&quot;&gt;bk.Where(Restrictions.Or(
    Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.Name).IsInsensitiveLike(search),
    Restrictions.Or(
        Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.Summary).IsInsensitiveLike(search),
        Restrictions.Or(
            Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.Synopsis).IsInsensitiveLike(search),
            Restrictions.Or(
                Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.BookCode).IsInsensitiveLike(search),
                Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.ISBN).IsInsensitiveLike(search)
            )
        )
    ) 
));&lt;/pre&gt;
This makes me very sad.&lt;br /&gt;
&lt;br /&gt;
But there&#39;s hope! Thanks to C#&#39;s extension feature and param arguments, we can write a method that will take as many abstract criteria as we care to hand it. Here&#39;s what I came up with:
&lt;br /&gt;
&lt;pre class=&quot;brush:c-sharp&quot;&gt;public static class Extensions
{
    public static IQueryOver&amp;lt;troot, tsubtype&amp;gt; Or&amp;lt;troot, tsubtype&amp;gt;(this IQueryOver&amp;lt;troot, tsubtype&amp;gt; input, params ICriterion[] criteria)
    {
        if (criteria.Length == 0)
            return input;
        else if (criteria.Length == 1)
            return input.Where(criteria[0]);
        else
        {
            var or = Restrictions.Or(criteria[0], criteria[1]);
            for (int i = 2; i &amp;lt; criteria.Length; i++)
                or = Restrictions.Or(or, criteria[i]);
 
           return input.Where(or);
        }
    }
}&lt;/pre&gt;
And now our crazy where clause simplifies to this:
&lt;br /&gt;
&lt;pre class=&quot;brush:c-sharp&quot;&gt;var bk = QueryOver.Of&amp;lt;Book&amp;gt;();
bk.Or(
    Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.Name).IsInsensitiveLike(search),
    Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.Summary).IsInsensitiveLike(search),
    Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.Synopsis).IsInsensitiveLike(search),
    Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.BookCode).IsInsensitiveLike(search),
    Restrictions.On&amp;lt;Book&amp;gt;(b =&amp;gt; b.ISBN).IsInsensitiveLike(search)
);&lt;/pre&gt;</description><link>http://www.methodicmadness.com/2012/04/extending-queryover-with-or.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-2555807101315490424</guid><pubDate>Tue, 13 Mar 2012 18:46:00 +0000</pubDate><atom:updated>2012-03-13T14:52:06.418-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">sqlserver2008</category><title>T-SQL: Aggregate a column to a comma delimited list</title><description>I commonly encounter situations where it is useful to select a comma delimited list as an aggregate in a grouped query. This is a well known problem and yet each time I run across it I have to look something up to solve it.&lt;br /&gt;
&lt;br /&gt;
The following is a detailed breakdown of the solution from the&amp;nbsp;&lt;a href=&quot;http://archive.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=createacommadelimitedlist&quot; target=&quot;_blank&quot;&gt;msdn archive&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The scenario I&#39;m covering here is the need to aggregate all the IDs in a joined table into a single column on the master table. We&#39;ll use a table structure like this:&lt;br /&gt;
&lt;pre class=&quot;brush:sql&quot;&gt;CREATE TABLE Parent (
  Id int NOT NULL identity,
  Name varchar(50) NOT NULL,
  Children varchar(256) NULL,
)
CREATE TABLE Child (
  Id int NOT NULL identity,
  ParentId int NOT NULL,
  Name varchar(50) NOT NULL
)&lt;/pre&gt;
Create some sample data:
&lt;br /&gt;
&lt;pre class=&quot;brush:sql&quot;&gt;INSERT INTO Parent (Name)
VALUES (&#39;Parent 1&#39;), (&#39;Parent 2&#39;), (&#39;Parent 3&#39;)
INSERT INTO Child (ParentId, Name)
VALUES (1, &#39;Child 1&#39;), (1, &#39;Child 2&#39;), (1, &#39;Child 3&#39;), (2, &#39;Child 4&#39;), (2, &#39;Child 5&#39;), (3, &#39;Child 6&#39;), (3, &#39;Child 7&#39;), (3, &#39;Child 8&#39;), (3, &#39;Child 9&#39;)&lt;/pre&gt;
Now we can update the Children column on Parent with this:
&lt;br /&gt;
&lt;pre class=&quot;brush:sql&quot;&gt;;
WITH
t AS (SELECT p1.Id, Children = (
    SELECT (&#39;,&#39; + convert(varchar, c2.Name ))
    FROM Parent p2
      JOIN Child c2 ON p2.Id = c2.ParentId
    WHERE p2.Id = p1.Id
    ORDER BY c2.Id
    FOR XML PATH( &#39;&#39; )
  ) + &#39;,&#39;
  FROM Parent p1
    JOIN Child c1 ON p1.Id = c1.ParentId
  GROUP BY p1.Id)
UPDATE p
SET Children = t.Children
FROM Parent p
  JOIN t ON t.Id = p.Id&lt;/pre&gt;
And the results look like:
&lt;br /&gt;
&lt;pre&gt;Id | Name | Children
1 | Parent 1 | ,Child 1,Child 2,Child 3,
2 | Parent 2 | ,Child 4,Child 5,
3 | Parent 3 | ,Child 6,Child 7,Child 8,Child 9,&lt;/pre&gt;</description><link>http://www.methodicmadness.com/2012/03/t-sql-aggregate-column-to-comma.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-4117270421139728346</guid><pubDate>Thu, 09 Jun 2011 19:10:00 +0000</pubDate><atom:updated>2011-06-09T15:25:32.414-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">activereports</category><category domain="http://www.blogger.com/atom/ns#">c#</category><category domain="http://www.blogger.com/atom/ns#">grapecity</category><title>ActiveReports: Grouping</title><description>We&#39;ve used &lt;a href=&quot;http://www.datadynamics.com/&quot;&gt;Grape City&#39;s (formerly Data Dynamics) ActiveReports&lt;/a&gt; off and on for many years. I&#39;m not truly a fan since personally I&#39;ve never found it that intuitive, but for flexibility they&#39;re pretty good. &lt;br /&gt;&lt;br /&gt;Recently I ran into a quirk I&#39;ve encountered before but had forgotten. I won&#39;t call it a bug since we&#39;re using it in a manner that is undocumented and most likely not supported.&lt;br /&gt;&lt;br /&gt;Since AR uses (or appears to use) DataBinder.Eval to evaluate the DataField on each object in the DataSource of a report, we have always used collections of domain objects for our report sources. This works well for textboxes, however, when you try to do a standard report grouping (with header and footer) you&#39;ll get stuck wondering why the report only seems to recognize one group. Specifically this occurs when you use a property path of depth greater than one.&lt;br /&gt;&lt;br /&gt;The following works:&lt;pre class=&quot;brush:c-sharp&quot;&gt;myTextbox.DataField = &quot;Property1.Property2&quot;;&lt;br /&gt;myGroupheader.DataField = &quot;Property1&quot;;&lt;br /&gt;&lt;/pre&gt;This does not:&lt;pre class=&quot;brush:c-sharp&quot;&gt;myTextbox.DataField = &quot;Property1.Property2&quot;;&lt;br /&gt;myGroupheader.DataField = &quot;Property1.Property2&quot;;&lt;br /&gt;&lt;/pre&gt;The textbox will populate correctly but the report will only discover one group of records.</description><link>http://www.methodicmadness.com/2011/06/activereports-grouping.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-6343724154731567274</guid><pubDate>Fri, 06 May 2011 20:24:00 +0000</pubDate><atom:updated>2011-05-10T18:08:46.042-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c#</category><category domain="http://www.blogger.com/atom/ns#">icriteria</category><category domain="http://www.blogger.com/atom/ns#">nhibernate</category><title>NHibernate: Group By Case Statement</title><description>Today I wanted to speed up some statistics tables which had been tossed into our application dashboard awhile back. The queries were originally written quick and dirty to just pull back all of the records in the table then run some linq counts on them. Terrible of course and there was a nice little comment above the section saying something about &quot;TODO: make this better&quot;.&lt;br /&gt;&lt;br /&gt;The quickest query I could think of to run these statistics looks something like this:&lt;pre class=&quot;brush:sql&quot;&gt;select &lt;br /&gt;  IsJourneyman, &lt;br /&gt;  case when Accepted is null then 1 else 0 end, &lt;br /&gt;  Count(*)&lt;br /&gt;from &lt;br /&gt;  students&lt;br /&gt;group by &lt;br /&gt;  IsJourneyman, &lt;br /&gt;  case when Accepted is null then 1 else 0 end&lt;/pre&gt;My next thought was &quot;Can I implement this in ICriteria?&quot; Well it turns out the answer is Yes!&lt;pre class=&quot;brush:c#&quot;&gt;var cr = Session.CreateCriteria&amp;lt;Student&amp;gt;();&lt;br /&gt;&lt;br /&gt;cr.SetProjection(Projections.ProjectionList()&lt;br /&gt;  .Add(Projections.RowCount(), &quot;Count&quot;)&lt;br /&gt;  .Add(Projections.Group&amp;lt;Student&amp;gt;(s =&gt; s.IsJourneyman), &quot;IsJourneyman&quot;)&lt;br /&gt;  .Add(Projections.GroupProperty(&lt;br /&gt;    Projections.SqlProjection(&quot;case when Accepted is null then 1 else 0 end&quot;,&lt;br /&gt;      new[] { &quot;IsApplicant&quot; }, new[] { NHibernateUtil.Boolean })), &lt;br /&gt;      &quot;IsApplicant&quot;)&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;// transform the results into a strong typed object&lt;br /&gt;cr.SetTransformer(Transformers.AliasToBean(typeof(CountResult)));&lt;br /&gt;&lt;br /&gt;return cr.List&amp;lt;CountResult&amp;gt;();&lt;/pre&gt;For which I created this simple class. The aliases passed to .Add() are used to match up the properties.&lt;pre class=&quot;brush:c#&quot;&gt;public class CountResult&lt;br /&gt;{&lt;br /&gt;  public bool IsJourneyman { get; set; }&lt;br /&gt;  public bool IsApplicant { get; set; }&lt;br /&gt;  public int Count { get; set; }&lt;br /&gt;}&lt;/pre&gt;I tried using the Projections.Conditional, but ran into a NHibernate bug on mixing named and ordered parameters. &lt;br /&gt;&lt;br /&gt;I&#39;m sure there are faster ways to accomplish this, but since I wanted to do it in NHibernate without adding a calculated field this will work for me.</description><link>http://www.methodicmadness.com/2011/05/nhibernate-group-by-case-statement.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-4571745122740819013</guid><pubDate>Thu, 21 Apr 2011 16:15:00 +0000</pubDate><atom:updated>2014-03-10T10:53:00.693-04:00</atom:updated><title>Free Reflector Alternatives</title><description>If you&#39;re like me you were super disappointed when Red Gate reneged on their promise to keep .Net Reflector &quot;free forever&quot;. While I don&#39;t use Reflector every day, there are numerous times where I&#39;ve needed to drill into a dll to see how something is accomplished or find some functionality I need. &lt;br /&gt;
&lt;br /&gt;
Fortunately, there are new alternatives appearing for us penny pinchers. Hopefully Red Gate will get the message.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://wiki.sharpdevelop.net/ilspy.ashx&quot;&gt;ILSpy&lt;/a&gt; - ILSpy is a free, open source replacement for .Net Reflector. Look and feel are modeled on Reflector. &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.telerik.com/products/decompiling.aspx&quot;&gt;JustDecompile&lt;/a&gt; (h/t Assia) - Telerik&#39;s foray into the market. Currently in beta but promises regular updates and an integrated auto-updater.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.jetbrains.com/decompiler/index.html?topDP&quot;&gt;dotPeek&lt;/a&gt; - By JetBrains.</description><link>http://www.methodicmadness.com/2011/04/free-reflector-alternative.html</link><author>noreply@blogger.com (JP)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-2129264273568953454</guid><pubDate>Sun, 13 Jun 2010 21:13:00 +0000</pubDate><atom:updated>2012-01-12T10:58:56.559-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c#</category><category domain="http://www.blogger.com/atom/ns#">mongodb</category><category domain="http://www.blogger.com/atom/ns#">nosql</category><title>Practical MongoDB Part 3: Fine Tuning</title><description>&lt;div&gt;In &lt;a href=&quot;http://www.methodicmadness.com/2010/06/practical-mongodb-part-1-up-and-running.html&quot;&gt;Part 1&lt;/a&gt; of this series I briefly discussed setting up MongoDB to run as a service. In &lt;a href=&quot;http://www.methodicmadness.com/2010/06/practical-mongodb-part-2-normalized.html&quot;&gt;Part 2&lt;/a&gt; I covered data access objects. In this installment I&#39;d like to touch on embedded documents before reviewing a few configuration changes you should use to improve performance.&lt;/div&gt;&lt;br /&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style=&quot;font-weight:bold;&quot;&gt;Embedded Documents&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Obviously few real world domain objects consist entirely of primitive members. Most objects contain reference types, or collections of primitives or reference types. Mongo provides support for these too.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Let&#39;s modify our User class from Part 2. In addition to email and password fields, We&#39;d like to store a collection of UserStat objects:&lt;/div&gt;&lt;pre class=&quot;brush:c#&quot;&gt;public class User : ICollectable&lt;br /&gt;{&lt;br /&gt;    public User()&lt;br /&gt;    {&lt;br /&gt;        Stats = new List&amp;lt;UserStat&amp;gt;();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    ...&lt;br /&gt;&lt;br /&gt;    public List&amp;lt;UserStat&amp;gt; Stats { get; private set; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class UserStat&lt;br /&gt;{&lt;br /&gt;    public DateTime Posted { get; internal set; }&lt;br /&gt;    ...&lt;br /&gt;}&lt;/pre&gt;&lt;div&gt;You may notice that UserStat here does not implement &lt;span style=&quot;font-family:&#39;courier new&#39;&quot;&gt;ICollectable&lt;/span&gt;. This is because &lt;span style=&quot;font-family:&#39;courier new&#39;&quot;&gt;ICollectable&lt;/span&gt; is intended to be implemented only on Collection classes. When we save this new User object to Mongo, there will still only be one Collection: User. UserStat only exists inside the context of a User and thus does not require a Collection of its own.&lt;/div&gt;&lt;div&gt;Let&#39;s go ahead and write a test for saving a UserStat.&lt;/div&gt;&lt;pre class=&quot;brush:c#&quot;&gt;public void Can_Save_User_With_Stats()&lt;br /&gt;{&lt;br /&gt;    UserStat stat1 = new UserStat();&lt;br /&gt;    stat1.Posted = DateTime.UtcNow.AddMinutes(5);&lt;br /&gt;    UserStat stat2 = new UserStat();&lt;br /&gt;    stat2.Posted = DateTime.UtcNow.AddMinutes(10);&lt;br /&gt;&lt;br /&gt;    User test = new User();&lt;br /&gt;    test.Email = &quot;email&quot;;&lt;br /&gt;    test.Stats.Add(stat1);&lt;br /&gt;    test.Stats.Add(stat2);&lt;br /&gt;&lt;br /&gt;    using (var dao = new UserDao())&lt;br /&gt;    {&lt;br /&gt;        dao.Insert(test);&lt;br /&gt;&lt;br /&gt;        User found = dao.Get(test.Email);&lt;br /&gt;&lt;br /&gt;        Assert.NotNull(test.Id); // insert succeeded&lt;br /&gt;        Assert.Equal(2, found.Stats.Count);&lt;br /&gt;        Assert.True(found.Stats.Any(s =&gt; s.Posted.Minute == stat1.Posted.Minute));&lt;br /&gt;        Assert.True(found.Stats.Any(s =&gt; s.Posted.Minute == stat2.Posted.Minute));&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;div&gt;After successfully passing this test, we can look at the contents of the collection to see how it was stored.&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align:center;&quot;&gt;&lt;a href=&quot;http://picasaweb.google.com/lh/photo/z6umNkkFH4JyAtEltWmtfAFA_tddwG1m21odRuwSuJM?feat=embedwebsite&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjft_vOTW3u4g32kWvsg2ljNdjTZ2F6jlFSTaosmeh9lZqTvFaatuIfP993wywPqlLNaZqM5EiR4sVVZbjeV13V91L-AuopQudQZxImv9ealXknGpI27Am5obJf1enqLluYg2T41jjz41w/s400/mongo.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-weight:bold;&quot;&gt;Indexing&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Indexing in Mongo, just as in an RDBMS, is important for improving query performance. Indexes can be defined on a single field, a combination of fields, and even on fields in embedded documents.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;I&#39;m going to modify my DaoBase class with an EnsureIndex method:&lt;/div&gt;&lt;pre class=&quot;brush:c#&quot;&gt;public abstract class DaoBase&amp;lt;T&amp;gt; &lt;br /&gt;    where T : ICollectable&lt;br /&gt;{&lt;br /&gt;    public DaoBase()&lt;br /&gt;    {&lt;br /&gt;        ...&lt;br /&gt;        EnsureIndex(Mongo.GetCollection&amp;lt;T&amp;gt;());&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    ...&lt;br /&gt;    protected abstract void EnsureIndex(MongoCollection&amp;lt;T&amp;gt; collection);&lt;br /&gt;}&lt;/pre&gt;&lt;div&gt;And since I&#39;ll be querying my users frequently by email, I&#39;ll add a unique index in UserDao.&lt;/div&gt;&lt;pre class=&quot;brush:c#&quot;&gt;public class UserDao : DaoBase&amp;lt;User&amp;gt;&lt;br /&gt;{&lt;br /&gt;    ...&lt;br /&gt;    protected override void EnsureIndex(MongoCollection&amp;lt;User&amp;gt; collection)&lt;br /&gt;    {&lt;br /&gt;        collection.CreateIndex(u =&gt; u.Email, // the field to index&lt;br /&gt;            &quot;email&quot;, // index name&lt;br /&gt;            true, // unique&lt;br /&gt;            IndexOption.Ascending // this doesn&#39;t matter on unique indexes&lt;br /&gt;        );&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;div&gt;NoRM also provides support for indexing multiple fields using anonymous types, but I won&#39;t go into that here.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;We can run our tests again and confirm that the index exist using the command line.&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align:center;&quot;&gt;&lt;a href=&quot;http://picasaweb.google.com/lh/photo/6TwELpl_iSdgL-jDSWJrcAFA_tddwG1m21odRuwSuJM?feat=embedwebsite&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZ18Kf0oZbhFmhD7kDvv9eQmQAUaLYeRNnEUCCb8Yfvbp_hqnb9XC1tuXrlXcJyBDfYH8T3SsxZu8l-T7jukdgk5lWCOZR1L4IYlGbdGz3Kl71BBXthKm4R3LQDyyavEoGNfDrXYKo2wA/s400/mongo_indexes.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;Notice that there already exists an index on the Id column. Mongo creates this index on all collections by default and it cannot be removed.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;At this point I&#39;m entirely sure I want the EnsureIndex method to be part of my DAO, but I&#39;ll leave it for now.&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-weight:bold;&quot;&gt;Configuring Property Aliases&lt;/div&gt;&lt;br /&gt;&lt;div&gt;NoRM provides a useful feature called configuration maps. This allows you more fine grained control of how data is stored in Mongo. As we&#39;ve seen, we can setup and start using NoRM and Mongo together without even touching this feature. However, I&#39;ll be using aliasing in order to reduce my database size.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;To begin I&#39;ll need to create a new class which extends &lt;span style=&quot;font-family:&#39;courier new&#39;&quot;&gt;MongoConfigurationMap&lt;/span&gt;.&lt;/div&gt;&lt;pre class=&quot;brush:c#&quot;&gt;public class UserMap : MongoConfigurationMap&lt;br /&gt;{&lt;br /&gt;    public UserMap()&lt;br /&gt;    {&lt;br /&gt;        For&amp;lt;User&amp;gt;(config =&gt;&lt;br /&gt;            {&lt;br /&gt;                config.ForProperty(u =&gt; u.Email).UseAlias(&quot;un&quot;);&lt;br /&gt;                config.ForProperty(u =&gt; u.Password).UseAlias(&quot;pwd&quot;);&lt;br /&gt;                config.ForProperty(u =&gt; u.Stats).UseAlias(&quot;st&quot;);&lt;br /&gt;            }&lt;br /&gt;        );&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;div&gt;Than we need to execute this map before calling mongo. For this I created another class to centralize mapping and unmapping.&lt;/div&gt;&lt;pre class=&quot;brush:c#&quot;&gt;internal class Configurations&lt;br /&gt;{&lt;br /&gt;   internal static void Map()&lt;br /&gt;   {&lt;br /&gt;       MongoConfiguration.Initialize(config =&gt; config.AddMap&amp;lt;UserMap&amp;gt;());&lt;br /&gt;   }&lt;br /&gt;   internal static void UnMap()&lt;br /&gt;   {&lt;br /&gt;       MongoConfiguration.RemoveMapFor&amp;lt;User&amp;gt;();&lt;br /&gt;   }&lt;br /&gt;}&lt;/pre&gt;&lt;div&gt;And modified DaoBase once more.&lt;/div&gt;&lt;pre class=&quot;brush:c#&quot;&gt;public abstract class DaoBase&amp;lt;T&amp;gt; &lt;br /&gt;    where T : ICollectable&lt;br /&gt;{&lt;br /&gt;    public DaoBase()&lt;br /&gt;    {&lt;br /&gt;        Configurations.Map();&lt;br /&gt;        ...&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;div&gt;If we run our test again and check the console we can see that the field values are now stored with shortened property names.&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;text-align:center;&quot;&gt;&lt;a href=&quot;http://picasaweb.google.com/lh/photo/ZxgS86CudvuY6yCukJTG-QFA_tddwG1m21odRuwSuJM?feat=embedwebsite&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3r-Y2AjP8QJEm10FgOcShZZfcYX0sGr79hGOtTQ9IqwN_kPVYK5Bxgy2x2vIEvMRbTn47iP96viecAhH7bpp0SB7jX2xrRO4NjiSlTj0DSqXFuG9E7jQjHKqLnzgblODr2IBccj4IulE/s400/mongo_aliasing.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;I leave it to the reader to alias the fields in UserStat.&lt;/div&gt;</description><link>http://www.methodicmadness.com/2010/06/practical-mongodb-part-3-fine-tuning.html</link><author>noreply@blogger.com (JP)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjft_vOTW3u4g32kWvsg2ljNdjTZ2F6jlFSTaosmeh9lZqTvFaatuIfP993wywPqlLNaZqM5EiR4sVVZbjeV13V91L-AuopQudQZxImv9ealXknGpI27Am5obJf1enqLluYg2T41jjz41w/s72-c/mongo.png" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-3559138696684732251</guid><pubDate>Fri, 11 Jun 2010 01:13:00 +0000</pubDate><atom:updated>2012-01-12T10:58:05.792-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c#</category><category domain="http://www.blogger.com/atom/ns#">mongodb</category><category domain="http://www.blogger.com/atom/ns#">nosql</category><title>Practical MongoDB Part 2: NoRMalized Data Access</title><description>&lt;div&gt;
In &lt;a href=&quot;http://www.methodicmadness.com/2010/06/practical-mongodb-part-1-up-and-running.html&quot;&gt;Part 1&lt;/a&gt; of this series I demonstrated setting up MongoDB to run as a Windows service. In this segment, I&#39;ll show you how I setup my data access layers using &lt;a href=&quot;http://github.com/atheken/NoRM&quot;&gt;NoRM&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;font-size: larger;&quot;&gt;&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;b style=&quot;font-size: larger;&quot;&gt;The Glue&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
For starts I created two modules: an abstract class for my data access objects, and an interface for my POCO&#39;s.&lt;/div&gt;
&lt;pre class=&quot;brush:c-sharp;&quot;&gt;public abstract class DaoBase&amp;lt;T&amp;gt;
    where T : ICollectable
{
}

public interface ICollectable
{
    ObjectId Id { get; }
}&lt;/pre&gt;
&lt;div&gt;
(ObjectId is NoRM&#39;s wrapper type for the &lt;a href=&quot;http://www.mongodb.org/display/DOCS/Object+IDs&quot;&gt;Mongo generated id&lt;/a&gt;.)&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now we&#39;ll add the NoRM integration. You&#39;ll need to download the latest source from github and compile it, but I&#39;m sure you can figure that out.&lt;/div&gt;
&lt;pre class=&quot;brush:c#&quot;&gt;public abstract class DaoBase&amp;lt;T&amp;gt;
    where T : ICollectable
{
    public DaoBase()
    {
        var connectionString = ConfigurationManager.ConnectionStrings[&quot;default&quot;].ConnectionString;
        Mongo = Mongo.Create(connectionString);
    }

    private Mongo Mongo { get; set; }

    protected MongoCollection&amp;lt;T&amp;gt; Collection
    {
        get
        {
            return Mongo.GetCollection&amp;lt;T&amp;gt;();
        }
    }

    protected IQueryable&amp;lt;T&amp;gt; Query
    {
        get
        {
            return Collection.AsQueryable();
        }
    }
}&lt;/pre&gt;
&lt;div&gt;
(Connection strings are covered in detail &lt;a href=&quot;http://www.mongodb.org/display/DOCS/Connections&quot;&gt;here&lt;/a&gt;. On my dev box I use &lt;span style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;mongodb://localhost/databasename&lt;/span&gt;. Mongo will create the database on the first insert.)&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Finally, we don&#39;t want to leave the Mongo object just hanging around. The Mongo instance houses the connection so by disposing of it we can return it to the connection pool.&lt;/div&gt;
&lt;pre class=&quot;brush:c#&quot;&gt;public abstract class DaoBase&amp;lt;T&amp;gt; : IDisposable
    where T : ICollectable
{
    ...
    public void Dispose()
    {
        Mongo.Dispose();
    }
}&lt;/pre&gt;
&lt;div&gt;
So much for the theory. Let&#39;s try using it.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;font-size: larger;&quot;&gt;A Basic Domain Object&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
We don&#39;t need to do a thing in Mongo to start storing our objects. We can simply define some classes and start inserting them. Mongo will create the appropriate collections as needed.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here&#39;s a basic domain class I would like to store&lt;/div&gt;
&lt;pre class=&quot;brush:c#&quot;&gt;public class User : ICollectable
{
    public ObjectId Id { get; internal set; }
    public string Email { get; internal set; }
    public string Password { get; internal set; }
    ...
}&lt;/pre&gt;
&lt;div&gt;
Let&#39;s write a test for inserting and retrieving a User from Mongo.&lt;/div&gt;
&lt;pre class=&quot;brush:c#&quot;&gt;public class UserDaoFacts
{
    public UserDaoFacts()
    {
        // At the beginning of each test, drop the User collection
        // strict=false tells NoRM not to error if the collection doesn&#39;t exist
        using (var mongo = Mongo.Create(TestHelper.ConnectionString, &quot;strict=false&quot;))
            // NoRM uses the class name by default. I&#39;ll show you how to override this in Part 3
            mongo.Database.DropCollection(typeof(User).Name); 
    }

    [Fact]
    public void Can_Insert_And_Retrieve()
    {
        using (var dao = new UserDao())
        {
            User user = new User();
            user.Email = &quot;email&quot;;
            user.Password = &quot;password&quot;;
            dao.Insert(user);

            User found = dao.Get(user.Email);

            Assert.NotNull(user.Id);
            Assert.Equal(user.Email, found.Email);
        }
    }
}&lt;/pre&gt;
&lt;div&gt;
For which we create a concrete implementation of DaoBase.&lt;/div&gt;
&lt;pre class=&quot;brush:c#&quot;&gt;public class UserDao : DaoBase&amp;lt;User&amp;gt;
{
    internal void Insert(User user)
    {
        Collection.Insert(user);
    }

    public User Get(string email)
    {
        return Query.FirstOrDefault(u =&amp;gt; u.Email == email);
    }
}&lt;/pre&gt;
&lt;div&gt;
This is enough to make our test successfully pass.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;http://picasaweb.google.com/lh/photo/RUWBujwYMXS7MqgAfx94jQFA_tddwG1m21odRuwSuJM?feat=embedwebsite&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg529Xs64dzDIc-NJmD1mhCJEr9hrAuPkFcIfKJDL4R9oRaHj1zFrxviNbYtGQiGMdqjHchIjrgCkxFvS0bgaabBo_qsz73Q69od6aHccl1ay58vCzLfZ5kbdvxYmIc-qS8MvlU4t6-Ras/s400/mongo_2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I&#39;m going to move the Insert method to DaoBase and add some other common methods. Hopefully you can figure out how to write some tests for these methods.&lt;/div&gt;
&lt;pre class=&quot;brush:c#&quot;&gt;public abstract class DaoBase&amp;lt;T&amp;gt; : IDisposable
    where T : ICollectable
{
    ...
    public IQueryable&amp;lt;T&amp;gt; GetAll()
    {
        return Query;
    }

    public T Get(ObjectId id)
    {
        // Here&#39;s where ICollectable comes in handy!
        return Query.SingleOrDefault(t =&amp;gt; t.Id == id);
    }

    internal void Update(T obj)
    {
        // Mongo and NoRM offer partial updates, but this is sufficient for our immediate purposes
        Collection.Update(new { Id = obj.Id }, obj, false, false);
    }

    internal void Insert(T obj)
    {
        Collection.Insert(obj);
    }

    internal void Insert(IEnumerable&amp;lt;T&amp;gt; objs)
    {
        Collection.Insert(objs);
    }
    ...
}&lt;/pre&gt;
&lt;div&gt;
There you have it! A fully functional User Dao! In Part 3 I&#39;ll discuss embedded documents, indexing, and configuration options.&lt;/div&gt;</description><link>http://www.methodicmadness.com/2010/06/practical-mongodb-part-2-normalized.html</link><author>noreply@blogger.com (JP)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg529Xs64dzDIc-NJmD1mhCJEr9hrAuPkFcIfKJDL4R9oRaHj1zFrxviNbYtGQiGMdqjHchIjrgCkxFvS0bgaabBo_qsz73Q69od6aHccl1ay58vCzLfZ5kbdvxYmIc-qS8MvlU4t6-Ras/s72-c/mongo_2.png" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-8666170895307083582</guid><pubDate>Thu, 10 Jun 2010 23:03:00 +0000</pubDate><atom:updated>2012-01-12T11:00:03.298-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">database</category><category domain="http://www.blogger.com/atom/ns#">mongodb</category><category domain="http://www.blogger.com/atom/ns#">nosql</category><title>Practical MongoDB Part 1: Up and Running</title><description>Like many others, I&#39;ve been intrigued by the NoSQL movement and the various alternatives which have appeared in recent years. One of these options which is rapidly growing in popularity is &lt;a href=&quot;http://www.mongodb.org/&quot;&gt;MongoDB&lt;/a&gt;, a document oriented database written in C++ with scalability in mind. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This post is the first in a series documenting my attempts to implement MongoDB into a real world project.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;MongoDB has garnered a following in the ruby and php communities, but up until recently had little exposure to .Net folks. The earliest .Net driver, &lt;a href=&quot;http://github.com/samus/mongodb-csharp&quot;&gt;mongodb-csharp&lt;/a&gt;, was basically a wrapper on Mongo&#39;s built in capabilities. While useful, this design did little to provide a strongly typed approach to data access. More recently however, another open source effort led by Andrew Theken and Rob Conery created &lt;a href=&quot;http://github.com/atheken/NoRM&quot;&gt;NoRM&lt;/a&gt;: a strongly typed driver (which even has a sweet Linq provider). There are other C# drivers out there, but these are the ones I have experienced. Part 2 and onward of this series will use NoRM.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size:large;&quot;&gt;&lt;b&gt;Setting it up... For the Windows user&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hopefully you&#39;ve already downloaded the mongo binaries and played around with the command line interface. If not, I recommend doing so. Plenty of others have discussed this before so I won&#39;t cover it again. This is &lt;a href=&quot;http://mookid.dk/oncode/archives/1057&quot;&gt;one of the walkthroughs I used&lt;/a&gt; to get started.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Once you&#39;ve tried out the command line interface, you&#39;ll start wondering how to get this running as a service on your server. With earlier versions of Mongo it may have been necessary to create a batch file and install a service manually to call this batch file. However, a feature was added recently (version 1.2 I believe) which performs the service installation for you. Simply call the mongod executable with the &lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;--install&lt;/span&gt; switch to install a service which will keep your mongo always up and running.&lt;/div&gt;&lt;pre class=&quot;brush: bash&quot;&gt;c:\&gt;c:\mongo\mongod --install {arguments}&lt;/pre&gt;&lt;div&gt;(&lt;b&gt;Note:&lt;/b&gt; Version 1.4.3 has a bug which requires that the &lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;--install&lt;/span&gt; switch be run with the full path specified as shown above, however, I believe the nightlies include a patch for this.)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When using the &lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;--install&lt;/span&gt; switch, all other arguments become part of the execution call in the service. You can verify this by looking at the path in Windows service manager. For running on a server I like to include the &lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;--logpath &lt;/span&gt;and &lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;--quiet&lt;/span&gt; switches. The former so I can check for error outputs, and the latter to prevent my logs from growing to fast. Mongo 1.4 supports log rotation, but I haven&#39;t messed with it yet.&lt;/div&gt;&lt;pre class=&quot;brush: bash&quot;&gt;d:\&gt;d:\mongo\mongod --install --dbpath d:\data --logpath d:\data\mongodb.log --logappend --quiet&lt;/pre&gt;&lt;div style=&quot;text-align:center;&quot;&gt;&lt;a href=&quot;http://picasaweb.google.com/lh/photo/yA5xZDwgl_bxQ10X3PO2dQFA_tddwG1m21odRuwSuJM?feat=embedwebsite&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXZ-bQVTTdXe2bN3SH_ZIz3HkunQPssmWJYoBeFsKUkZqjZyKNzGAofQ4qgfxozqUhNHk9CroWhv5BCo_iSE6EyeLwJjbQNLTI_1-crf4Xnccn_TjdWxRKSUT8JygYfi25acDn0xbyQWQ/s400/mongo.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</description><link>http://www.methodicmadness.com/2010/06/practical-mongodb-part-1-up-and-running.html</link><author>noreply@blogger.com (JP)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXZ-bQVTTdXe2bN3SH_ZIz3HkunQPssmWJYoBeFsKUkZqjZyKNzGAofQ4qgfxozqUhNHk9CroWhv5BCo_iSE6EyeLwJjbQNLTI_1-crf4Xnccn_TjdWxRKSUT8JygYfi25acDn0xbyQWQ/s72-c/mongo.png" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-3191157393991677083</guid><pubDate>Thu, 15 Apr 2010 22:21:00 +0000</pubDate><atom:updated>2010-04-16T09:14:01.366-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.net</category><category domain="http://www.blogger.com/atom/ns#">mvc</category><title>MVC 2: JsonRequestBehavior DenyGet</title><description>We migrated one of our projects to MVC 2 today, and one of the first things I noticed is that all my ajaxified jsony sweetness had stopped working! A quick look at the XHR revealed the following server error.&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.&lt;/code&gt;&lt;/blockquote&gt;What the heck?&lt;br /&gt;&lt;br /&gt;A quick Google turned up a couple articles about MVC 2&#39;s new JsonRequestBehavior, and specifically the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.web.mvc.jsonrequestbehavior(v=VS.100).aspx&quot;&gt;MSDN article&lt;/a&gt; (the &lt;a href=&quot;http://haacked.com/archive/2009/06/25/json-hijacking.aspx&quot;&gt;link to Haack is dead, so here&#39;s a good one&lt;/a&gt;). Ok, good to know. I wasn&#39;t aware of that vulnerability, but in the mean time I need this project working. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I could modify the actions to call a Json overload which accepts the JsonRequestBehavior.&lt;/div&gt;&lt;pre class=&quot;brush: c-sharp&quot;&gt;  return Json(myjson, JsonRequestBehavior.AllowGet);&lt;/pre&gt;&lt;div&gt;But since I have somewhere between 50-80 Json actions in this app, that would be a lot of find-replace. Plus, when I finish modifying my client library to use POST requests, I would have to do it all over again. A one stop solution would be much preferable.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If your project already uses a base controller class, you can do one simple override:&lt;/div&gt;&lt;div&gt;&lt;pre class=&quot;brush: c-sharp&quot;&gt;protected override JsonResult Json(object data, string contentType,&lt;br /&gt;   Encoding contentEncoding, JsonRequestBehavior behavior)&lt;br /&gt;{&lt;br /&gt;   // TODO: change all my GET Json request into POST&lt;br /&gt;   return base.Json(data, contentType, contentEncoding,&lt;br /&gt;       JsonRequestBehavior.AllowGet);&lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;Keep in mind this should be a temporary crutch only!</description><link>http://www.methodicmadness.com/2010/04/mvc-2-jsonrequestbehavior-denyget.html</link><author>noreply@blogger.com (JP)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-2349955480802168996</guid><pubDate>Thu, 15 Apr 2010 14:22:00 +0000</pubDate><atom:updated>2010-04-15T11:53:32.540-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">hosting</category><category domain="http://www.blogger.com/atom/ns#">iis7</category><category domain="http://www.blogger.com/atom/ns#">ssl</category><title>IIS 7 (7.5): Hosting Multiple SSL Sites On One IP</title><description>Since I continually find myself Googling this information whenever I add a new site on our wildcard cert, I figured I&#39;d document it here.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;b&gt;Adding a New Binding:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Requirements:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;A wild card SSL certificate (of the form *.domain.com). I assume the cert is already installed on your server.&lt;/li&gt;&lt;li&gt;An IP you wish to use on multiple IIS sites.&lt;/li&gt;&lt;li&gt;Two or more IIS sites with no SSL binding (I&#39;ll touch on changing a binding at the end).&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;With these in place, adding an SSL cert is quite simple:&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;In an elevated command prompt navigate to &lt;blockquote&gt;&lt;code&gt;C:\Windows\System32\inetsrv&lt;/code&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Enter the following command (replace {SITENAME}, {IP}, and {HOSTHEADER} with the appropriate values). &lt;pre class=&quot;brush: bash&quot;&gt;appcmd set site /site.name:{SITENAME} /+bindings.[protocol=&#39;https&#39;,bindingInformation=&#39;{IP}:443:{HOSTHEADER}&#39;]&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Check the selected cert in IIS via the bindings window. You can change the cert here, but you cannot change the host header.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;That&#39;s it. &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Changing an Existing Binding:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Changing a binding is similar to the adding binding with a few alterations to the command&lt;/div&gt;&lt;div&gt;&lt;pre class=&quot;brush: bash&quot;&gt;appcmd set site /site.name:{SITENAME} /bindings.[protocol=&#39;https&#39;,bindingInformation=&#39;{IP}:443:{HOSTHEADER}&#39;].bindingInformation:{NEWIP}:443:{NEWHOSTHEADER}&lt;/pre&gt;&lt;/div&gt;</description><link>http://www.methodicmadness.com/2010/04/iis-7-75-hosting-multiple-ssl-on-one-ip.html</link><author>noreply@blogger.com (JP)</author><thr:total>8</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-1734657464354985712</guid><pubDate>Wed, 20 Jan 2010 16:17:00 +0000</pubDate><atom:updated>2010-04-15T11:27:28.431-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">nhibernate</category><category domain="http://www.blogger.com/atom/ns#">reflection</category><title>NHibernate: Is That Type a Proxy?</title><description>&lt;p&gt;One of our applications does some reflection to map customizable content to domain objects. Anyone familiar with NHibernate and lazy loading has probably encountered proxy classes before. My problem: given a Type, I want the domain type.&lt;/p&gt;&lt;p&gt;It&#39;s easy to find out that proxy types extend the domain type they represent, so if I know that my Type is a proxy I can call BaseType to get the domain type. But how do I know if my Type is a proxy?&lt;/p&gt;&lt;p&gt;I tried numerous approaches, but the simplest I found was to look for a specific interface. Turns out proxies implement an interface called INHibernateProxy.&lt;/p&gt;&lt;pre class=&quot;brush: c-sharp&quot;&gt;if (clazz.GetInterface(typeof(INHibernateProxy).FullName) != null)&lt;br /&gt;    clazz = clazz.BaseType;&lt;/pre&gt;&lt;p&gt;Now clazz represents the domain type as desired.&lt;/p&gt;&lt;p&gt;There are other solutions of course, such as detecting the namespace (proxies have none), and possibly checking IsAutoClass (which I couldn&#39;t confirm in any documentation). This approach seems the most reliable.&lt;/p&gt;</description><link>http://www.methodicmadness.com/2010/01/nhibernate-is-that-type-proxy.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-2084709511027062672</guid><pubDate>Fri, 08 Jan 2010 21:19:00 +0000</pubDate><atom:updated>2010-04-15T11:37:32.821-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">nhibernate</category><title>NHibernate: Mapping a Generic List of Enum</title><description>&lt;p&gt;I recently ran into a case where I wanted to have a collection of an enumeration on one of my domain classes.&lt;/p&gt;&lt;p&gt;E.g.&lt;/p&gt;&lt;pre class=&quot;brush: c-sharp&quot;&gt;public class MyDomainClass&lt;br /&gt;{&lt;br /&gt;   public List&amp;lt;MyRoleEnum&amp;gt; Roles { get; set; }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;But how is do we map something like this in an xml mapping? A quick google didn&#39;t turn up the answer, so I played around a bit and found the following works as desired.&lt;/p&gt;&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;bag name=&quot;Roles&quot; table=&quot;MyDomainClass2Role&quot;&amp;gt;    &lt;br /&gt;   &amp;lt;key column=&quot;MyDomainClassId&quot; /&amp;gt;    &lt;br /&gt;   &amp;lt;element column=&quot;Role&quot; type=&quot;MyRoleEnum&quot; /&amp;gt;&lt;br /&gt;&amp;lt;/bag&amp;gt;&lt;/pre&gt;&lt;p&gt;To confirm this usage I checked the documentation at &lt;a href=&quot;https://www.hibernate.org/hib_docs/nhibernate/html/collections.html&quot;&gt;hibernate.org&lt;/a&gt;. Turns out the &amp;lt;element /&amp;gt; tag was designed for value type bags anyway.&lt;/p&gt;</description><link>http://www.methodicmadness.com/2010/01/nhibernate-mapping-generic-list-of-enum.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-399637308477283629</guid><pubDate>Wed, 04 Nov 2009 15:12:00 +0000</pubDate><atom:updated>2010-01-20T11:34:52.134-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">activedirectory</category><category domain="http://www.blogger.com/atom/ns#">dns</category><category domain="http://www.blogger.com/atom/ns#">domaincontroller</category><category domain="http://www.blogger.com/atom/ns#">server2003</category><title>Demote 2003 Domain Controller: NETLOGON Timeout</title><description>&lt;div&gt;As you may know, I occasionally copy information here which I feel needs better exposure on the web.  This is just such a post.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;I recently tried to demote a server 2003 domain controller (using dcpromo), and hit the following error message:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;code&gt;The operation failed because:&lt;br /&gt;&lt;br /&gt;Failed to configure the service NETLOGON as requested&lt;br /&gt;&lt;br /&gt;&quot;The wait operation timed out&quot;&lt;/code&gt;&lt;/blockquote&gt;&lt;div&gt;This is a particularly useless message because the actual problem has nothing to do with netlogon. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I corrected this problem by modifying the TCP/IP settings to point DNS at the remaining domain controller (e.g. remove 127.0.0.1 or any other IP which points to the machine being demoted).&lt;/div&gt;</description><link>http://www.methodicmadness.com/2009/11/demote-2003-domain-controller-netlogon.html</link><author>noreply@blogger.com (JP)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-285477380414254415</guid><pubDate>Tue, 29 Sep 2009 16:11:00 +0000</pubDate><atom:updated>2010-01-20T11:32:52.579-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ie6</category><category domain="http://www.blogger.com/atom/ns#">virtualization</category><category domain="http://www.blogger.com/atom/ns#">windows7</category><title>Running IE6 in Windows 7 with Virtual PC</title><description>&lt;div style=&quot;text-align: left;&quot;&gt;With the advent of Windows 7 and improved application virtualization, legacy browser testing has been greatly simplified.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Thanks to the XP Mode vmc that Microsoft provides &lt;a href=&quot;http://www.microsoft.com/windows/virtual-pc/&quot;&gt;here&lt;/a&gt;, it is quite easy to setup an instance of IE6 to run almost seamlessly alongside your native Windows 7 apps.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFCqgtAeTI6JShMcZwFCSfF1Hf2wq8JE3_9SqUPexfle0RNSnSX1y2wUoa8n4LEuoCtaW1GgeYnlTDfYzn0-Xu6tqfmz1lGcPT7oqKoUiOjPCm7V0JaOWIDIN_p7eHsPW9pwy68mTQo-8/s400/ie6inwin7.PNG&quot; style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 219px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5386930574454320770&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;After installing Windows Virtual PC and the XP Mode vhd, perform the following steps:&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;ol&gt;&lt;li&gt;In Windows Explorer, navigate to &lt;b&gt;&quot;c:\documents and settings\all users\start menu&quot;&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;Right-click and select &lt;b&gt;New -&gt; Shortcut&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;Type in &lt;b&gt;http://www.google.com &lt;/b&gt;or whatever you would like your home page to be.&lt;/li&gt;&lt;li&gt;Give the shortcut a name (I called mine &lt;b&gt;&quot;IE6&quot;&lt;/b&gt;).&lt;/li&gt;&lt;li&gt;Finish the wizard, log off, and close the virtual PC.&lt;/li&gt;&lt;li&gt;In your Windows 7 start menu you will now find a folder at &lt;b&gt;All Programs -&gt; Windows Virtual PC -&gt; Windows XP Mode Applications&lt;/b&gt; which contains the shortcut you just created. Click this shortcut and &lt;i&gt;TADA&lt;/i&gt;! IE6 runs in a window of it&#39;s own.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;One limitation of this approach is that you can only have one instance of any XP Mode application running at one time. You may be able to open multiple IE6 instances by creating more than one shortcut in the xp start menu, but I didn&#39;t try it.&lt;/div&gt;&lt;/div&gt;</description><link>http://www.methodicmadness.com/2009/09/running-ie6-in-windows-7-with-virtual.html</link><author>noreply@blogger.com (JP)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFCqgtAeTI6JShMcZwFCSfF1Hf2wq8JE3_9SqUPexfle0RNSnSX1y2wUoa8n4LEuoCtaW1GgeYnlTDfYzn0-Xu6tqfmz1lGcPT7oqKoUiOjPCm7V0JaOWIDIN_p7eHsPW9pwy68mTQo-8/s72-c/ie6inwin7.PNG" height="72" width="72"/><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-2010210793597680603</guid><pubDate>Mon, 31 Aug 2009 00:47:00 +0000</pubDate><atom:updated>2010-01-20T11:32:52.580-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">audio</category><category domain="http://www.blogger.com/atom/ns#">windows7</category><title>No DVD Sound in Windows 7</title><description>I installed Windows 7 on an older (4 years) laptop this past weekend and encountered a rather irksome problem that has a very simple fix. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Symptoms:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt; Audio works fine, until you stick in a DVD and try to play it with WMP12: no sound.&lt;/li&gt;&lt;li&gt; WMP12 playing mp3&#39;s is fine, but stick in a DVD: no sound.&lt;/li&gt;&lt;li&gt; Load a DVD ISO on a virtual drive and try to play: no sound.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;Because of some trouble I had with the Realtek drivers for windows 7, and the Sony DVD drive, I was not certain at this point where precisely the problem lay.  Searching a bit for Realtek, DVD and Sony&#39;s DW-D56A didn&#39;t turn anything up, so I started looking more broadly.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Turns out &lt;a href=&quot;http://www.avforums.com/forums/windows-7/993294-windows-7-no-dvd-sound.html#post9525557&quot;&gt;a post on AVForums by Damernath&lt;/a&gt; pointed out a very simple solution that worked like a charm. I repeat below for your benefit:&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Go to: Control Panel -&gt; Sound &lt;/li&gt;&lt;li&gt;On the &quot;Playback&quot; tab select &quot;Speakers&quot; and click &quot;Properties&quot;&lt;/li&gt;&lt;li&gt;On the &quot;Advanced&quot; tab uncheck &quot;Allow applications to take exclusive control of this device&quot;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;That&#39;s it. Restart WMP and watch your DVD glory.&lt;/div&gt;&lt;/div&gt;</description><link>http://www.methodicmadness.com/2009/08/no-dvd-sound-in-windows-7.html</link><author>noreply@blogger.com (JP)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-1865701795087798930</guid><pubDate>Thu, 06 Aug 2009 15:01:00 +0000</pubDate><atom:updated>2010-04-15T11:38:17.283-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msdeploy</category><category domain="http://www.blogger.com/atom/ns#">server2008</category><title>MS Deploy RC1 Install ... Odd!</title><description>In upgrading from MS Deploy Beta1 to RC1, I found an undocumented oddity which could stump you for who knows how long.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you install the RC without first uninstalling the beta, the Web Deployment Agent Service refuses to start.  From the command line, &quot;net start msdepsvc&quot; returns &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;&lt;code&gt;The service did not report an error&lt;/code&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;And no error is logged in the Event Log either. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The fix? Simple, just go into Programs and Features, select the Web Deployment Tool Release Candidate 1 and choose &quot;Repair&quot;. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;All fixed.&lt;/div&gt;</description><link>http://www.methodicmadness.com/2009/08/ms-deploy-rc1-install-odd.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-1741526181919203030</guid><pubDate>Thu, 18 Jun 2009 15:20:00 +0000</pubDate><atom:updated>2010-01-20T11:33:25.749-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">sqlserver2008</category><title>Clearing Sql 2008 Management Studio Saved Passwords</title><description>In Management Studio 2005, the saved connections, usernames, and passwords could be cleared out by deleting the mru.dat file. However, in SSMS 2008 there is no equivalent data file. A similar effect can be achieved by deleting the SqlStudio.bin file. This will affect other settings, but for now it&#39;s the best solution.&lt;br /&gt;&lt;br /&gt;In Vista, this file is located at:&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;C:\Users\{username}\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin&lt;/code&gt;&lt;/blockquote&gt;And for XP:&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;C:\Documents and Settings\{username}\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin&lt;/code&gt;&lt;/blockquote&gt;Aaron Bertrand has blogged a bit more about this &lt;a href=&quot;http://sqlblog.com/blogs/aaron_bertrand/archive/2009/03/18/managing-the-mru-list-for-the-connect-to-server-dialog-in-ssms.aspx&quot;&gt;here&lt;/a&gt;.</description><link>http://www.methodicmadness.com/2009/06/clearing-sql-2008-management-studio.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-4468202298322792667</guid><pubDate>Thu, 07 May 2009 21:02:00 +0000</pubDate><atom:updated>2010-04-15T11:39:02.312-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">loopbackadapter</category><category domain="http://www.blogger.com/atom/ns#">networking</category><category domain="http://www.blogger.com/atom/ns#">server2008</category><title>Server 2008 Loopback Adapter Forwarding</title><description>&lt;blockquote&gt;&lt;/blockquote&gt;I don&#39;t know why this information is so hard to find, but I&#39;m copying it here to hopefully help a few more people find it.&lt;br /&gt;&lt;br /&gt;(from &lt;a href=&quot;http://www-01.ibm.com/support/docview.wss?rs=250&amp;amp;context=SSBQMN&amp;amp;dc=DB520&amp;amp;dc=DB560&amp;amp;uid=swg21304795&amp;amp;loc=en_US&amp;amp;cs=UTF-8&amp;amp;lang=en&amp;amp;rss=ct250websphere&quot;&gt;http://www-01.ibm.com/support/docview.wss?rs=250&amp;amp;context=SSBQMN&amp;amp;dc=DB520&amp;amp;dc=DB560&amp;amp;uid=swg21304795&amp;amp;loc=en_US&amp;amp;cs=UTF-8〈=en&amp;amp;rss=ct250websphere&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;In server 2008, loopback adapters are slightly different than in earlier windows operating systems.  In order to forward traffic coming from your physical connection through the ips associated with the loopback you have to enable forwarding on your default connection.&lt;br /&gt;&lt;pre class=&quot;brush: bash&quot;&gt;netsh interface ipv4 set interface &quot;local area connection&quot; forwarding=enabled&lt;/pre&gt;</description><link>http://www.methodicmadness.com/2009/05/server-2008-loopback-adapter-forwarding.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-2510778117799846455</guid><pubDate>Fri, 09 Jan 2009 01:11:00 +0000</pubDate><atom:updated>2012-12-06T12:43:54.739-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">nhibernate</category><title>NHibernate: What the heck is &quot;clazz_&quot;?</title><description>Being a reticent fellow, it isn&#39;t often that I blog twice in as many days, but I ran into an issue with NHibernate joined-subclasses and ISQLQuery twice in two different instances in the past two days.&lt;br /&gt;&lt;br /&gt;
After searching around a good deal for any information I could find about adding entities to SQL queries in NHibernate, I finally found something that pointed me in the right direction, and I thought I&#39;d give it a post to hopefully assist any other unfortunate Hibernate users out there who may encounter this problem.&lt;br /&gt;&lt;br /&gt;
&lt;h4&gt;The Error&lt;/h4&gt;&lt;br /&gt;
You can reproduce this error by creating a class inheritance like:
&lt;pre class=&quot;brush:xml&quot; name=&quot;code&quot;&gt;&amp;lt;class name=&quot;BaseEntity&quot; table=&quot;BaseEntity&quot;&amp;gt;
  ...

  &amp;lt;joined-subclass name=&quot;FirstChildEntity&quot; table=&quot;FirstChildeEntity&quot;&amp;gt;
    ...
  &amp;lt;/joined-subclass&amp;gt;

  &amp;lt;joined-subclass name=&quot;SecondChildEntity&quot; table=&quot;SecondChildeEntity&quot;&amp;gt;
    ...
  &amp;lt;/joined-subclass&amp;gt;
&amp;lt;/class&amp;gt;&lt;/pre&gt;Now when you run a SQL query like so:
&lt;pre class=&quot;brush:c-sharp&quot; name=&quot;code&quot;&gt;Session.CreateSQLQuery(@&quot;
select * 
from 
  BaseEntity be
  left join FirstBaseEntity fbe on be.Id = fbe.EntityId
  left join SecondBaseEntity sbe on be.Id = sbe.EntityId
&quot;).AddEntity(typeof(BaseEntity)).List&amp;lt;BaseEntity&amp;gt;();&lt;/pre&gt;We get the following error message.&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: solid 1px black; color: black; font-size: 8pt; padding: 10px;&quot;&gt;
&lt;h2 style=&quot;color: maroon; font-family: Verdana; font-size: 14pt; font-weight: normal;margin:0;&quot;&gt;&lt;i&gt;clazz_&lt;/i&gt;&lt;/h2&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, Geneva, SunSans-Regular, sans-serif;&quot;&gt;&lt;b&gt; Description: &lt;/b&gt;An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.&lt;br /&gt;&lt;br /&gt;&lt;b&gt; Exception Details: &lt;/b&gt;System.IndexOutOfRangeException: clazz_&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Stack Trace:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #ffffcc;&quot;&gt;
&lt;pre&gt;[IndexOutOfRangeException: clazz_]
  System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) +2307341
  System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +258
  NHibernate.Driver.NHybridDataReader.GetOrdinal(String name) +33
  NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name) +133
  NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name, ISessionImplementor session, Object owner) +13
  NHibernate.Loader.Loader.GetInstanceClass(IDataReader rs, Int32 i, ILoadable persister, Object id, ISessionImplementor session) +215
  NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i, ILoadable persister, EntityKey key, LockMode lockMode, EntityKey optionalObjectKey, Object optionalObject, IList hydratedObjects, ISessionImplementor session) +78
  NHibernate.Loader.Loader.GetRow(IDataReader rs, ILoadable[] persisters, EntityKey[] keys, Object optionalObject, EntityKey optionalObjectKey, LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session) +636
  NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[] keys, Boolean returnProxies) +285
  NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +756   NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +105
  NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +236&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h4&gt;The Research&lt;/h4&gt;&lt;br /&gt;
The error message is not very helpful. &amp;nbsp;All we can really tell from the stack trace is that it&#39;s trying to do a field name lookup, but what field is &quot;clazz_&quot;?&lt;br /&gt;&lt;br /&gt;
If you are like me, you immediately pull open Google and run a search for anything about Nhibernate/Hibernate, clazz_, and createsqlquery. &amp;nbsp;One of the few useful results is this &lt;a href=&quot;http://fisheye3.atlassian.com/browse/nhibernate/trunk/nhibernate/src/NHibernate/Persister/NormalizedEntityPersister.cs?r=760&quot; target=&quot;_blank&quot;&gt;anotated source code on FishEye&lt;/a&gt;, from which we can see that Hibernate uses the &quot;clazz_&quot; string as a column discriminator. &amp;nbsp;Great! &amp;nbsp;But for what purpose?&lt;br /&gt;&lt;br /&gt;
Examining the code a little further, and reading the comments, we can discover that &quot;clazz_&quot; is a column added to the generated sql to differentiate between polymorphic classes, i.e. subclasses. &amp;nbsp;This is and old version, but it seems we&#39;re on the right trail. &lt;br /&gt;&lt;br /&gt;
A quick search on the Hibernate.org forums (which, for some reason, aren&#39;t indexed by Google) reveals some 8-10 threads concerning this very issue. &amp;nbsp;Sadly, it&#39;s not the good folks on the Hibernate project who are the most helpful in this case. &amp;nbsp;Thanks, however, to a fellow by the name of credmond, we can &lt;a href=&quot;http://forum.hibernate.org/viewtopic.php?t=986714&amp;amp;highlight=addentity+subclass&quot; target=&quot;_blank&quot;&gt;glean a little more info&lt;/a&gt; about this &quot;clazz_&quot; column.&lt;br /&gt;&lt;br /&gt;
To get any further, we&#39;re going to have to get our hands dirty. &amp;nbsp;Let&#39;s run a standard HQL query and see what kind of SQL it generates.
&lt;pre class=&quot;brush:c-sharp&quot; name=&quot;code&quot;&gt;Session.CreateQuery(&quot;from BaseEntity&quot;).List();&lt;/pre&gt;The resulting SQL string looks something like this (with most of the fields removed for space):
&lt;pre class=&quot;brush:sql&quot; name=&quot;code&quot;&gt;select 
  entity0_.Id as Id27_, 
  [base entity fields],
  [first child entity fields],
  [second child entity fields],
  case 
    when entity0_1_.EntityId is not null then 1 
    when entity0_2_.EntityId is not null then 2 
    when entity0_.Id is not null then 0 
  end as clazz_ 
from 
  BaseEntity entity0_ 
  left outer join FirstChildEntity entity0_1_ on entity0_.Id=entity0_1_.EntityId 
  left outer join SecondChildEntity entity0_2_ on entity0_.Id=entity0_2_.EntityId&lt;/pre&gt;We can see here the case statement credmond spoke of. &amp;nbsp;My first question is: what happens if we change the order of the joined-subclasses in the mapping file?  &amp;nbsp;The resultant SQL looks much the same, except for one important aspect: the aliases in the from clause are reversed!
&lt;pre class=&quot;brush:sql&quot; name=&quot;code&quot;&gt;from
  BaseEntity entity0_ 
  left outer join SecondChildEntity entity0_1_ on entity0_.Id=entity0_1_.EntityId
  left outer join FirstChildEntity entity0_2_ on entity0_.Id=entity0_2_.EntityId&lt;/pre&gt;So it appears that the number associated with each subclass is dependent upon the order of the subclasses in the mapping file. &amp;nbsp;Thus we find our (ugly) workaround.&lt;br /&gt;&lt;br /&gt;
&lt;h4&gt;The Workaround&lt;/h4&gt;&lt;br /&gt;
We can get our code working (albeit, not very pretty) by adding the &quot;clazz_&quot; discriminator column manually to our SQL:
&lt;pre class=&quot;brush:c-sharp&quot; name=&quot;code&quot;&gt;Session.CreateSQLQuery(@&quot;
select *,
  case 
    when fbe.EntityId is not null then 1 
    when sbe.EntityId is not null then 2 
    else 0 
  end as clazz_
from 
  BaseEntity be
  left join FirstBaseEntity fbe on be.Id = fbe.EntityId
  left join SecondBaseEntity sbe on be.Id = sbe.EntityId
&quot;).AddEntity(typeof(BaseEntity)).List&amp;lt;BaseEntity&amp;gt;();&lt;/pre&gt;To make sure this doesn&#39;t break down the road, a comment should be added to the mapping file to convey the importance of maintaining the order of the joined-subclass descriptions.&lt;br /&gt;&lt;br /&gt;
While I don&#39;t like this solution, it&#39;s the simplest one I&#39;ve found until the Hibernate team fixes what I consider to be a bug in their implementation of joined-subclasses.</description><link>http://www.methodicmadness.com/2009/01/nhibernate-what-is-heck-clazz.html</link><author>noreply@blogger.com (JP)</author><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-6111510611306458178</guid><pubDate>Wed, 07 Jan 2009 18:39:00 +0000</pubDate><atom:updated>2010-01-20T11:32:27.134-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">iis7</category><title>HTTP Error 500.19: &quot;This configuration section cannot be used at this path.&quot;</title><description>Occasionally, when setting up a new Vista box with IIS 7 and ASP.NET, I&#39;ll encounter this error for one application or another.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAM6og-8ucLSX4gdsOa36Hh5XGfjN9QNS1Oq6LDXm3vCQggJoGrdh5wT7T4cDDrQHxdiNo0d4dOrsJJSTJGvnrfDW41pPdh2v9DDwhqmfwseAjkzvvFQjOa2SsMqhmEfo32S3sL-SIIOE/s320/errorpage.jpg&quot; style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 258px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5288624918219509058&quot; /&gt;&lt;br /&gt;Simply Googling the generic header &quot;500.19 Internal Server Error&quot; turns up too much unrelated information.  You have to look a little further down and see the little message about:&lt;br /&gt;&lt;span style=&quot;font-weight:bold&quot;&gt;&lt;pre&gt;&quot;This configuration section cannot be used at this path.  This happens when the section is locked at a parent level.&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;&lt;h4&gt;Application-in-Site&lt;/h4&gt;&lt;br /&gt;&lt;div&gt;Once you&#39;ve noticed this key piece of information, the steps to fixing it are simple and few:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Examine the source to figure out which section has an override lock on it.  In my case, this was &lt;span style=&quot;color:red;&quot;&gt;&lt;pre style=&quot;display:inline&quot;&gt;requestFiltering&lt;/pre&gt;&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;Locate your applicationHost.config file.  This is generally located at %SystemRoot%/system32/inetserv/config/applicationHost.config.&lt;/li&gt;&lt;li&gt;Within applicationHost.config, find the override section from step 1 and change it&#39;s overrideModeDefault to &quot;Allow&quot;.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;&lt;h4&gt;Application-in-Application&lt;/h4&gt;&lt;br /&gt;&lt;div&gt;If your application is in a directory beneath another IIS application, debugging this error can become a little more tricky since there are multiple places the section could have been locked.  You should still begin by checking the applicationHost.config as the most likely place, but failing there, look through any other web.configs above your application.&lt;br /&gt;&lt;/div&gt;</description><link>http://www.methodicmadness.com/2009/01/http-error-50019-this-configuration.html</link><author>noreply@blogger.com (JP)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAM6og-8ucLSX4gdsOa36Hh5XGfjN9QNS1Oq6LDXm3vCQggJoGrdh5wT7T4cDDrQHxdiNo0d4dOrsJJSTJGvnrfDW41pPdh2v9DDwhqmfwseAjkzvvFQjOa2SsMqhmEfo32S3sL-SIIOE/s72-c/errorpage.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-7067347483356910610</guid><pubDate>Sat, 27 Dec 2008 18:57:00 +0000</pubDate><atom:updated>2010-01-20T11:33:07.923-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">webdesign</category><title>Web 2.0 Design: How To</title><description>I ran across &lt;a href=&quot;http://www.webdesignfromscratch.com/web-2.0-design-style-guide.php&quot;&gt;this&lt;/a&gt; great article on web 2.0 design. &lt;br /&gt;&lt;br /&gt;This guy has a lot of good suggestions for the emerging web designer, and he backs up all his key points with examples and reasons.  I&#39;d recommend reading this through completely before beginning your next design.</description><link>http://www.methodicmadness.com/2008/12/web-20-design-how-to.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3002872373515344423.post-8473561748976746195</guid><pubDate>Mon, 08 Dec 2008 14:57:00 +0000</pubDate><atom:updated>2009-06-19T19:40:12.175-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">elmah</category><category domain="http://www.blogger.com/atom/ns#">email</category><title>Elmah Error Logging and Secure SMTP</title><description>&lt;div&gt;[EDIT: As of 1.0, Elmah natively supports ssl with the useSsl property making the below tweaks unneccessary.]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;For those of you who don&#39;t know elmah, &lt;a href=&quot;http://code.google.com/p/elmah/&quot;&gt;check it out&lt;/a&gt;.  Elmah is s a great, open source tool for logging all the errors on your web application.&lt;br /&gt;&lt;br /&gt;One enhancement I have made to the source is adding secure smtp capability.  This is important for those of us who like to use Google hosted email, which only rides on secure protocols.&lt;br /&gt;&lt;br /&gt;The changes are quite simple.  The only class you need to modify is the ErrorMailModule.  There are three steps to modifying the source:&lt;br /&gt;&lt;br /&gt;1. Add a property (I&#39;ve called mine SmtpSecure).&lt;br /&gt;2. Load the property from the config in OnInit.&lt;br /&gt;3. Enable ssl on the SmtpClient in the SendMail function.&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;border:solid 1px #9d9d9d;padding:15px;&quot;&gt;&lt;pre&gt;public class ErrorMailModule : HttpModuleBase, IExceptionFiltering&lt;br /&gt;{&lt;br /&gt;  ...&lt;br /&gt;  // Add the SmtpSecure property&lt;br /&gt;&lt;div style=&quot;color:blue&quot;&gt;&lt;br /&gt;  private bool _smtpSecure;&lt;br /&gt;  protected virtual bool SmtpSecure&lt;br /&gt;  {&lt;br /&gt;      get { return _smtpSecure; }&lt;br /&gt;  }&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;  protected override void OnInit(HttpApplication application)&lt;br /&gt;  {&lt;br /&gt;      ...&lt;br /&gt;      // initialize the property&lt;br /&gt;      // this should be done in two steps for error trapping reasons&lt;br /&gt;&lt;div style=&quot;color:blue&quot;&gt;&lt;br /&gt;      bool smtpSecure = Convert.ToBoolean(GetSetting(config, &quot;smtpSecure&quot;, bool.FalseString));&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;      // ... after the error handlers are attached&lt;br /&gt;&lt;div style=&quot;color:blue&quot;&gt;&lt;br /&gt;      _smtpSecure = smtpSecure;&lt;/div&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  // Enable ssl on the smtp client in SendMail&lt;br /&gt;  protected virtual void SendMail(MailMessage mail)&lt;br /&gt;  {&lt;br /&gt;      ...&lt;br /&gt;      // ... after client is instantiated&lt;br /&gt;&lt;div style=&quot;color:blue&quot;&gt;&lt;br /&gt;      if (SmtpSecure)&lt;br /&gt;          client.EnableSsl = true;&lt;/div&gt;&lt;br /&gt;      ...&lt;br /&gt;  }&lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;That&#39;s it!  The last thing to do is add the attribute in your web.config:&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;border:solid 1px #9d9d9d;padding:15px;&quot;&gt;&lt;pre&gt;&amp;lt;errorMail&lt;br /&gt;          from=&quot;errors@email.com&quot;&lt;br /&gt;          to=&quot;admin@email.com&quot;&lt;br /&gt;          subject=&quot;Unhandled Exception&quot;&lt;br /&gt;          async=&quot;true&quot;&lt;br /&gt;          smtpPort=&quot;587&quot;&lt;br /&gt;          smtpServer=&quot;smtp.gmail.com&quot;&lt;br /&gt;          userName=&quot;errors@email.com&quot;&lt;br /&gt;          password=&quot;password&quot;&lt;br /&gt;          &lt;span style=&quot;color:blue;&quot;&gt;smtpSecure=&quot;true&quot; /&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;</description><link>http://www.methodicmadness.com/2008/12/elmah-error-logging-and-secure-smtp.html</link><author>noreply@blogger.com (JP)</author><thr:total>0</thr:total></item></channel></rss>