<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Janne Mattila's blog : tips and tricks</title><link>http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx</link><description>Tags: tips and tricks</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Internet Explorer 8 and InPrivate Filtering</title><link>http://blogs.msdn.com/jannemattila/archive/2009/11/22/internet-explorer-8-and-inprivate-filtering.aspx</link><pubDate>Sun, 22 Nov 2009 06:59:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9926891</guid><dc:creator>jannemattila</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/9926891.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=9926891</wfw:commentRss><description>&lt;p&gt;I just noticed pretty cool feature which I have previously managed to miss. And that is &lt;em&gt;InPrivate Filtering&lt;/em&gt; in IE8. It’s basically mechanism that allows you to filter content from the web pages. Previously I haven’t thought this as “&lt;em&gt;Adblock functionality&lt;/em&gt;” but I did a test and noticed huge difference on web page rendering performance after adding some filtering.&lt;/p&gt;  &lt;p&gt;So if you like to also remove some noise (a.k.a. ads :-) from web pages just follow these steps:&lt;/p&gt;  &lt;p&gt;Open &lt;em&gt;InPrivate Filtering Settings&lt;/em&gt; under &lt;em&gt;Safety&lt;/em&gt; menu:    &lt;br /&gt;    &lt;br /&gt; &lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="InPrivate Filtering menu" border="0" alt="InPrivate Filtering menu" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/InternetExplorer8andInPrivateFiltering_D757/InPrivateFiltering1_6.png" width="436" height="231" /&gt;&amp;#160; &lt;br /&gt;I used “&lt;em&gt;Choose content to block or allow”&lt;/em&gt; and then I selected all entries and clicked the &lt;em&gt;Block&lt;/em&gt; button (this list was already populated by IE):     &lt;br /&gt;    &lt;br /&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="InPrivate Filtering settings" border="0" alt="InPrivate Filtering settings" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/InternetExplorer8andInPrivateFiltering_D757/InPrivateFiltering2_3.png" width="551" height="519" /&gt;&amp;#160; &lt;br /&gt;Since I wanted to add more filtering using regular expressions I clicked “&lt;em&gt;Advanced settings”&lt;/em&gt; from the previous dialogs. It then shows you this list:     &lt;br /&gt;    &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/InternetExplorer8andInPrivateFiltering_D757/InPrivateFiltering3_2.png" target="_blank"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="InPrivate Filtering Advanced settings" border="0" alt="InPrivate Filtering Advanced settings" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/InternetExplorer8andInPrivateFiltering_D757/InPrivateFiltering3_thumb.png" width="640" height="405" /&gt;&lt;/a&gt;     &lt;br /&gt;In this dialog you can “&lt;em&gt;Import”&lt;/em&gt; or “&lt;em&gt;Export”&lt;/em&gt; rules. I just exported rules to XML file and opened it in Visual Studio:&lt;/p&gt;  &lt;p&gt;   &lt;table cellspacing="10"&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td valign="top" align="right"&gt;           &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;&lt;font color="#0000ff"&gt;&amp;lt;?&lt;/font&gt;&lt;font color="#a31515"&gt;xml&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;version&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;1.0&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;encoding&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;UTF-8&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;?&amp;gt;
&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;rss&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;version&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;2.0&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;xmlns:wf&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;http://www.microsoft.com/schemas/webfilter/2008&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;&amp;gt;
 &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;channel&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;title&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;IE Blocked URLs&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;title&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;description&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;Export of InPrivate Filtering&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;description&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;item&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
   &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;description&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;example/*/examplescript.js&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;description&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
   &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;wf:blockRegex&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&amp;lt;![CDATA[&lt;/font&gt;&lt;font color="#808080"&gt;example/.*examplescript\.js.*&lt;/font&gt;&lt;font color="#0000ff"&gt;]]&amp;gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;wf:blockRegex&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
  &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;item&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
  &amp;lt;!--&lt;/font&gt;&lt;font color="#008000"&gt; 
   Repeat &amp;quot;item&amp;quot; per regular expression 
   &lt;/font&gt;&lt;font color="#0000ff"&gt;--&amp;gt;
 &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;channel&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;rss&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
After that I added few &lt;em&gt;item&lt;/em&gt; elements with most commonly used ad servers and saved the file. Then I just imported the XML and started enjoying much faster browsing experience! And I was also glad that I got rid of those flashy things on the web pages...&lt;/p&gt;

&lt;p&gt;Now you might thing that this only works in &lt;em&gt;InPrivate mode&lt;/em&gt; but that’s not the case. You can turn it on from the menu (see first screenshot) or just toggle it with Control+Shift+F even in normal browsing mode.&lt;/p&gt;

&lt;p&gt;Hmm... I might even do some testing to get some performance numbers out from my system. 
  &lt;br /&gt;

  &lt;br /&gt;Anyways... Happy hacking!

  &lt;br /&gt;

  &lt;br /&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9926891" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/IE8/default.aspx">IE8</category></item><item><title>Live Mesh + Visual SourceSafe = Code everywhere!</title><link>http://blogs.msdn.com/jannemattila/archive/2009/11/06/live-mesh-visual-sourcesafe-code-everywhere.aspx</link><pubDate>Fri, 06 Nov 2009 12:32:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9918543</guid><dc:creator>jannemattila</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/9918543.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=9918543</wfw:commentRss><description>&lt;p&gt;For long time I have wanted have my code _&lt;em&gt;everywhere&lt;/em&gt;_. Just because I have 3 different computers that I use to write my own stuff. Obviously it would be nice to have version control system (such as Team Foundation Server) but for my own use it would be quite heavy solution. And many times when I have had inspiration to start development of my old project I haven’t had network connectivity at that moment &lt;strong&gt;:-(&lt;/strong&gt; So I thought that I try untraditional solution: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Use Visual SourceSafe for source control &lt;/li&gt;    &lt;li&gt;Synchronize VSS database across all my computers with &lt;a href="http://www.mesh.com/" target="_blank"&gt;Live Mesh&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Use local VSS database and “get latest” from that in each computer&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I know that this sounds &lt;strong&gt;*weird*&lt;/strong&gt; but it turns out to be good and working solution! Now I can take my source from local VSS database whenever I need and it’s always up to date (since Live Mesh is constantly running on the background and it does all the synchronization stuff). &lt;/p&gt;  &lt;p&gt;Future will show if I manage to destroy my VSS database using this this approach &lt;strong&gt;:-)&lt;/strong&gt;     &lt;br /&gt;    &lt;br /&gt;Anyways... Happy hacking!     &lt;br /&gt;    &lt;br /&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918543" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Programming/default.aspx">Programming</category></item><item><title>Visual Studio 2008: Track Active Item in Solution Explorer</title><link>http://blogs.msdn.com/jannemattila/archive/2009/02/21/visual-studio-2008-track-active-item-in-solution-explorer.aspx</link><pubDate>Sat, 21 Feb 2009 21:58:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9437915</guid><dc:creator>jannemattila</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/9437915.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=9437915</wfw:commentRss><description>&lt;p&gt;If you’re working on solution that has many projects and many project items and &lt;u&gt;you tend to get lost between your files&lt;/u&gt;... You might want to go to &lt;em&gt;Tools –&amp;gt; Options –&amp;gt; Projects and Solutions&lt;/em&gt; and set &lt;em&gt;Track Active Item in Solution Explorer&lt;/em&gt; on. For me it was a big relief that I found it. I’m working on project that has quite many projects under the solution and I have found myself constantly “searching” for files that are at the same location as the currently open file. And this is the painkiller for that pain:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Visual Studio 2008 - Track Active Item in Solution Explorer" border="0" alt="Visual Studio 2008 - Track Active Item in Solution Explorer" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/VisualStudio2008TrackActiveIteminSolutio_123FB/image_6.png" width="510" height="251" /&gt;     &lt;br /&gt;    &lt;br /&gt;I’m not sure but if I have to guess... this was on by default on previous version of VS but not anymore on 2008. Because I know that I have enjoyed this feature in the past &lt;strong&gt;:-)&lt;/strong&gt; But I might be wrong and I have manually set that on in the past too.     &lt;br /&gt;    &lt;br /&gt;Anyways... Happy hacking!     &lt;br /&gt;    &lt;br /&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9437915" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Attaching debugger to w3wp.exe using nice and easy keyboard shortcut</title><link>http://blogs.msdn.com/jannemattila/archive/2008/10/30/attaching-debugger-to-w3wp-exe-using-nice-and-easy-keyboard-shortcut.aspx</link><pubDate>Thu, 30 Oct 2008 22:56:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9025158</guid><dc:creator>jannemattila</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/9025158.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=9025158</wfw:commentRss><description>&lt;p&gt;How many times have you done some web development and used following method to attach your Visual Studio Debugger to &lt;em&gt;w3wp.exe &lt;/em&gt;(a.k.a. &lt;em&gt;Debug &amp;gt; Attach to Process&lt;/em&gt; –method):    &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/image_7.png"&gt;&lt;img title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/image_thumb_2.png" width="248" height="164" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;    &lt;br /&gt;And then you scroll the long list and find your &lt;em&gt;w3wp.exe&lt;/em&gt; and press attach:    &lt;br /&gt;&lt;a target="_blank" href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/VSDebugger_2.png"&gt;&lt;img title="VSDebugger" border="0" alt="VSDebugger" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/VSDebugger_thumb.png" width="550" height="381" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I’ll bet that you have done that a lot &lt;strong&gt;:-)&lt;/strong&gt; At least I have.    &lt;br /&gt;    &lt;br /&gt;Let’s create macro that does that very same thing but so that you don’t have to take your fingers of the keyboard.     &lt;br /&gt;First open up &lt;em&gt;Macro Explorer&lt;/em&gt; (using &lt;em&gt;View &amp;gt;&lt;/em&gt; &lt;em&gt;Other windows&lt;/em&gt; &amp;gt; &lt;em&gt;Macro Explorer&lt;/em&gt; or just hit &lt;em&gt;Alt-F8&lt;/em&gt;). Then open up example &lt;em&gt;AttachToCalc &lt;/em&gt;macro under &lt;em&gt;Samples &lt;/em&gt;&amp;gt; &lt;em&gt;VSDebugger&lt;/em&gt;:    &lt;br /&gt;&lt;img title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/image_3.png" width="198" height="215" /&gt;&amp;#160; &lt;br /&gt;    &lt;br /&gt;Right click and select edit:    &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/image_9.png"&gt;&lt;img title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/image_thumb_3.png" width="210" height="142" /&gt;&lt;/a&gt;     &lt;br /&gt;    &lt;br /&gt;Copy contents of that and create new macro under &lt;em&gt;My Macros&lt;/em&gt;:    &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/image_11.png"&gt;&lt;img title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/image_thumb_4.png" width="258" height="108" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;    &lt;br /&gt;And give it a name &lt;em&gt;MyVSDebugger&lt;/em&gt;. Then paste the source code to it. Then modify the process name from &lt;em&gt;calc.exe&lt;/em&gt; to &lt;em&gt;w3wp.exe&lt;/em&gt; and remove the &lt;em&gt;Exit For&lt;/em&gt;. You should have something like this left:&lt;/p&gt;  &lt;p&gt;   &lt;table cellspacing="10"&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td valign="top" align="right"&gt;           &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;&lt;font color="#0000ff"&gt;Imports&lt;/font&gt; System
&lt;font color="#0000ff"&gt;Imports&lt;/font&gt; EnvDTE
&lt;font color="#0000ff"&gt;Imports&lt;/font&gt; EnvDTE80
&lt;font color="#0000ff"&gt;Imports&lt;/font&gt; EnvDTE90
&lt;font color="#0000ff"&gt;Imports&lt;/font&gt; System.Diagnostics

&lt;font color="#0000ff"&gt;Public&lt;/font&gt; &lt;font color="#0000ff"&gt;Module&lt;/font&gt; MyVSDebugger

  &lt;font color="#008000"&gt;' This subroutine attaches to w3wp.exe:
&lt;/font&gt;  &lt;font color="#0000ff"&gt;Sub&lt;/font&gt; AttachToW3WP()
    &lt;font color="#0000ff"&gt;Dim&lt;/font&gt; attached &lt;font color="#0000ff"&gt;As&lt;/font&gt; &lt;font color="#0000ff"&gt;Boolean&lt;/font&gt; = &lt;font color="#0000ff"&gt;False
&lt;/font&gt;    &lt;font color="#0000ff"&gt;Dim&lt;/font&gt; proc &lt;font color="#0000ff"&gt;As&lt;/font&gt; EnvDTE.Process

    &lt;font color="#0000ff"&gt;For&lt;/font&gt; &lt;font color="#0000ff"&gt;Each&lt;/font&gt; proc &lt;font color="#0000ff"&gt;In&lt;/font&gt; DTE.Debugger.LocalProcesses
      &lt;font color="#0000ff"&gt;If&lt;/font&gt; (Right(proc.Name, 8) = &lt;font color="#a31515"&gt;&amp;quot;w3wp.exe&amp;quot;&lt;/font&gt;) &lt;font color="#0000ff"&gt;Then
&lt;/font&gt;        proc.Attach()
        attached = &lt;font color="#0000ff"&gt;True
&lt;/font&gt;      &lt;font color="#0000ff"&gt;End&lt;/font&gt; &lt;font color="#0000ff"&gt;If
&lt;/font&gt;    &lt;font color="#0000ff"&gt;Next

&lt;/font&gt;    &lt;font color="#0000ff"&gt;If&lt;/font&gt; attached = &lt;font color="#0000ff"&gt;False&lt;/font&gt; &lt;font color="#0000ff"&gt;Then
&lt;/font&gt;      MsgBox(&lt;font color="#a31515"&gt;&amp;quot;Couldn't find w3wp.exe&amp;quot;&lt;/font&gt;)
    &lt;font color="#0000ff"&gt;End&lt;/font&gt; &lt;font color="#0000ff"&gt;If

&lt;/font&gt;  &lt;font color="#0000ff"&gt;End&lt;/font&gt; &lt;font color="#0000ff"&gt;Sub

End&lt;/font&gt; &lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
Now you should have this kind of view at the &lt;em&gt;Macro Explorer&lt;/em&gt;:

  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/image_5.png"&gt;&lt;img title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/image_thumb_1.png" width="176" height="123" /&gt;&lt;/a&gt;

  &lt;br /&gt;

  &lt;br /&gt;Now let’s add keyboard shortcut for our macro from &lt;em&gt;Tools&lt;/em&gt; &amp;gt; &lt;em&gt;Options&lt;/em&gt; and &lt;em&gt;Environment &lt;/em&gt;&amp;gt; &lt;em&gt;Keyboard&lt;/em&gt;:

  &lt;br /&gt;&lt;a target="_blank" href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/image_13.png"&gt;&lt;img title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/eb0f5b1dcb22_12A25/image_thumb_5.png" width="646" height="377" /&gt;&lt;/a&gt; 

  &lt;br /&gt;Just find your new macro and set focus to &lt;em&gt;Press shortcut keys&lt;/em&gt; field and press your favorite keyboard shortcut and press &lt;em&gt;Assign&lt;/em&gt; and then press &lt;em&gt;OK&lt;/em&gt;. &lt;strong&gt;NOTE:&lt;/strong&gt; You might have another command already using that combination but you can override it if you like.&lt;/p&gt;

&lt;p&gt;Now we’re ready to use that. If you want to build your solution you can Ctrl-Shift-B and if you want to attach to &lt;em&gt;w3wp.exe &lt;/em&gt;you’ll just press &lt;em&gt;Ctrl-Shift-V. &lt;/em&gt;This is extremely handy if you have &lt;em&gt;Post-Build event&lt;/em&gt; nicely set.

  &lt;br /&gt;

  &lt;br /&gt;Anyways... Happy hacking!

  &lt;br /&gt;

  &lt;br /&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9025158" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Web Services and namespaces (or WCF?)</title><link>http://blogs.msdn.com/jannemattila/archive/2008/10/15/web-services-and-namespaces-or-wcf.aspx</link><pubDate>Wed, 15 Oct 2008 10:27:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9000423</guid><dc:creator>jannemattila</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/9000423.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=9000423</wfw:commentRss><description>&lt;p&gt;You might have encountered following situation:    &lt;br /&gt;1. You have created class library “MyLibrary” and it contains following class:     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;   &lt;table cellspacing="10"&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td valign="top" align="right"&gt;           &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;&lt;font color="#0000ff"&gt;namespace&lt;/font&gt; MyLibrary
{
  &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;class&lt;/font&gt; &lt;font color="#2b91af"&gt;Employee
&lt;/font&gt;  {
    &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;string&lt;/font&gt; FirstName;
    &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;string&lt;/font&gt; LastName;
  }
}&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/p&gt;

&lt;p&gt;2. You have created Web Service “MyWeb” using following VS template: 
  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/WhyWCFsinceIlikeWebServices_78D2/Web%20Service%20project_2.png"&gt;&lt;img title="Web Service project" border="0" alt="Web Service project" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/WhyWCFsinceIlikeWebServices_78D2/Web%20Service%20project_thumb.png" width="128" height="20" /&gt;&lt;/a&gt; 

  &lt;br /&gt;&amp;#160; - It references “MyLibrary” 

  &lt;br /&gt;&amp;#160; - It contains following method: &lt;/p&gt;

&lt;p&gt;
  &lt;table cellspacing="10"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" align="right"&gt;
          &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;class&lt;/font&gt; &lt;font color="#2b91af"&gt;MyWeb&lt;/font&gt; : System.Web.Services.&lt;font color="#2b91af"&gt;WebService
&lt;/font&gt;{
  [&lt;font color="#2b91af"&gt;WebMethod&lt;/font&gt;]
  &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;void&lt;/font&gt; AddNewEmployee(MyLibrary.&lt;font color="#2b91af"&gt;Employee&lt;/font&gt; employee)
  {
    &lt;font color="#008000"&gt;// TODO: implement
&lt;/font&gt;  }
}&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/p&gt;

&lt;p&gt;3. Finally you create Windows Forms application “My Win App”: 
  &lt;br /&gt;&amp;#160; - You “Add Web Reference” to “MyWeb” and you name it “WebServices” 

  &lt;br /&gt;&amp;#160; - You write following code to use that web service: &lt;/p&gt;

&lt;p&gt;
  &lt;table cellspacing="10"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" align="right"&gt;
          &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;WebServices.&lt;font color="#2b91af"&gt;Employee&lt;/font&gt; employee = &lt;font color="#0000ff"&gt;new&lt;/font&gt; WebServices.&lt;font color="#2b91af"&gt;Employee&lt;/font&gt;();
employee.FirstName = &lt;font color="#a31515"&gt;&amp;quot;John&amp;quot;&lt;/font&gt;;
employee.LastName = &lt;font color="#a31515"&gt;&amp;quot;Doe&amp;quot;&lt;/font&gt;;
WebServices.&lt;font color="#2b91af"&gt;MyWeb&lt;/font&gt; myWeb = &lt;font color="#0000ff"&gt;new&lt;/font&gt; WebServices.&lt;font color="#2b91af"&gt;MyWeb&lt;/font&gt;();
myWeb.AddNewEmployee(employee);&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/p&gt;

&lt;p&gt;4. You run your application and all is fine. 
  &lt;br /&gt;5. Later you notice that you need to add reference to your “MyLibrary” into your “My Win App” 

  &lt;br /&gt;(There could be many reasons for this. For example you want to use same business logic that web service uses etc.) 

  &lt;br /&gt;6. You add following code to you “My Win App”: &lt;/p&gt;

&lt;p&gt;
  &lt;table cellspacing="10"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" align="right"&gt;
          &lt;pre&gt;&lt;font color="gray"&gt;1
2
3&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;MyLibrary.&lt;font color="#2b91af"&gt;Employee&lt;/font&gt; employee2 = &lt;font color="#0000ff"&gt;new&lt;/font&gt; MyLibrary.&lt;font color="#2b91af"&gt;Employee&lt;/font&gt;();
MyLibrary.&lt;font color="#2b91af"&gt;EmployeeManager&lt;/font&gt; employeeManager = &lt;font color="#0000ff"&gt;new&lt;/font&gt; MyLibrary.&lt;font color="#2b91af"&gt;EmployeeManager&lt;/font&gt;();
employeeManager.AddNewEmployee(employee2);&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/p&gt;

&lt;p&gt;7. Code works fine but then you notice that you actually have the same class from two different namespaces. What if you try to mix and match them (and sometimes you just have to do that)? Let’s see what happens:&lt;/p&gt;

&lt;p&gt;
  &lt;table cellspacing="10"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" align="right"&gt;
          &lt;pre&gt;&lt;font color="gray"&gt;1
2
3&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;WebServices.&lt;font color="#2b91af"&gt;Employee&lt;/font&gt; employee = &lt;font color="#0000ff"&gt;new&lt;/font&gt; WebServices.&lt;font color="#2b91af"&gt;Employee&lt;/font&gt;();
MyLibrary.&lt;font color="#2b91af"&gt;EmployeeManager&lt;/font&gt; employeeManager = &lt;font color="#0000ff"&gt;new&lt;/font&gt; MyLibrary.&lt;font color="#2b91af"&gt;EmployeeManager&lt;/font&gt;();
employeeManager.AddNewEmployee(employee);&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/p&gt;

&lt;p&gt;8. When you try to compile your application and you’ll receive following error: 
  &lt;br /&gt;&lt;em&gt;&lt;img title="VS compile error" border="0" alt="VS compile error" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/WhyWCFsinceIlikeWebServices_78D2/VS%20compile%20error_3.png" width="703" height="62" /&gt;&amp;#160; Error&amp;#160;&amp;#160;&amp;#160; 11&amp;#160;&amp;#160;&amp;#160; The best overloaded method match for 'MyLibrary.EmployeeManager.AddNewEmployee(MyLibrary.Employee)' has some invalid arguments&amp;#160;&amp;#160;&amp;#160; C:\&amp;lt;path&amp;gt;\MyWinApp\MainForm.cs&amp;#160;&amp;#160;&amp;#160; 41&amp;#160;&amp;#160;&amp;#160; 1&amp;#160;&amp;#160;&amp;#160; MyWinApp 

    &lt;br /&gt;Error&amp;#160;&amp;#160;&amp;#160; 12&amp;#160;&amp;#160;&amp;#160; Argument '1': cannot convert from 'MyWinApp.WebServices.Employee' to 'MyLibrary.Employee'&amp;#160;&amp;#160;&amp;#160; C:\&amp;lt;path&amp;gt;\MyWinApp\MainForm.cs&amp;#160;&amp;#160;&amp;#160; 41&amp;#160;&amp;#160;&amp;#160; 32&amp;#160;&amp;#160;&amp;#160; MyWinApp 

    &lt;br /&gt;&lt;/em&gt;

  &lt;br /&gt;9. You open up the generated proxy code: 

  &lt;br /&gt;&lt;img title="Reference" border="0" alt="Reference" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/WhyWCFsinceIlikeWebServices_78D2/Reference_3.png" width="172" height="97" /&gt; 

  &lt;br /&gt;

  &lt;br /&gt;10. You locate the code where &lt;em&gt;Employee&lt;/em&gt; is defined and comment that part. And then you compile again with following results: 

  &lt;br /&gt;&lt;em&gt;Error&amp;#160;&amp;#160;&amp;#160; 11&amp;#160;&amp;#160;&amp;#160; The type or namespace name 'Employee' could not be found (are you missing a using directive or an assembly reference?)&amp;#160;&amp;#160;&amp;#160; C:\&amp;lt;path&amp;gt;\MyWinApp\Web References\WebServices\Reference.cs&amp;#160;&amp;#160;&amp;#160; 82&amp;#160;&amp;#160;&amp;#160; 36&amp;#160;&amp;#160;&amp;#160; MyWinApp 
    &lt;br /&gt;&lt;/em&gt;

  &lt;br /&gt;11. You fix that by resolving the missing type: 

  &lt;br /&gt;&lt;img title="VS Resolve" border="0" alt="VS Resolve" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/WhyWCFsinceIlikeWebServices_78D2/VS%20Resolve_3.png" width="518" height="66" /&gt; &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;12. You compile and you’re happy right (obviously you need to modify also all &lt;em&gt;WebServices.Employee&lt;/em&gt; types to &lt;em&gt;MyLibrary.Employee&lt;/em&gt; types)?&lt;/p&gt;

&lt;p&gt;Well you might be happy since now your code works... &lt;strong&gt;BUT&lt;/strong&gt; you have manually edited generated file which will be re-generated every time you do “Update Web Reference” from Visual Studio and you’ll lose you modifications. And that’s not nice.&lt;/p&gt;

&lt;p&gt;If this would be question for me I would give you following answer (you might find different opinions on this one): Go to the WCF route instead &lt;strong&gt;:-) &lt;/strong&gt;If Windows Communication Foundation (WCF) is something new to you I think you should check these out and find more information on the web: &lt;a target="_blank" href="http://en.wikipedia.org/wiki/Windows_Communication_Foundation"&gt;Overview of WCF from Wikipedia&lt;/a&gt; and &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/netframework/aa663324.aspx"&gt;Windows Communication Foundation home on MSDN&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;I’m going to run through this same example with WCF way and then we can (hopefully) see why it fits like good glove.&lt;/p&gt;

&lt;p&gt;1. Create new WCF project called “MyWcf” using following VS template: 
  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/WhyWCFsinceIlikeWebServices_78D2/WCF%201_2.png"&gt;&lt;img title="WCF 1" border="0" alt="WCF 1" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/WhyWCFsinceIlikeWebServices_78D2/WCF%201_thumb.png" width="138" height="18" /&gt;&lt;/a&gt; 

  &lt;br /&gt;2. Add reference to “MyLibrary” 

  &lt;br /&gt;3. Delete &lt;em&gt;IService1.cs&lt;/em&gt; and &lt;em&gt;Service1.svc &lt;/em&gt;from your newly created project. 

  &lt;br /&gt;4. Add new item “MyWcfService.svc” (using &lt;em&gt;WCF Service &lt;/em&gt;template) 

  &lt;br /&gt;5. Modify “IMyWcfService.cs” file: 

  &lt;table cellspacing="10"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" align="right"&gt;
          &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
12&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;&lt;font color="#0000ff"&gt;using&lt;/font&gt; System.ServiceModel;
&lt;font color="#0000ff"&gt;using&lt;/font&gt; MyLibrary;

&lt;font color="#0000ff"&gt;namespace&lt;/font&gt; MyWcf
{
  [&lt;font color="#2b91af"&gt;ServiceContract&lt;/font&gt;]
  &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;interface&lt;/font&gt; &lt;font color="#2b91af"&gt;IMyWcfService
&lt;/font&gt;  {
    [&lt;font color="#2b91af"&gt;OperationContract&lt;/font&gt;]
    &lt;font color="#0000ff"&gt;void&lt;/font&gt; AddNewEmployee(&lt;font color="#2b91af"&gt;Employee&lt;/font&gt; employee);
  }
}&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
6. Modify “MyWcfService.cs” file: 

  &lt;table cellspacing="10"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" align="right"&gt;
          &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;&lt;font color="#0000ff"&gt;using&lt;/font&gt; System;
&lt;font color="#0000ff"&gt;using&lt;/font&gt; MyLibrary;

&lt;font color="#0000ff"&gt;namespace&lt;/font&gt; MyWcf
{
  &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;class&lt;/font&gt; &lt;font color="#2b91af"&gt;MyWcfService&lt;/font&gt; : &lt;font color="#2b91af"&gt;IMyWcfService
&lt;/font&gt;  {
    &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;void&lt;/font&gt; AddNewEmployee(&lt;font color="#2b91af"&gt;Employee&lt;/font&gt; employee)
    {
      &lt;font color="#008000"&gt;// TODO: implement
&lt;/font&gt;    }
  }
}&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
7. Open up “web.config” and modify the &lt;em&gt;system.serviceModel&lt;/em&gt; section as follows: 

  &lt;table cellspacing="10"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" align="right"&gt;
          &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;system.serviceModel&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
 &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;services&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;service&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;behaviorConfiguration&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;MyWcf.MyWcfServiceBehavior&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;name&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;MyWcf.MyWcfService&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;&amp;gt;
   &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;endpoint&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;address&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&amp;quot;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;binding&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;basicHttpBinding&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;contract&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;MyWcf.IMyWcfService&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;&amp;gt;
    &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;identity&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
     &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;dns&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;value&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;localhost&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt; /&amp;gt;
    &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;identity&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
   &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;endpoint&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
   &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;endpoint&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;address&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;mex&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;binding&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;mexHttpBinding&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;contract&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;IMetadataExchange&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt; /&amp;gt;
  &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;service&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
 &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;services&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
 &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;behaviors&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;serviceBehaviors&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
   &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;behavior&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;name&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;MyWcf.MyWcfServiceBehavior&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;&amp;gt;
    &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;serviceMetadata&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;httpGetEnabled&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;true&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt; /&amp;gt;
    &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;serviceDebug&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;includeExceptionDetailInFaults&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt;false&lt;/font&gt;&amp;quot;&lt;font color="#0000ff"&gt; /&amp;gt;
   &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;behavior&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
  &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;serviceBehaviors&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
 &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;behaviors&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;system.serviceModel&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
(you might notice that most important part is the &lt;strong&gt;binding&lt;em&gt; &lt;/em&gt;&lt;/strong&gt;what I have changed to be &lt;strong&gt;basicHttpBinding&lt;/strong&gt;) 

  &lt;br /&gt;

  &lt;br /&gt;8. Go back to your “My Win App” project. 

  &lt;br /&gt;&amp;#160; - Remove “WebServices” web references 

  &lt;br /&gt;&amp;#160; - Add new “Service Reference” to your newly created WCF Service and name it “WcfServices” 

  &lt;br /&gt;&amp;#160; - Verify that you have “Reuse types in referenced assemblies” checked in settings (you can see them if you click &lt;em&gt;Advanced...&lt;/em&gt; button from the “&lt;em&gt;Add Service Reference”&lt;/em&gt; dialog): 

  &lt;br /&gt;&lt;img title="WCF 2" border="0" alt="WCF 2" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/WhyWCFsinceIlikeWebServices_78D2/WCF%202_3.png" width="287" height="256" /&gt;&amp;#160; &lt;br /&gt;

  &lt;br /&gt;9. Modify your code to use this new service: 

  &lt;table cellspacing="10"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" align="right"&gt;
          &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;MyLibrary.&lt;font color="#2b91af"&gt;Employee&lt;/font&gt; employee = &lt;font color="#0000ff"&gt;new&lt;/font&gt; &lt;font color="#2b91af"&gt;Employee&lt;/font&gt;();
employee.FirstName = &lt;font color="#a31515"&gt;&amp;quot;John&amp;quot;&lt;/font&gt;;
employee.LastName = &lt;font color="#a31515"&gt;&amp;quot;Doe&amp;quot;&lt;/font&gt;;
WcfServices.&lt;font color="#2b91af"&gt;MyWcfServiceClient&lt;/font&gt; myWcf = &lt;font color="#0000ff"&gt;new&lt;/font&gt; MyWinApp.WcfServices.&lt;font color="#2b91af"&gt;MyWcfServiceClient&lt;/font&gt;();
myWcf.AddNewEmployee(employee);&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
10. Enjoy one of the benefits of WCF &lt;strong&gt;:-)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is just one of the many benefits that WCF over the “good old ASP.NET Web Services”. So if you’re interested then you should start looking more information on the web. 
  &lt;br /&gt;

  &lt;br /&gt;Anyways... Happy hacking! 

  &lt;br /&gt;

  &lt;br /&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9000423" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/.NET+General/default.aspx">.NET General</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/WCF/default.aspx">WCF</category></item><item><title>Tip: Disable RunOnce from Internet Explorer in your VPC images</title><link>http://blogs.msdn.com/jannemattila/archive/2008/09/17/tip-disable-runonce-from-internet-explorer-in-your-vpc-images.aspx</link><pubDate>Wed, 17 Sep 2008 14:30:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8955348</guid><dc:creator>jannemattila</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/8955348.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=8955348</wfw:commentRss><description>&lt;p&gt;If you’re working with VPC images that cannot connect to internet you might have noticed annoying thing at Internet Explorer. IE tries to connect to internet so that it could finish up the setup. It’s good if you &lt;strong&gt;CAN&lt;/strong&gt; connect to internet but it’s really annoying if you won’t ever have network connection (and this happens typically if you don’t want to connect your VPC to network). And waiting for the timeout isn’t that nice (+ pressing the stop button doesn’t help that much).&lt;/p&gt;  &lt;p&gt;This can be however changed through registry. Just add two keys (or modify existing) &lt;em&gt;RunOnceHasShown&lt;/em&gt; and &lt;em&gt;RunOnceComplete&lt;/em&gt;. Here is example .reg file for that:&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Windows Registry Editor Version 5.00 &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]     &lt;br /&gt;&amp;quot;RunOnceHasShown&amp;quot;=dword:00000001      &lt;br /&gt;&amp;quot;RunOnceComplete&amp;quot;=dword:00000001&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;After that you should have following keys under &lt;em&gt;HKCU\Software\Microsoft\Internet Explorer\Main&lt;/em&gt;:&lt;/p&gt;  &lt;p&gt;&lt;img title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/DisableRunOncefromInternetExplorer_C3BE/image_3.png" width="336" height="48" /&gt;&lt;/p&gt;  &lt;p&gt;And now if you launch IE it won’t try to connect to internet. You might also want to change your home page to be something simple like &lt;em&gt;about:blank&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;This was just small tip to make your development life a bit easier in the world of VPC images.   &lt;br /&gt;    &lt;br /&gt;Anyways… Happy hacking!    &lt;br /&gt;    &lt;br /&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8955348" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category></item><item><title>Use LINQ to access CRM objects</title><link>http://blogs.msdn.com/jannemattila/archive/2008/08/29/use-linq-to-access-crm-objects.aspx</link><pubDate>Fri, 29 Aug 2008 15:43:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8904857</guid><dc:creator>jannemattila</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/8904857.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=8904857</wfw:commentRss><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;If you have written small console application to check some data from CRM database you have probably already read this article from MSDN: &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/cc151204.aspx"&gt;Use Filtered Views&lt;/a&gt;. That is okay but honestly I’m currently more into LINQ solution. I’ll show you what I mean...&lt;/p&gt;  &lt;p&gt;First I'll create new Console Application project and &lt;em&gt;Add New Item&lt;/em&gt; to it and select &lt;em&gt;LINQ to SQL Classes&lt;/em&gt; and name it &lt;em&gt;CRMDataClasses.dbml&lt;/em&gt;:     &lt;br /&gt;&lt;img title="LINQDataClasses" border="0" alt="LINQDataClasses" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/CRMandLINQ_C741/LINQDataClasses_3.png" width="544" height="304" /&gt; &lt;/p&gt;  &lt;p&gt;Then I'll use &lt;em&gt;Server Explorer&lt;/em&gt; to connect to CRM database:     &lt;br /&gt;&lt;img title="ServerExplorer" border="0" alt="ServerExplorer" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/CRMandLINQ_C741/ServerExplorer_3.png" width="254" height="164" /&gt;&lt;/p&gt;  &lt;p&gt;And then I'll drag &lt;em&gt;Account, Contact, FilteredAccount &lt;/em&gt;and &lt;em&gt;FilteredContact&lt;/em&gt; to the canvas of our newly created &lt;em&gt;CRMDataClasses.dbml: &lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/CRMandLINQ_C741/CRMDataClasses_5.png"&gt;&lt;img title="CRMDataClasses" border="0" alt="CRMDataClasses" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/CRMandLINQ_C741/CRMDataClasses_thumb_1.png" width="700" height="264" /&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Now I'm ready to use LINQ to these views:    &lt;br /&gt;    &lt;table cellspacing="10"&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td valign="top" align="right"&gt;           &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;&lt;font color="#2b91af"&gt;CRMDataClassesDataContext&lt;/font&gt; dataContext = &lt;font color="#0000ff"&gt;new&lt;/font&gt; &lt;font color="#2b91af"&gt;CRMDataClassesDataContext&lt;/font&gt;();

&lt;font color="#0000ff"&gt;var&lt;/font&gt; queryContact = &lt;font color="#0000ff"&gt;from&lt;/font&gt; contact &lt;font color="#0000ff"&gt;in&lt;/font&gt; dataContext.Contacts
          &lt;font color="#0000ff"&gt;where&lt;/font&gt; contact.MobilePhone.Length &amp;gt; 0 &amp;amp;&amp;amp;
          contact.LastName.Length &amp;gt; 0
    &lt;font color="#0000ff"&gt;select&lt;/font&gt; contact;

&lt;font color="#2b91af"&gt;Console&lt;/font&gt;.WriteLine(&lt;font color="#a31515"&gt;&amp;quot;Contact(s):&amp;quot;&lt;/font&gt;);
&lt;font color="#0000ff"&gt;foreach&lt;/font&gt; (&lt;font color="#2b91af"&gt;Contact&lt;/font&gt; c &lt;font color="#0000ff"&gt;in&lt;/font&gt; queryContact)
{
  &lt;font color="#2b91af"&gt;Console&lt;/font&gt;.WriteLine(c.FirstName + &lt;font color="#a31515"&gt;&amp;quot; &amp;quot;&lt;/font&gt; + c.LastName + &lt;font color="#a31515"&gt;&amp;quot;, &amp;quot;&lt;/font&gt; + c.MobilePhone);
}

&lt;font color="#0000ff"&gt;var&lt;/font&gt; queryFilteredContact = &lt;font color="#0000ff"&gt;from&lt;/font&gt; contact &lt;font color="#0000ff"&gt;in&lt;/font&gt; dataContext.FilteredContacts
          &lt;font color="#0000ff"&gt;select&lt;/font&gt; contact;
&lt;font color="#2b91af"&gt;Console&lt;/font&gt;.WriteLine(&lt;font color="#a31515"&gt;&amp;quot;&amp;quot;&lt;/font&gt;);

&lt;font color="#2b91af"&gt;Console&lt;/font&gt;.WriteLine(&lt;font color="#a31515"&gt;&amp;quot;Filtered contact(s):&amp;quot;&lt;/font&gt;);
&lt;font color="#0000ff"&gt;foreach&lt;/font&gt; (&lt;font color="#2b91af"&gt;FilteredContact&lt;/font&gt; c &lt;font color="#0000ff"&gt;in&lt;/font&gt; queryFilteredContact)
{
  &lt;font color="#2b91af"&gt;Console&lt;/font&gt;.WriteLine(c.lastname);
}&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/p&gt;

&lt;p&gt;On lines 3 to 6 I queried all contacts that have lastname and mobilephone filled in. On lines 14 to 15 I'm querying all contacts where current user has access to. &lt;strong&gt;NOTE: It doesn't return anything if you use SQL Authentication!&lt;/strong&gt; So both of these can be used to fill you applications needs. But do notice that for some reason the attributes at the &lt;em&gt;FilteredContacts&lt;/em&gt; are all lower case and in &lt;em&gt;Contacts&lt;/em&gt; their naming is a bit different. So if you plan to change from &lt;em&gt;Contacts &lt;/em&gt;to &lt;em&gt;FilteredContact&lt;/em&gt; your going to have to change the casing of the attributes little bit.&lt;/p&gt;

&lt;p&gt;This was just quick advice how you can leverage LINQ to your CRM solutions.
  &lt;br /&gt;

  &lt;br /&gt;Anyways... Happy hacking!

  &lt;br /&gt;

  &lt;br /&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8904857" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Microsoft+CRM/default.aspx">Microsoft CRM</category></item><item><title>Maximize the use of CPU with parallel extensions (+ some WPF stuff)</title><link>http://blogs.msdn.com/jannemattila/archive/2008/08/26/maximize-the-use-of-cpu-with-parallel-extensions-some-wpf-stuff.aspx</link><pubDate>Tue, 26 Aug 2008 22:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8898129</guid><dc:creator>jannemattila</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/8898129.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=8898129</wfw:commentRss><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Since this is my &lt;u&gt;40th post to this blog&lt;/u&gt; I decided to go back to square one… or &lt;a href="http://blogs.msdn.com/jannemattila/archive/2007/01/07/solving-small-puzzles-with-just-a-few-lines-of-code.aspx" target="_blank"&gt;post one&lt;/a&gt; actually &lt;strong&gt;:-)&lt;/strong&gt; I’m going to create Windows Presentation Foundation (WPF) application that solves the &lt;a href="http://en.wikipedia.org/wiki/Knight%27s_tour" target="_blank"&gt;Knight’s Tour&lt;/a&gt; puzzle. I actually didn’t know about this puzzle before I bought book called &lt;a href="http://www.wrox.com/WileyCDA/WroxTitle/Puzzles-for-Programmers-and-Pros.productCd-0470121688.html" target="_blank"&gt;Puzzles for Programmers and Pros&lt;/a&gt;. That book had interesting puzzle that lead in to this post. So here we go!&lt;/p&gt;  &lt;p&gt;I said that I’m going to create WPF application for my UI. You might ask why not the “good old” Windows Forms application...? Well for these simple reasons:    &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;1.&lt;/strong&gt;&amp;#160; I don’t like to write code to &lt;em&gt;OnPaint&lt;/em&gt; / &lt;em&gt;MainForm_Paint&lt;/em&gt; methods.     &lt;br /&gt;&lt;strong&gt;2. &lt;/strong&gt;I wanted to define my user interface and then just say in code “hey knight go there” and it should just draw the UI with the knight in the correct position. But the defined UI must be also scalable.     &lt;br /&gt;&lt;strong&gt;3. &lt;/strong&gt;WPF doesn’t have same barriers than Windows Forms does =&amp;gt; It’s the face of future applications!     &lt;br /&gt;    &lt;br /&gt;I don’t probably have to explain my reason #1 for you if you have experienced the same that I have :-) You’ll end up writing the UI code a lot and that’s not what you’re trying to do. You’re trying to solve puzzle and you are suddenly focusing for the UI code. That’s wrong approach. Therefore reason #2 goes hand-in-hand with #1. &lt;/p&gt;  &lt;p&gt;So let’s look the the UI of the running application:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/KnightsTourparallelism_CDDE/WPF%20UI_2.png"&gt;&lt;img title="WPF UI" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="306" alt="WPF UI" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/KnightsTourparallelism_CDDE/WPF%20UI_thumb.png" width="306" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;It’s the view of the classic chess board and I decided to take shortcut when creating the knight. I decided to use gray circle instead (or ellipse actually) &lt;strong&gt;:-)&lt;/strong&gt; And for the layout management I just took the easy approach by using &lt;em&gt;Grid&lt;/em&gt; and defining &lt;em&gt;Columns&lt;/em&gt; and &lt;em&gt;Rows&lt;/em&gt;. Here is the XAML for the UI:&lt;/p&gt;  &lt;table cellspacing="10"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" align="right"&gt;         &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37&lt;/font&gt;&lt;/pre&gt;
      &lt;/td&gt;

      &lt;td valign="top"&gt;
        &lt;pre&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;Window&lt;/font&gt;&lt;font color="#ff0000"&gt; x&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#ff0000"&gt;Class&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Window1&amp;quot;
&lt;/font&gt;  &lt;font color="#ff0000"&gt; xmlns&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;
&lt;/font&gt;  &lt;font color="#ff0000"&gt; xmlns&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#ff0000"&gt;x&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;
&lt;/font&gt;  &lt;font color="#ff0000"&gt; Title&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Knight's Tour&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt; MinHeight&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;100&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt; MinWidth&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;100&amp;quot;&lt;/font&gt; 
    &lt;font color="#ff0000"&gt; Width&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;300&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt; Height&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;300&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt; Loaded&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Window_Loaded&amp;quot;&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;  &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;Grid&lt;/font&gt;&lt;font color="#ff0000"&gt; x&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#ff0000"&gt;Name&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Board&amp;quot;&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;    
    &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;Grid.ColumnDefinitions&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;ColumnDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;ColumnDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;ColumnDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;ColumnDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;ColumnDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;ColumnDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;ColumnDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;ColumnDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;    &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;Grid.ColumnDefinitions&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;    &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;Grid.RowDefinitions&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;RowDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;RowDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;RowDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;RowDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;RowDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;RowDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;RowDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;      &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;RowDefinition&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;    &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;Grid.RowDefinitions&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;

&lt;/font&gt;&lt;font color="#a31515"&gt;    &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;Ellipse&lt;/font&gt;&lt;font color="#ff0000"&gt; x&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#ff0000"&gt;Name&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Knight&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt; Fill&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;Gray&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt; Panel.ZIndex&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;1&amp;quot;
&lt;/font&gt;        &lt;font color="#ff0000"&gt; Grid.Column&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;{&lt;/font&gt;&lt;font color="#a31515"&gt;Binding&lt;/font&gt;&lt;font color="#ff0000"&gt; Path&lt;/font&gt;&lt;font color="#0000ff"&gt;=KnightX}&amp;quot;&lt;/font&gt; 
        &lt;font color="#ff0000"&gt; Grid.Row&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;{&lt;/font&gt;&lt;font color="#a31515"&gt;Binding&lt;/font&gt;&lt;font color="#ff0000"&gt; Path&lt;/font&gt;&lt;font color="#0000ff"&gt;=KnightY}&amp;quot; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;    
    &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;Rectangle&lt;/font&gt;&lt;font color="#ff0000"&gt; x&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#ff0000"&gt;Name&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;A8&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt; Fill&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;White&amp;quot; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;    &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;Rectangle&lt;/font&gt;&lt;font color="#ff0000"&gt; x&lt;/font&gt;&lt;font color="#0000ff"&gt;:&lt;/font&gt;&lt;font color="#ff0000"&gt;Name&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;B8&amp;quot;&lt;/font&gt;&lt;font color="#ff0000"&gt; Grid.Column&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;1&amp;quot; /&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;    &lt;/font&gt;&lt;font color="#008000"&gt;&amp;lt;!-- Etc... --&amp;gt;
&lt;/font&gt;&lt;font color="#a31515"&gt;  &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;Grid&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;Window&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/pre&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;You probably noticed the interesting part of the XAML... and that’s the lines 30 and 31 where &lt;em&gt;Binding &lt;/em&gt;is defined. It means that these values coming from the public properties of the &lt;em&gt;DataContext&lt;/em&gt;. So let’s look at the code behind that XAML and let’s discuss the binding little bit more: 

  &lt;table cellspacing="10"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" align="right"&gt;
          &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;&lt;font color="#0000ff"&gt;using&lt;/font&gt; System;
&lt;font color="#0000ff"&gt;using&lt;/font&gt; System.ComponentModel;
&lt;font color="#0000ff"&gt;using&lt;/font&gt; System.Diagnostics;
&lt;font color="#0000ff"&gt;using&lt;/font&gt; System.Windows;
&lt;font color="#0000ff"&gt;using&lt;/font&gt; System.Windows.Media;
&lt;font color="#0000ff"&gt;using&lt;/font&gt; System.Windows.Shapes;

&lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;partial&lt;/font&gt; &lt;font color="#0000ff"&gt;class&lt;/font&gt; &lt;font color="#2b91af"&gt;Window1&lt;/font&gt; : &lt;font color="#2b91af"&gt;Window&lt;/font&gt;, &lt;font color="#2b91af"&gt;INotifyPropertyChanged
&lt;/font&gt;{
  &lt;font color="#0000ff"&gt;private&lt;/font&gt; &lt;font color="#0000ff"&gt;int&lt;/font&gt; knightX = 0;
  &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;int&lt;/font&gt; KnightX
  {
    &lt;font color="#0000ff"&gt;get&lt;/font&gt; { &lt;font color="#0000ff"&gt;return&lt;/font&gt; knightX; }
    &lt;font color="#0000ff"&gt;set
&lt;/font&gt;    {
      knightX = &lt;font color="#0000ff"&gt;value&lt;/font&gt;;
      NotifyPropertyChanged(&lt;font color="#a31515"&gt;&amp;quot;KnightX&amp;quot;&lt;/font&gt;);
    }
  }

  &lt;font color="#0000ff"&gt;private&lt;/font&gt; &lt;font color="#0000ff"&gt;int&lt;/font&gt; knightY = 0;
  &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;int&lt;/font&gt; KnightY
  {
    &lt;font color="#0000ff"&gt;get&lt;/font&gt; { &lt;font color="#0000ff"&gt;return&lt;/font&gt; knightY; }
    &lt;font color="#0000ff"&gt;set
&lt;/font&gt;    {
      knightY = &lt;font color="#0000ff"&gt;value&lt;/font&gt;;
      NotifyPropertyChanged(&lt;font color="#a31515"&gt;&amp;quot;KnightY&amp;quot;&lt;/font&gt;);
    }
  }

  &lt;font color="#0000ff"&gt;private&lt;/font&gt; &lt;font color="#0000ff"&gt;void&lt;/font&gt; Window_Loaded(&lt;font color="#0000ff"&gt;object&lt;/font&gt; sender, &lt;font color="#2b91af"&gt;RoutedEventArgs&lt;/font&gt; e)
  {
    Knight.DataContext = &lt;font color="#0000ff"&gt;this&lt;/font&gt;;
    &lt;font color="#008000"&gt;// Now moving the Knight is easy!
&lt;/font&gt;    KnightX = 3;
    KnightY = 3;
  }

  &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;event&lt;/font&gt; &lt;font color="#2b91af"&gt;PropertyChangedEventHandler&lt;/font&gt; PropertyChanged;
  &lt;font color="#0000ff"&gt;private&lt;/font&gt; &lt;font color="#0000ff"&gt;void&lt;/font&gt; NotifyPropertyChanged(&lt;font color="#2b91af"&gt;String&lt;/font&gt; info)
  {
    &lt;font color="#0000ff"&gt;if&lt;/font&gt; (PropertyChanged != &lt;font color="#0000ff"&gt;null&lt;/font&gt;)
    {
      PropertyChanged(&lt;font color="#0000ff"&gt;this&lt;/font&gt;, &lt;font color="#0000ff"&gt;new&lt;/font&gt; &lt;font color="#2b91af"&gt;PropertyChangedEventArgs&lt;/font&gt;(info));
    }
  }
  &lt;font color="#008000"&gt;//...&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
You might already noticed that my window also implements &lt;em&gt;INotyfyPropertyChanged&lt;/em&gt; interface. And my two properties actually call &lt;em&gt;NotifyPropertyChanged&lt;/em&gt; method when they are changed. So what’s this all about? Well if you don’t do this your values will be updated for the first time and after that they don’t actually get “bubbled” up to the ellipse anymore... unless you implement the notify mechanisms yourself. This is quite important and you should probably read more information about it on MSDN. &lt;/p&gt;

&lt;p&gt;For the actual solving part I just used classic “old recursion” to solve the puzzle. And this is the part where we finally are going to the &lt;em&gt;title&lt;/em&gt; of my post... &lt;/p&gt;

&lt;p&gt;Classic one worker thread approach gives “fairly easy to implement but sub-optimal” solution. And you might ask why? And to answer this question I’m going so show you picture of task manager: 
  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/KnightsTourparallelism_CDDE/CPU1_2.png"&gt;&lt;img title="CPU1" height="116" alt="CPU1" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/KnightsTourparallelism_CDDE/CPU1_thumb.png" width="654" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;This picture was taken when my solver was running in “full speed ahead” –mode. And guess what... &lt;u&gt;I’m not impressed&lt;/u&gt;! I’m actually just using single CPU (see the third box where green line has reached the roof)!!! So my worker thread approach is far from optimal resource usage.&lt;/p&gt;

&lt;p&gt;Okay... What can I do then? I could do multiple threads and handle them manually but that’s again writing a lot of code that doesn’t have anything to do with the actual solving!? So if I would chosen Windows Forms + manual handling of multiple threads I would have a lot of code and just small fraction of that would actually do work that I was originally planning to do. &lt;/p&gt;

&lt;p&gt;This is where &lt;a href="http://blogs.msdn.com/pfxteam/" target="_blank"&gt;&lt;em&gt;Parallel Extensions&lt;/em&gt;&lt;/a&gt;&lt;em&gt; &lt;/em&gt;(&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=348F73FD-593D-4B3C-B055-694C50D2B0F3&amp;amp;displaylang=en" target="_blank"&gt;download&lt;/a&gt;)&lt;em&gt; &lt;/em&gt;comes into the game! It’s additional library (&lt;em&gt;System.Threading.dll&lt;/em&gt;) sitting on top of .NET Framework 3.5 and it’s currently in CTP phase. But I still highly recommend you to check it out if you want easily get more horse power to your algorithms. &lt;/p&gt;

&lt;p&gt;I analyzed my code and noticed part where I could do things differently: 
  &lt;table cellspacing="10"&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;td valign="top" align="right"&gt;
          &lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
&lt;/font&gt;&lt;/pre&gt;
        &lt;/td&gt;

        &lt;td valign="top"&gt;
          &lt;pre&gt;&lt;font color="#008000"&gt;// My code was this:
&lt;/font&gt;&lt;font color="#0000ff"&gt;foreach&lt;/font&gt; (&lt;font color="#0000ff"&gt;int&lt;/font&gt; location &lt;font color="#0000ff"&gt;in&lt;/font&gt; startLocations)
{
  &lt;font color="#008000"&gt;// Calculations here!
&lt;/font&gt;}

&lt;font color="#008000"&gt;// And I changed it to this:
&lt;/font&gt;&lt;font color="#2b91af"&gt;Parallel&lt;/font&gt;.ForEach&amp;lt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&amp;gt;(startLocations, (location) =&amp;gt;
{
  &lt;font color="#008000"&gt;// Calculations here!
&lt;/font&gt;});&lt;/pre&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;

  &lt;br /&gt;So I changed code in line 2 to be the code at line 8. What was the result at the task manager then: 

  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/KnightsTourparallelism_CDDE/CPU2_2.png"&gt;&lt;img title="CPU2" height="111" alt="CPU2" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/KnightsTourparallelism_CDDE/CPU2_thumb.png" width="650" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Well I believe that I managed to get better use of the available horse power &lt;strong&gt;:-)&lt;/strong&gt; It shows of course in the results: 

  &lt;br /&gt;“foreach”: ~50 solved solutions in ~5 minutes 

  &lt;br /&gt;”Parallel.ForEach”: ~450 solved solutions in &amp;lt; 5 minutes&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To summarize... &lt;/strong&gt;&lt;u&gt;I just changed 1 line of code and I was able to get unbelievable results from it!&lt;/u&gt; So if you’re doing something similar then I recommend checking out the parallel extensions first before doing “own custom solution” for that. &lt;/p&gt;

&lt;p&gt;I originally thought that I would go little bit deeper into the details of my solver but this post ended up too long even without it so maybe I’ll pass this time... But I’ll include &lt;a href="http://blogs.msdn.com/jannemattila/attachment/8898129.ashx" target="_blank"&gt;video clip&lt;/a&gt; that shows the UI of the application when it’s solving.

  &lt;br /&gt;

  &lt;br /&gt;Anyways... Happy hacking! 

  &lt;br /&gt;

  &lt;br /&gt;J&lt;/p&gt;

&lt;p&gt;P.S. I’m also interested in F# and I’m probably going to do something fun with that too.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8898129" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/jannemattila/attachment/8898129.ashx" length="18623" type="video/x-ms-wmv" /><category domain="http://blogs.msdn.com/jannemattila/archive/tags/.NET+General/default.aspx">.NET General</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Application+Development/default.aspx">Application Development</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Programming/default.aspx">Programming</category></item><item><title>Link: SharePoint slow spin-up times…</title><link>http://blogs.msdn.com/jannemattila/archive/2008/05/29/link-sharepoint-slow-spin-up-times.aspx</link><pubDate>Thu, 29 May 2008 18:14:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8558858</guid><dc:creator>jannemattila</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/8558858.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=8558858</wfw:commentRss><description>&lt;p&gt;I accidently found myself on this page: &lt;a href="http://jritmeijer.spaces.live.com/blog/cns!8A48A27460FB898A!965.entry" target="_blank"&gt;SharePoint 2007 Quirks - Solving painfully slow spin-up times&lt;/a&gt;. After reading that article I was forced to test that. And my &lt;em&gt;stsadm&lt;/em&gt; experience was really fast after that! So this link deserves a link post even if I don’t do those normally &lt;strong&gt;:-) &lt;/strong&gt;&lt;br&gt;&lt;br&gt;Anyways... Happy hacking!&lt;br&gt;&lt;br&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8558858" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Microsoft+Office+SharePoint+Server+2007/default.aspx">Microsoft Office SharePoint Server 2007</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category></item><item><title>Adding CRM 4.0 to your own win app with web form authentication</title><link>http://blogs.msdn.com/jannemattila/archive/2008/05/26/adding-crm-4-0-to-your-own-win-app-with-web-form-authentication.aspx</link><pubDate>Mon, 26 May 2008 09:15:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8551960</guid><dc:creator>jannemattila</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/8551960.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=8551960</wfw:commentRss><description>&lt;p&gt;Last year I wrote small article &lt;a href="http://blogs.msdn.com/jannemattila/archive/2007/09/25/adding-ms-crm-to-your-own-windows-forms-applications.aspx" target="_blank"&gt;Adding MS CRM to your own windows forms applications&lt;/a&gt; that demonstrates the usage of CRM in your own custom windows forms applications. In CRM 4.0 the story is pretty much the same but there’re few things that you need to take into account so that everything works as you expect. One thing is multi-tenancy and another one is different authentication mechanisms. CRM 4.0 introduces new authentication mechanism called Service Provider License Agreement / SPLA / IFD / Internet Facing Deployment (it has sooo many names :-). Basicly it just means that you login to CRM using web form so it isn’t anything fancier. And that authentication is of course cookie based so if you use Fiddler you’ll see something like this (Note: image is clipped):&lt;/p&gt; &lt;p&gt;&lt;img border="0" alt="CRMCookie" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Add.0toyourownwinappwithwebformauthentic_6429/CRMCookie_0e5cfaaf-10d3-46e3-be26-73dba2a6c877.jpg" width="344" height="105"&gt; &lt;/p&gt; &lt;p&gt;So there is &lt;em&gt;MSCRMSession&lt;/em&gt; ticket that authenticates the user to the system. Okay fine… but what if I want to spawn CRM session whenever I like and still provide “&lt;em&gt;auto login” &lt;/em&gt;for my end users (and of course you’re not using windows authentication a.k.a. On Premise authentication)? Let’s first use Fiddler to determine what’s happening under covers in IFD (and compare it to win auth):&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Add.0toyourownwinappwithwebformauthentic_6429/IFD_2.jpg" target="_blank"&gt;&lt;img border="0" alt="IFD" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Add.0toyourownwinappwithwebformauthentic_6429/IFD_thumb.jpg" width="700" height="252"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Here’s screenshot of Fiddler when user logs on (see highlighted username and password). So the login is just normal HTTP POST. &lt;/p&gt; &lt;p&gt;If we compare that to win auth then we’ll see that there’s that normal &lt;em&gt;authorization&lt;/em&gt; headers that makes the magic happen:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Add.0toyourownwinappwithwebformauthentic_6429/WinAuth_2.jpg" target="_blank"&gt;&lt;img border="0" alt="WinAuth" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Add.0toyourownwinappwithwebformauthentic_6429/WinAuth_thumb.jpg" width="700" height="230"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;You have probably noticed the other difference... which is status code 401. In win auth the system returns 401 which starts the authentication routine. In IFD you’ll save time because you don’t do those 401 round-trips.&lt;/p&gt; &lt;p&gt;But okay.. now we need to achieve “&lt;em&gt;auto login"&lt;/em&gt; and for that we’ll need little bit of code. Example code has been taken from &lt;a href="http://support.microsoft.com/kb/174923" target="_blank"&gt;How To Use the PostData Parameter in WebBrowser Control&lt;/a&gt; and it has been modified for this case. And here we go:&lt;/p&gt; &lt;table cellspacing="10"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" align="right"&gt;&lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;pre&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt; signInUrl = &lt;font color="#a31515"&gt;"http://mcs.mycrmserver.local/signin.aspx?targeturl="&lt;/font&gt;;
&lt;font color="#0000ff"&gt;string&lt;/font&gt; destinationUrl = &lt;font color="#2b91af"&gt;HttpUtility&lt;/font&gt;.UrlEncode(&lt;font color="#a31515"&gt;"http://mcs.mycrmserver.local/loader.aspx"&lt;/font&gt;);
&lt;font color="#0000ff"&gt;using&lt;/font&gt; (&lt;font color="#2b91af"&gt;WebBrowser&lt;/font&gt; browser = &lt;font color="#0000ff"&gt;new&lt;/font&gt; &lt;font color="#2b91af"&gt;WebBrowser&lt;/font&gt;())
{
  &lt;font color="#0000ff"&gt;string&lt;/font&gt; postData = &lt;font color="#a31515"&gt;"txtUserName="&lt;/font&gt; + username + &lt;font color="#a31515"&gt;"&amp;amp;txtPassword="&lt;/font&gt; + password;
  browser.Navigate(
    signInUrl + destinationUrl &lt;font color="#008000"&gt;/* Url */&lt;/font&gt;,
    &lt;font color="#a31515"&gt;"_blank"&lt;/font&gt; &lt;font color="#008000"&gt;/* Target */&lt;/font&gt;,
    &lt;font color="#2b91af"&gt;Encoding&lt;/font&gt;.UTF8.GetBytes(postData) &lt;font color="#008000"&gt;/* Postdata */&lt;/font&gt;,
    &lt;font color="#a31515"&gt;"Content-Type: application/x-www-form-urlencoded"&lt;/font&gt; + &lt;font color="#2b91af"&gt;Environment&lt;/font&gt;.NewLine &lt;font color="#008000"&gt;/* Headers */&lt;/font&gt;);
}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;That code clips uses &lt;em&gt;System.Windows.Forms.WebBrowser &lt;/em&gt;component to POST the login information to CRM so that end user won’t notice the logon event at all. In this example the user will be redirected into the main CRM page (as defined at line 2) but you can of course use any page under CRM if you need to.&lt;/p&gt;
&lt;p&gt;Obviously this approach poses some security threats since you need to store username and especially password in memory. But you can make this thing better by storing the confidential values at &lt;em&gt;System.Security.SecureString&lt;/em&gt; (more info can be found in &lt;a href="http://msdn.microsoft.com/en-us/library/system.security.securestring.aspx" target="_blank"&gt;MSDN&lt;/a&gt;). &lt;em&gt;SecureString&lt;/em&gt; is designed for storing confidential text. And of course you should use HTTPS so that you don’t pass on the information plain text. &lt;/p&gt;
&lt;p&gt;&lt;br&gt;Anyways... Happy hacking!&lt;br&gt;&lt;br&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8551960" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Microsoft+CRM/default.aspx">Microsoft CRM</category></item><item><title>CRM 4.0 (or SharePoint or custom application) and DebugView</title><link>http://blogs.msdn.com/jannemattila/archive/2008/05/07/crm-4-0-or-sharepoint-or-custom-application-and-debugview.aspx</link><pubDate>Wed, 07 May 2008 10:04:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8465208</guid><dc:creator>jannemattila</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/8465208.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=8465208</wfw:commentRss><description>&lt;p&gt;Every now and then I’m find myself trying to solve same issues over and over again :-) That’s why I found myself (again) using &lt;em&gt;DebugView&lt;/em&gt; as my debugging assistant at remote box. If you don’t know what &lt;em&gt;DebugView&lt;/em&gt; is then you should definitely try it out. I’m going to give you few ideas how you could use it at your applications. You can download the &lt;em&gt;DebugView&lt;/em&gt; from &lt;a title="DebugView download" href="http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx" target="_blank"&gt;Technet&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Why do I use &lt;em&gt;DebugView&lt;/em&gt;? Well I want to get debug messages from running system BUT... I don’t want to write to EventLog or to File since it’s totally unnecessary to write all the messages all the time. I just want messages when I’m ready to observe the system. And DebugView is handy tool for that. Here is list of steps how I normally implement that kind of approach:&lt;br&gt;1) Create log class that implements logging/tracing/debugging (this is pretty much just wrapper to few simple method calls) (I recommend making this as singleton)&lt;br&gt;2) Use you log class in your application/solution&lt;br&gt;3) Use &lt;em&gt;DebugView &lt;/em&gt;to follow the trace messages written by your log class&lt;/p&gt; &lt;p&gt;In 1) I mention that I recommend using singleton approach at the log class. This is important especially at the CRM 4.0 where you need to add default trace listener so that you’ll get the trace messages. Here is the code example for that:&lt;/p&gt; &lt;p&gt; &lt;table cellspacing="10"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" align="right"&gt;&lt;pre&gt;&lt;font color="gray"&gt;1
2
3&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;pre&gt;&lt;font color="#0000ff"&gt;using&lt;/font&gt; System.Diagnostics;
&lt;font color="#008000"&gt;// ...
&lt;/font&gt;&lt;font color="#2b91af"&gt;Trace&lt;/font&gt;.Listeners.Add(&lt;font color="#0000ff"&gt;new&lt;/font&gt; &lt;font color="#2b91af"&gt;DefaultTraceListener&lt;/font&gt;());&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;
&lt;p&gt;After you have added the default listener you can just use this oneliner:&lt;/p&gt;
&lt;p&gt;
&lt;table cellspacing="10"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" align="right"&gt;&lt;pre&gt;&lt;font color="gray"&gt;1&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;pre&gt;&lt;font color="#2b91af"&gt;Trace&lt;/font&gt;.WriteLine(&lt;font color="#a31515"&gt;"My Trace: "&lt;/font&gt; + message);&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;
&lt;p&gt;Now your trace can be seen at the &lt;em&gt;DebugView&lt;/em&gt;:&lt;br&gt;&lt;img border="0" alt="DebugView" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/CRM4.0andDebugView_60C3/DebugView_c8bc2cb2-c36a-463a-9b14-168b4e41f642.png" width="470" height="243"&gt;&lt;br&gt;(here is CRM 4.0 where I have menu item that points to custom ASPX page and I’m using “My Trace” to see what’s happening in there)&lt;/p&gt;
&lt;p&gt;&lt;em&gt;DebugView&lt;/em&gt; has many built-in functionalities like “Save As” etc. that can help you on your debug/trace efforts. So I recommend that you learn to play around with it.&lt;/p&gt;
&lt;p&gt;I also had the magic word “SharePoint” in my title. That is for the simple reason that this same story applies to SharePoint too. And don’t forget... Since &lt;em&gt;System.Diagnostics.Trace&lt;/em&gt; is implemented at the .NET Framework this story also applies to all other applications which are built on top of that.&lt;/p&gt;
&lt;p&gt;You might also want to read my previous post about tracing: &lt;a title="CRM 4.0, SharePoint and ASP.NET Trace" href="http://blogs.msdn.com/jannemattila/archive/2008/02/23/crm-4-0-sharepoint-and-asp-net-trace.aspx" target="_blank"&gt;CRM 4.0, SharePoint and ASP.NET Trace&lt;/a&gt;.&lt;br&gt;&lt;br&gt;Anyways... Happy hacking!&lt;br&gt;&lt;br&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8465208" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Application+Development/default.aspx">Application Development</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Microsoft+Office+SharePoint+Server+2007/default.aspx">Microsoft Office SharePoint Server 2007</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Microsoft+CRM/default.aspx">Microsoft CRM</category></item><item><title>Custom SharePoint application and System.IO.FileNotFoundException</title><link>http://blogs.msdn.com/jannemattila/archive/2008/02/23/custom-sharepoint-application-and-system-io-filenotfoundexception.aspx</link><pubDate>Sat, 23 Feb 2008 23:55:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7862558</guid><dc:creator>jannemattila</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/7862558.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=7862558</wfw:commentRss><description>&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; I have normal user access rights at SharePoint but I'm administrator of the physical SharePoint box. I don't have access rights to SharePoint databases but I still need to run few lines of code against SharePoint. I have created small console application but when I run it I get nasty &lt;em&gt;System.IO.FileNotFoundException:&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;img height="333" alt="FileNotFoundException" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/RunSharePointAdmintaskwithlocalserveruse_102D7/MySharePointTask1_056daa7f-fecc-473d-b6b9-ed1cfac67e30.png" width="668" border="0"&gt; &lt;/p&gt; &lt;p&gt;What can I do?&lt;/p&gt; &lt;p&gt;&lt;strong&gt;My answer: &lt;/strong&gt;So you have used &lt;em&gt;Microsoft.SharePoint.dll&lt;/em&gt; and probably you have something like this in your code: "&lt;em&gt;using (SPSite site = new SPSite("..."))&lt;/em&gt;" and that causes the exception. Well that exception is actually pretty understandable since you're using API that connects directly to the SharePoint databases... and you mentioned that you don't have access rights to databases so it makes sense. And on top of that you have only standard user rights to SharePoint so we're at the dead end anyway. &lt;/p&gt; &lt;p&gt;That means that we need to change our approach a little bit. Of course the solution differs little bit what you're trying to do but I think that you have few options. First one is that you could use SharePoint web services to implement your functionality. I know that it's not the easiest way to go but it should to the trick. Another approach could be custom application page that does the trick. It is a bit "hacky" approach but if you need to "&lt;em&gt;do something against SharePoint&lt;/em&gt;" that is something you could try. I'll give you example so that you'll get the idea what I mean.&lt;/p&gt; &lt;p&gt;First create your custom aspx page into layouts folder (&lt;em&gt;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\&lt;/em&gt;). I created &lt;em&gt;MySharePointAdminTask.aspx&lt;/em&gt; to the root of layouts but you should add subfolder with correct naming (e.g. &lt;em&gt;Company.Project.Functionality&lt;/em&gt;). I added following code to my page:&lt;/p&gt; &lt;table cellspacing="10"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" align="right"&gt;&lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;pre&gt;&amp;lt;%&lt;font color="#0000ff"&gt;@&lt;/font&gt; &lt;font color="#a31515"&gt;Page&lt;/font&gt; &lt;font color="#ff0000"&gt;language&lt;/font&gt;&lt;font color="#0000ff"&gt;="C#"&lt;/font&gt; %&amp;gt;
&amp;lt;%&lt;font color="#0000ff"&gt;@&lt;/font&gt; &lt;font color="#a31515"&gt;Import&lt;/font&gt; &lt;font color="#ff0000"&gt;Namespace&lt;/font&gt;&lt;font color="#0000ff"&gt;="Microsoft.SharePoint"&lt;/font&gt; %&amp;gt;
&amp;lt;%&lt;font color="#0000ff"&gt;@&lt;/font&gt; &lt;font color="#a31515"&gt;Import&lt;/font&gt; &lt;font color="#ff0000"&gt;Namespace&lt;/font&gt;&lt;font color="#0000ff"&gt;="Microsoft.SharePoint.WebControls"&lt;/font&gt; %&amp;gt;

&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;script&lt;/font&gt; &lt;font color="#ff0000"&gt;runat&lt;/font&gt;&lt;font color="#0000ff"&gt;="server"&amp;gt;
&lt;/font&gt; &lt;font color="#0000ff"&gt;void&lt;/font&gt; Page_load(&lt;font color="#0000ff"&gt;object&lt;/font&gt; sender, &lt;font color="#2b91af"&gt;EventArgs&lt;/font&gt; e)
 {
  &lt;font color="#0000ff"&gt;if&lt;/font&gt; (Request.IsLocal == &lt;font color="#0000ff"&gt;true&lt;/font&gt; &amp;amp;&amp;amp; Request.IsSecureConnection == &lt;font color="#0000ff"&gt;true&lt;/font&gt;)
  {
    &lt;font color="#2b91af"&gt;SPSecurity&lt;/font&gt;.RunWithElevatedPrivileges(&lt;font color="#0000ff"&gt;delegate&lt;/font&gt;()
    {
      &lt;font color="#0000ff"&gt;using&lt;/font&gt; (&lt;font color="#2b91af"&gt;SPSite&lt;/font&gt; site = &lt;font color="#0000ff"&gt;new&lt;/font&gt; &lt;font color="#2b91af"&gt;SPSite&lt;/font&gt;(&lt;font color="#2b91af"&gt;SPControl&lt;/font&gt;.GetContextSite(&lt;font color="#2b91af"&gt;HttpContext&lt;/font&gt;.Current).ID))
      {
        &lt;font color="#0000ff"&gt;using&lt;/font&gt; (&lt;font color="#2b91af"&gt;SPWeb&lt;/font&gt; web = site.RootWeb)
        {
          &lt;font color="#008000"&gt;// TODO: add your code here
&lt;/font&gt;          &lt;font color="#008000"&gt;// Example:
&lt;/font&gt;          Response.Write(web.Title + &lt;font color="#a31515"&gt;" at url "&lt;/font&gt; + web.Url);
        }
      }
    });
  }
  &lt;font color="#0000ff"&gt;else
&lt;/font&gt;  {
    Response.StatusCode = 404;
    Response.SuppressContent = &lt;font color="#0000ff"&gt;true&lt;/font&gt;;
    Response.End();
  }
 }
&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;script&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;

&amp;lt;!&lt;/font&gt;&lt;font color="#a31515"&gt;DOCTYPE&lt;/font&gt; &lt;font color="#ff0000"&gt;html&lt;/font&gt; &lt;font color="#ff0000"&gt;PUBLIC&lt;/font&gt; &lt;font color="#0000ff"&gt;"-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/font&gt; 
 &lt;font color="#0000ff"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;
&lt;/font&gt; 
&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;html&lt;/font&gt; &lt;font color="#ff0000"&gt;xmlns&lt;/font&gt;&lt;font color="#0000ff"&gt;="http://www.w3.org/1999/xhtml"&lt;/font&gt; &lt;font color="#0000ff"&gt;&amp;gt;
&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;head&lt;/font&gt; &lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;font color="#0000ff"&gt;="Head1"&lt;/font&gt; &lt;font color="#ff0000"&gt;runat&lt;/font&gt;&lt;font color="#0000ff"&gt;="server"&amp;gt;
&lt;/font&gt;  &lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;title&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;MySharePointAdminTask&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;title&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;head&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;body&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&lt;/font&gt;  &lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;form&lt;/font&gt; &lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;font color="#0000ff"&gt;="form1"&lt;/font&gt; &lt;font color="#ff0000"&gt;runat&lt;/font&gt;&lt;font color="#0000ff"&gt;="server"&amp;gt;
&lt;/font&gt;  &lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;div&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&lt;/font&gt;    &lt;font color="#008000"&gt;&amp;lt;!-- TODO: add your code here --&amp;gt;
&lt;/font&gt;  &lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;div&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&lt;/font&gt;  &lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;form&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;body&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;html&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;I have some basic checks at line 8 to see that is this request local and is the connection secure but in order to make this even a bit safe &lt;u&gt;you need to add more checks &lt;/u&gt;to it. &lt;u&gt;If that line fails then everybody who knows the url can execute code with elevated privileges&lt;/u&gt;. So you need to be really careful if you want to use this kind of approach and using code behind class would be much better than this inline example. On lines 12 to 20 I'll just do my fancy SharePoint stuff (in this example I'll just write out title and url of the site).&lt;/p&gt;
&lt;p&gt;On lines 25 to 27 I'll just make the page look like 404 page just in case some of our checks didn't pass. We only want to run this code by the local user. So let see what is the end result:&lt;/p&gt;
&lt;p&gt;For the local user it looks like this (and the user has only normal SharePoint access rights):&lt;/p&gt;
&lt;p&gt;&lt;img height="180" alt="SharePoint Admin task for the local user" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/RunSharePointAdmintaskwithlocalserveruse_102D7/SPAdmin1_02c5169f-2972-45de-bae3-639c5dadbbac.png" width="564" border="0"&gt; &lt;/p&gt;
&lt;p&gt;For the remote user (even with System admin rights):&lt;/p&gt;
&lt;p&gt;&lt;img height="261" alt="SharePoint Admin task for the remote user" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/RunSharePointAdmintaskwithlocalserveruse_102D7/SPAdmin2_bc1d8eb7-c23d-4fb6-ab40-0986621df905.png" width="549" border="0"&gt; &lt;/p&gt;
&lt;p&gt;So this kind of approach is okay for small SharePoint operations but if you need to do more complex and long running operations then you need to reconsider your options. It's a bit hacky approach but it works :-)&lt;br&gt;&lt;br&gt;Anyway... Happy hacking!&lt;br&gt;&lt;br&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7862558" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Microsoft+Office+SharePoint+Server+2007/default.aspx">Microsoft Office SharePoint Server 2007</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category></item><item><title>CRM 4.0, SharePoint and ASP.NET Trace</title><link>http://blogs.msdn.com/jannemattila/archive/2008/02/23/crm-4-0-sharepoint-and-asp-net-trace.aspx</link><pubDate>Sat, 23 Feb 2008 21:12:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7860388</guid><dc:creator>jannemattila</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/7860388.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=7860388</wfw:commentRss><description>&lt;p&gt;Sometimes I tend to forget how much stuff is built into .NET Framework. Framework gives you nice set of features that you can use without writing a single line of code. ASP.NET Trace is one of them. I know that it's nothing new but I think that it's still used mainly in custom ASP.NET applications. But if you work with products like CRM or SharePoint... you kind of forget that those applications are built on top of ASP.NET and you can still benefit from the features that are part of the framework. So let's refresh our memory so that we can use this feature to build better solutions. &lt;/p&gt; &lt;p&gt;See also good post regarding tracing SharePoint in here "&lt;a title="Enabling Page Level Tracing For SharePoint ASPX Forms" href="http://blogs.threewill.com/implementingsharepoint/Lists/Categories/Category.aspx?Name=User%20Interface" target="_blank"&gt;Enabling Page Level Tracing For SharePoint ASPX Forms&lt;/a&gt;".&lt;/p&gt; &lt;p&gt;Okay let's first enable trace at the web.config (same changes apply for CRM and SharePoint):&lt;/p&gt; &lt;table cellspacing="10"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" align="right"&gt;&lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;pre&gt;&lt;font color="#0000ff"&gt;&amp;lt;?&lt;/font&gt;&lt;font color="#a31515"&gt;xml&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;version&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;font color="#0000ff"&gt;1.0&lt;/font&gt;"&lt;font color="#0000ff"&gt;?&amp;gt;
&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;configuration&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
 &amp;lt;!--&lt;/font&gt;&lt;font color="#008000"&gt; ... &lt;/font&gt;&lt;font color="#0000ff"&gt;--&amp;gt;
 &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;system.web&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
  &amp;lt;!--&lt;/font&gt;&lt;font color="#008000"&gt; ... &lt;/font&gt;&lt;font color="#0000ff"&gt;--&amp;gt;
  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;trace&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;requestLimit&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;font color="#0000ff"&gt;100&lt;/font&gt;"&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;enabled&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;font color="#0000ff"&gt;true&lt;/font&gt;"&lt;font color="#0000ff"&gt;/&amp;gt;
  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;compilation&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;debug&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;font color="#0000ff"&gt;true&lt;/font&gt;"&lt;font color="#0000ff"&gt; /&amp;gt;
  &amp;lt;!--&lt;/font&gt;&lt;font color="#008000"&gt; ... &lt;/font&gt;&lt;font color="#0000ff"&gt;--&amp;gt;
 &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;system.web&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
 &amp;lt;!--&lt;/font&gt;&lt;font color="#008000"&gt; ... &lt;/font&gt;&lt;font color="#0000ff"&gt;--&amp;gt;
&amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;configuration&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;So in order to enable the trace you just have to make sure that you have trace (line 6) and debug enabled (line 7). After that you're good to go and trace your application.&lt;/p&gt;
&lt;p&gt;I just retrieved front page from my SharePoint (&lt;em&gt;http://demo1&lt;/em&gt;) and then clicked url to custom application page. Then I typed in the trace url &lt;em&gt;http://demo1/Trace.axd&lt;/em&gt; and checkout the results:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/TracingCRM4.0orSharePoint_A9F6/SPSTrace1_2.png" target="_blank"&gt;&lt;img height="442" alt="SharePoint trace" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/TracingCRM4.0orSharePoint_A9F6/SPSTrace1_thumb.png" width="640" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;And in more detailed (I just clicked the &lt;em&gt;Pages/Default.aspx&lt;/em&gt;):&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/TracingCRM4.0orSharePoint_A9F6/SPSTrace2_2.png" target="_blank"&gt;&lt;img height="671" alt="SharePoint trace detailed" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/TracingCRM4.0orSharePoint_A9F6/SPSTrace2_thumb.png" width="650" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;And same thing works with CRM 4.0 too... but remember that it's &lt;strong&gt;unsupported&lt;em&gt; &lt;/em&gt;to modify web.config in CRM&lt;/strong&gt; so create back up copy so that you can restore the original file when you need to clean up your modifications.&lt;/p&gt;
&lt;p&gt;In my CRM I opened url &lt;em&gt;http://crmserver/Contoso&lt;/em&gt; to goto tenant named &lt;em&gt;Contoso.&lt;/em&gt; After that I used my custom aspx page from &lt;em&gt;ISV&lt;/em&gt;-folder. And then I checked the trace:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/TracingCRM4.0orSharePoint_A9F6/CRMTrace1_2.png" target="_blank"&gt;&lt;img height="301" alt="CRM Trace" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/TracingCRM4.0orSharePoint_A9F6/CRMTrace1_thumb.png" width="640" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;And if you look at more detailed view of the trace:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/TracingCRM4.0orSharePoint_A9F6/CRMTrace2_2.png" target="_blank"&gt;&lt;img height="430" alt="CRM Trace details" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/TracingCRM4.0orSharePoint_A9F6/CRMTrace2_thumb.png" width="640" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;And you can easily see the amount of stuff that is put into the application state and especially for &lt;em&gt;CRMWindowInfo_CacheKey&lt;/em&gt;. Using this technique you can find e.g performance issues in your code quite easily.&lt;/p&gt;
&lt;p&gt;I actually used this method to debug some AJAX and web services issues and it worked really well because I could check out from the trace what has happened and when. &lt;/p&gt;
&lt;p&gt;To summarize.... you should refresh your memory about things that you get straight from the platform. It can save lot of your time. At least it happened to me :-)&lt;br&gt;&lt;br&gt;&lt;br&gt;Anyways... Happy hacking!&lt;br&gt;&lt;br&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7860388" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Microsoft+Office+SharePoint+Server+2007/default.aspx">Microsoft Office SharePoint Server 2007</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Microsoft+CRM/default.aspx">Microsoft CRM</category></item><item><title>Comparing two databases (schema and/or data)</title><link>http://blogs.msdn.com/jannemattila/archive/2008/02/13/comparing-two-databases-schema-and-or-data.aspx</link><pubDate>Wed, 13 Feb 2008 22:28:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7679505</guid><dc:creator>jannemattila</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/7679505.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=7679505</wfw:commentRss><description>&lt;p&gt;Quite often people like to know what's happening under the covers when they do something through user interface. For example they use CRM, SharePoint or some other product through user interface and they would like to know what has happened at the database. Normally my answer is that you don't need to know that because "&lt;em&gt;Don't touch the database rule still applies&lt;/em&gt;" but this time I have different answer :-) &lt;/p&gt; &lt;p&gt;I'll shortly explain how can you check that stuff yourself using Visual Studio 2008 and &lt;em&gt;Schema compare&lt;/em&gt; and/or &lt;em&gt;Data compare&lt;/em&gt; functionalities. But it's important to understand that this kind of approach shouldn't be ever executed against production databases. So you really need to have separate dev environment (and databases) for this kind of testing.&lt;/p&gt; &lt;p&gt;Now we're ready to go. I'll use Microsoft CRM 4.0 in my example. I have created two tenants and named them &lt;em&gt;Demo&lt;/em&gt; and &lt;em&gt;DemoEmpty&lt;/em&gt;. And that of course means that I have databases &lt;em&gt;Demo_MSCRM&lt;/em&gt; and &lt;em&gt;DemoEmpty_MSCRM&lt;/em&gt; at my SQL Server. If I now start up my Visual Studio 2008 and connect those two databases to the server explorer and start playing around with this (&lt;em&gt;Data -&amp;gt; Schema Compare -&amp;gt; New Schema Comparison...&lt;/em&gt;):&lt;/p&gt; &lt;p&gt;&lt;img height="209" alt="VSMenuSchemaCompare" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/VSMenuSchemaCompare_b26b5932-3e44-4471-99ce-8254b0dd4146.png" width="617" border="0"&gt; &lt;/p&gt; &lt;p&gt;Then I get this dialog and select those two databases (&lt;strong&gt;NOTE&lt;em&gt;: &lt;/em&gt;Right hand side is the target database!&lt;/strong&gt;):&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/VSMenuSchemaCompare2_2.png" target="_blank"&gt;&lt;img height="291" alt="VSMenuSchemaCompare2" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/VSMenuSchemaCompare2_thumb.png" width="640" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;And when I click the &lt;em&gt;OK&lt;/em&gt;-button the Visual Studio starts crawling the two databases and then creates list of differences:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/VSMenuSchemaCompare3_2.png" target="_blank"&gt;&lt;img height="148" alt="VSMenuSchemaCompare3" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/VSMenuSchemaCompare3_thumb.png" width="640" border="0"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Currently we're not yet interested at the differences since we just want to make the databases equal. So I just pressed &lt;em&gt;Write updates&lt;/em&gt; button from the toolbar to make the &lt;em&gt;DemoEmpty_MSCRM&lt;/em&gt; same as the &lt;em&gt;Demo_MSCRM &lt;/em&gt;(remember &lt;em&gt;DemoEmpty&lt;/em&gt; was the target database). Obviously this makes my &lt;em&gt;DemoEmpty&lt;/em&gt; database useless but I use it only to track changes at the &lt;em&gt;Demo&lt;/em&gt; database. &lt;/p&gt; &lt;p&gt;I also used &lt;em&gt;Data Compare -&amp;gt; New Data Comparison...&lt;/em&gt; so that both databases would then have same content (of course you can achieve this same with backup/restore but it's not as fun as this approach!):&lt;/p&gt; &lt;p&gt;&lt;img height="149" alt="VSDataComparepng" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/VSDataComparepng_dd13296d-c796-4bda-8c93-255a1a3205fe.png" width="400" border="0"&gt; &lt;/p&gt; &lt;p&gt;Now if I refresh the &lt;em&gt;Schema compare&lt;/em&gt; we'll get this view:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/VSSchemaCompare_2.png" target="_blank"&gt;&lt;img height="366" alt="VSSchemaCompare" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/VSSchemaCompare_thumb.png" width="640" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Or closer view of the &lt;em&gt;schema compare&lt;/em&gt;:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/VSMenuSchemaCompare4_3.png" target="_blank"&gt;&lt;img height="399" alt="VSMenuSchemaCompare4" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/VSMenuSchemaCompare4_thumb.png" width="640" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;We can easily see that our database schemas are equal since the &lt;em&gt;Status &lt;/em&gt;is &lt;em&gt;Equal &lt;/em&gt;for the tables and &lt;em&gt;Update Action &lt;/em&gt;is set to &lt;em&gt;Skip&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;And now we're finally ready to go to the user interface for the tenant &lt;em&gt;Demo&lt;/em&gt; and make some changes. I'll type &lt;em&gt;&lt;u&gt;http://crmserver/Demo&lt;/u&gt;&lt;/em&gt; into my browser and go to the &lt;em&gt;Settings &lt;/em&gt;and &lt;em&gt;Customization -&amp;gt; Customize Entities&lt;/em&gt;. And I'll just add new custom entity called &lt;em&gt;MyDemo&lt;/em&gt; (how original name!) and it makes my entity name &lt;em&gt;new_demo&lt;/em&gt; (since I didn't even change the default prefix... and this is just lazyness I know!):&lt;/p&gt; &lt;p&gt;&lt;img height="246" alt="CRMMyDemoEntity" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/CRMMyDemoEntity_8fa9bd37-68a2-45f7-86d3-0aac435aa6c0.png" width="670" border="0"&gt; &lt;/p&gt; &lt;p&gt;After I have saved my new entity I'm ready to re-run the &lt;em&gt;Schema compare&lt;/em&gt;:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/VSNewEntitySchemaChange_2.png" target="_blank"&gt;&lt;img height="590" alt="VSNewEntitySchemaChange" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/Comparingdatabaseschemaandordata_B87C/VSNewEntitySchemaChange_thumb.png" width="679" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;And of course the changes we're something that you could expect... two new tables called &lt;em&gt;New_demoBase&lt;/em&gt; and &lt;em&gt;New_demoExtensionBase&lt;/em&gt;. If you look at the definitions:&lt;/p&gt; &lt;p&gt;&lt;em&gt;New_demoBase&lt;/em&gt;:&lt;/p&gt; &lt;table cellspacing="10"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" align="right"&gt;&lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;pre&gt;&lt;font color="#008000"&gt;-- Columns
&lt;/font&gt;&lt;font color="#0000ff"&gt;CREATE TABLE &lt;/font&gt;[dbo].[New_demoBase]
(
[New_demoId] [uniqueidentifier] &lt;font color="#0000ff"&gt;NOT NULL&lt;/font&gt;,
[CreatedOn] [datetime] &lt;font color="#0000ff"&gt;NULL&lt;/font&gt;,
[CreatedBy] [uniqueidentifier] &lt;font color="#0000ff"&gt;NULL&lt;/font&gt;,
[ModifiedOn] [datetime] &lt;font color="#0000ff"&gt;NULL&lt;/font&gt;,
[ModifiedBy] [uniqueidentifier] &lt;font color="#0000ff"&gt;NULL&lt;/font&gt;,
[OwningUser] [uniqueidentifier] &lt;font color="#0000ff"&gt;NULL&lt;/font&gt;,
[OwningBusinessUnit] [uniqueidentifier] &lt;font color="#0000ff"&gt;NULL&lt;/font&gt;,
[statecode] [int] &lt;font color="#0000ff"&gt;NOT NULL&lt;/font&gt;,
[statuscode] [int] &lt;font color="#0000ff"&gt;NULL&lt;/font&gt;,
[DeletionStateCode] [int] &lt;font color="#0000ff"&gt;NULL&lt;/font&gt;,
[VersionNumber] [timestamp] &lt;font color="#0000ff"&gt;NULL&lt;/font&gt;,
[ImportSequenceNumber] [int] &lt;font color="#0000ff"&gt;NULL&lt;/font&gt;,
[OverriddenCreatedOn] [datetime] &lt;font color="#0000ff"&gt;NULL&lt;/font&gt;,
[TimeZoneRuleVersionNumber] [int] &lt;font color="#0000ff"&gt;NULL&lt;/font&gt;,
[UTCConversionTimeZoneCode] [int] &lt;font color="#0000ff"&gt;NULL
&lt;/font&gt;) &lt;font color="#0000ff"&gt;ON &lt;/font&gt;[PRIMARY]
&lt;font color="#008000"&gt;-- ...&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;&lt;em&gt;New_demoExtensionBase&lt;/em&gt;:&lt;/p&gt;
&lt;table cellspacing="10"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" align="right"&gt;&lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;pre&gt;&lt;font color="#008000"&gt;-- Columns
&lt;/font&gt;&lt;font color="#0000ff"&gt;CREATE TABLE &lt;/font&gt;[dbo].[New_demoExtensionBase]
(
[New_demoId] [uniqueidentifier] &lt;font color="#0000ff"&gt;NOT NULL&lt;/font&gt;,
[New_name] [nvarchar] (100) &lt;font color="#0000ff"&gt;COLLATE &lt;/font&gt;Latin1_General_CI_AI &lt;font color="#0000ff"&gt;NULL
&lt;/font&gt;) &lt;font color="#0000ff"&gt;ON &lt;/font&gt;[PRIMARY]&lt;br&gt;&lt;font color="#008000"&gt;-- ...&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;You'll understand that actually only those base CRM columns are at the &lt;em&gt;New_demoBase&lt;/em&gt; table and all the other (1 in my case since I was lazy and didn't add more fields :-) fields are at the &lt;em&gt;New_demoExtensionBase&lt;/em&gt; table. Of course there are other important changes too like the two new views: &lt;em&gt;FilteredNew_demo&lt;/em&gt; and &lt;em&gt;New_demo&lt;/em&gt;. &lt;em&gt;FilteredNew_demo &lt;/em&gt;is view that uses the users rights to retrieve data... so it automatically filters out all the rows that user doesn't have access to (that's why it's called &lt;em&gt;Filtered&lt;/em&gt; :-). And the other view just combines the two tables (&lt;em&gt;Base&lt;/em&gt; + &lt;em&gt;ExtensionBase&lt;/em&gt;) together.&lt;/p&gt;
&lt;p&gt;But this was just small example how you could compare databases and see what is happening at your application. Remember to use this compare tool carefully... because you could easily make you target database useless... so it would be wise to create backup before playing around with it.&lt;br&gt;&lt;br&gt;Anyways... Happy hacking!&lt;br&gt;&lt;br&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7679505" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Microsoft+CRM/default.aspx">Microsoft CRM</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Catching unhandled exceptions in SharePoint</title><link>http://blogs.msdn.com/jannemattila/archive/2008/02/04/catching-unhandled-exceptions-in-sharepoint.aspx</link><pubDate>Mon, 04 Feb 2008 19:13:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7440474</guid><dc:creator>jannemattila</dc:creator><slash:comments>19</slash:comments><comments>http://blogs.msdn.com/jannemattila/comments/7440474.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jannemattila/commentrss.aspx?PostID=7440474</wfw:commentRss><description>&lt;p&gt;If you have done some dev stuff with MOSS you have most likely seen this:&lt;/p&gt; &lt;p&gt;&lt;img height="191" alt="UnexpectedError" src="http://blogs.msdn.com/blogfiles/jannemattila/WindowsLiveWriter/UnhandledexceptionsinSharePoint_E4E3/UnexpectedError_f71ed40f-d19b-4a3b-b328-58e6dd79b9d7.png" width="402" border="0"&gt; &lt;/p&gt; &lt;p&gt;"&lt;em&gt;An unexpected error has occurred. &lt;/em&gt;" is something that you probably don't want to see at your browser.... you want to have customized error page. In ASP.NET application you normally put &lt;em&gt;Application_Error&lt;/em&gt; into you &lt;em&gt;global.asax &lt;/em&gt;file. However in SharePoint that place has been taken by the product itself :-) So if you want to do customized approach then you can take &lt;em&gt;HttpModule&lt;/em&gt; approach which I'm going to go through in this post. &lt;/p&gt; &lt;p&gt;So let's create our custom exception handler http module. Here's the code for that:&lt;/p&gt; &lt;table cellspacing="10"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" align="right"&gt;&lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;pre&gt;&lt;font color="#0000ff"&gt;using&lt;/font&gt; System;
&lt;font color="#0000ff"&gt;using&lt;/font&gt; System.Web;

&lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;class&lt;/font&gt; &lt;font color="#2b91af"&gt;MyExceptionHandler&lt;/font&gt; : &lt;font color="#2b91af"&gt;IHttpModule
&lt;/font&gt;{
  &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;void&lt;/font&gt; Dispose()
  {
  }

  &lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#0000ff"&gt;void&lt;/font&gt; Init(&lt;font color="#2b91af"&gt;HttpApplication&lt;/font&gt; context)
  {
    context.Error += &lt;font color="#0000ff"&gt;new&lt;/font&gt; &lt;font color="#2b91af"&gt;EventHandler&lt;/font&gt;(context_Error);
  }

  &lt;font color="#0000ff"&gt;void&lt;/font&gt; context_Error(&lt;font color="#0000ff"&gt;object&lt;/font&gt; sender, &lt;font color="#2b91af"&gt;EventArgs&lt;/font&gt; e)
  {
    &lt;font color="#2b91af"&gt;Exception&lt;/font&gt;[] unhandledExceptions = &lt;font color="#2b91af"&gt;HttpContext&lt;/font&gt;.Current.AllErrors;

    &lt;font color="#0000ff"&gt;foreach&lt;/font&gt; (&lt;font color="#2b91af"&gt;Exception&lt;/font&gt; ex &lt;font color="#0000ff"&gt;in&lt;/font&gt; unhandledExceptions)
    {
      &lt;font color="#008000"&gt;// TODO: log your errors
&lt;/font&gt;    }

    &lt;font color="#2b91af"&gt;HttpContext&lt;/font&gt;.Current.Server.ClearError();
    &lt;font color="#2b91af"&gt;HttpContext&lt;/font&gt;.Current.Response.Clear();
    &lt;font color="#2b91af"&gt;HttpContext&lt;/font&gt;.Current.Server.Transfer(&lt;font color="#a31515"&gt;"/_layouts/MyCustomErrorPage.aspx"&lt;/font&gt;);
  }
}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;You can probably see from the code that I'll attach my code to the &lt;em&gt;Error&lt;/em&gt; event and in my event I'll do some basic stuff and then transfer to my &lt;em&gt;MyCustomErrorPage.aspx.&lt;/em&gt; I used &lt;em&gt;Server.Transfer &lt;/em&gt;just because I want user to stay at the same url where exception happened. If I would use &lt;em&gt;Response.Redirect&lt;/em&gt; it would "change" the url at the users browser. Same "change" would happen if your custom error page would be normal SharePoint publishing page (i.e. &lt;em&gt;/Pages/MyCustomErrorPage.aspx&lt;/em&gt;). If the url stays the same the user can actually press F5 and retry the operation right away. Of course it can be bad thing too and you may want to redirect to another page to avoid creating the same exception all over again. I'll let you decide what you want :-) So do some testing and then decide what's good for you. &lt;/p&gt;
&lt;p&gt;But one important thing to notice. You need to put your &lt;em&gt;IHttpModule&lt;/em&gt; before SharePoint specific modules in your &lt;em&gt;web.config&lt;/em&gt; or otherwise your error routines may not work as you would expect. Here's example from that:&lt;/p&gt;
&lt;table cellspacing="10"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" align="right"&gt;&lt;pre&gt;&lt;font color="gray"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;pre&gt;&lt;font color="#0000ff"&gt;&amp;lt;?&lt;/font&gt;&lt;font color="#a31515"&gt;xml&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;version&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;font color="#0000ff"&gt;1.0&lt;/font&gt;"&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;encoding&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;font color="#0000ff"&gt;UTF-8&lt;/font&gt;"&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;standalone&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;font color="#0000ff"&gt;yes&lt;/font&gt;"&lt;font color="#0000ff"&gt;?&amp;gt;
&amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;configuration&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
 &amp;lt;!--&lt;/font&gt;&lt;font color="#008000"&gt; ... &lt;/font&gt;&lt;font color="#0000ff"&gt;--&amp;gt;
  &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;httpModules&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;
   &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;clear&lt;/font&gt;&lt;font color="#0000ff"&gt; /&amp;gt;
   &lt;strong&gt;&amp;lt;&lt;/strong&gt;&lt;/font&gt;&lt;strong&gt;&lt;font color="#a31515"&gt;add&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;name&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;font color="#0000ff"&gt;MyExceptionHandler&lt;/font&gt;"&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;/strong&gt;&lt;strong&gt;&lt;font color="#0000ff"&gt;MyExceptionHandler,Example, 
      Version=1.0.0.0, Culture=neutral,PublicKeyToken=34a2bd01f6f6eb10&lt;/font&gt;"&lt;/strong&gt;&lt;font color="#0000ff"&gt;&lt;strong&gt; /&amp;gt;&lt;/strong&gt;
   &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;add&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;name&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;font color="#0000ff"&gt;SPRequest&lt;/font&gt;"&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;font color="#0000ff"&gt;Microsoft.SharePoint.ApplicationRuntime.SPRequestModule, 
      Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&lt;/font&gt;"&lt;font color="#0000ff"&gt; /&amp;gt;
   &amp;lt;&lt;/font&gt;&lt;font color="#a31515"&gt;add&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;name&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;font color="#0000ff"&gt;OutputCache&lt;/font&gt;"&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;"&lt;font color="#0000ff"&gt;System.Web.Caching.OutputCacheModule&lt;/font&gt;"&lt;font color="#0000ff"&gt; /&amp;gt;
   &amp;lt;!--&lt;/font&gt;&lt;font color="#008000"&gt; ... &lt;/font&gt;&lt;font color="#0000ff"&gt;--&amp;gt;

  &amp;lt;/&lt;/font&gt;&lt;font color="#a31515"&gt;configuration&lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;See line 6 where I put my exception handler definition. &lt;br&gt;&lt;br&gt;Anyways... Happy hacking!&lt;br&gt;&lt;br&gt;J&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7440474" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Microsoft+Office+SharePoint+Server+2007/default.aspx">Microsoft Office SharePoint Server 2007</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/tips+and+tricks/default.aspx">tips and tricks</category><category domain="http://blogs.msdn.com/jannemattila/archive/tags/Programming/default.aspx">Programming</category></item></channel></rss>