<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ankit Jain &#187; Microsoft</title>
	<atom:link href="http://ankitjain.info/ankit/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://ankitjain.info/ankit</link>
	<description>» It’s all about Ankit and Web! «</description>
	<lastBuildDate>Mon, 28 Jun 2010 06:28:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Visual Studio &#8211; Database Project Not Loading</title>
		<link>http://ankitjain.info/ankit/2008/05/05/visual-studio-database-project-not-loading/</link>
		<comments>http://ankitjain.info/ankit/2008/05/05/visual-studio-database-project-not-loading/#comments</comments>
		<pubDate>Mon, 05 May 2008 14:50:51 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Programming/Code]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/2008/05/05/visual-studio-database-project-not-loading</guid>
		<description><![CDATA[Have you ever created a Database project and after some time you are not able to load it in the Visual Studio? Probably you might be getting following error: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">Have you ever created a Database project and after some time you are not able to load it in the Visual Studio?  Probably you might be getting following error:</p>
<blockquote>
<p class="MsoNormal">An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 &#8211; Error Locating Server/Instance Specified)</p>
</blockquote>
<p class="MsoNormal">The database project requires an active database connection to load at design time. Probably it uses that to compile/verify scripts. The problem here is Visual Studio is not able to connect to any such instance. Following are few solutions (these worked for me)</p>
<ol type="1" style="margin-top: 0in" start="1">
<li class="MsoNormal">Make sure the instance to which you want to connect is running and allows remote connections.</li>
<li class="MsoNormal">After performing step 1, if it is still not loading then you may need to start the SQL Browser Service. Make sure it&#8217;s running.</li>
<li class="MsoNormal">If the problem is still there, it has to be fixed from Visual Studio itself. Actually database project do not store to which instance it can connect. It&#8217;s a Visual Studio setting.In VS2008 go to Tool > Options > Database Tools > Design-time Validation Database > Connection Options. Specify your instance name here like &#8220;\SQLEXPRESS&#8221;</li>
</ol>
<p class="MsoNormal">If the problem is still there post it to <a title="Visual Studio Team System - Database Professionals" target="_blank" href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=725&#038;SiteID=1">MSDN forums</a> <img src='http://ankitjain.info/ankit/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p class="MsoNormal">Ankit</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2008/05/05/visual-studio-database-project-not-loading/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Checklist: Cannot import webpart</title>
		<link>http://ankitjain.info/ankit/2007/09/16/sharepoint-webpart-import-error/</link>
		<comments>http://ankitjain.info/ankit/2007/09/16/sharepoint-webpart-import-error/#comments</comments>
		<pubDate>Sun, 16 Sep 2007 11:36:29 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[MOSS 2007]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[webpart]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/2007/09/16/sharepoint-webpart-import-error</guid>
		<description><![CDATA[While importing (drag/drop) your webpart to any SharePoint page, if you receive an error stating &#8220;Cannot import webpart&#8221; or &#8220;unable to add selected web part(s)&#8221;! here is the check list you should look for: Make sure the webpart class is inherited either from Microsoft.SharePoint.WebPartPages.WebPart or System.Web.UI.WebControls.WebParts.WebPart The webpart class needs to be declared public. Safe [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">While importing (drag/drop) your webpart to any SharePoint page, if you receive an error stating &#8220;Cannot import webpart&#8221; or &#8220;unable to add selected web part(s)&#8221;! here is the check list you should look for:</p>
<ol type="1" start="1" style="margin-top: 0in">
<li class="MsoNormal">Make sure the webpart class is inherited either from <span style="font-style: italic">Microsoft.SharePoint.WebPartPages.WebPart</span>  or <em>System.Web.UI.WebControls.WebParts.WebPart</em></li>
<li class="MsoNormal"><strong>The webpart class needs to be declared public.</strong></li>
<li class="MsoNormal">Safe controls entry in web.config file.</li>
<li class="MsoNormal">If you are referring a webpart from GAC (i.e. assembly containing webpart class is placed in GAC) make sure the GAC version is the latest build and IIS is re-started.</li>
</ol>
<p class="MsoNormal">- Ankit</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2007/09/16/sharepoint-webpart-import-error/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SharePoint: ServerContext not set to an instance</title>
		<link>http://ankitjain.info/ankit/2007/09/16/server-context-not-set-instance/</link>
		<comments>http://ankitjain.info/ankit/2007/09/16/server-context-not-set-instance/#comments</comments>
		<pubDate>Sun, 16 Sep 2007 11:21:46 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[MOSS 2007]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[solution]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/2007/09/16/server-context-not-set-instance</guid>
		<description><![CDATA[I was playing through SharePoint object model and somewhere (donâ€™t remember right now!) got an exception stating â€œServerContext not set to an instanceâ€. My solution for this: Installed SSP (Shared Services Provider) and this problem is solved! [ Edited:2008-03-24 I got this error while playing with stsadm.exe command ]]]></description>
			<content:encoded><![CDATA[<p>I was playing through SharePoint object model and somewhere (donâ€™t remember right now!) got an exception stating â€œServerContext not set to an instanceâ€.</p>
<p>My solution for this: Installed SSP (Shared Services Provider) and this problem is solved!<br />
[ <em>Edited:2008-03-24</em><br />
 I got this error while playing with stsadm.exe command<br />
]</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2007/09/16/server-context-not-set-instance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows CardSpace: FAQ for ASP.NET Developers</title>
		<link>http://ankitjain.info/ankit/2007/06/19/windows-infocard-faq-developers/</link>
		<comments>http://ankitjain.info/ankit/2007/06/19/windows-infocard-faq-developers/#comments</comments>
		<pubDate>Tue, 19 Jun 2007 18:27:39 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[.net 3.0]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Programming/Code]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/2007/06/19/windows-infocard-faq-developers</guid>
		<description><![CDATA[Few frequently asked question for ASP.NET developers: The Identity Selector dialog box is displayed only for SSL protected pages. Therefore you are required to deploy your application on a Web server and install a SSL Certificate. Windows CardSpace does not work with Self Signed Certificates and will die horribly. These certificates do not have CRL [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">Few frequently asked question for ASP.NET developers:</p>
<ol type="1" style="margin-top: 0in" start="1">
<li class="MsoNormal">The Identity Selector dialog      box is displayed only for SSL protected pages. Therefore you are required      to deploy your application on a Web server and <a target="_blank" href="http://www.microsoft.com/technet/prodtechnol/windowsserver2003/library/iis/56bdf977-14f8-4867-9c51-34c346d48b04.mspx">install a SSL Certificate</a>.</li>
<li class="MsoNormal">Windows CardSpace does not      work with Self Signed Certificates and <span lang="EN">will die horribly</span>. These certificates <a target="_blank" href="http://idunno.org/archive/2007/04/06/Self-signed-Certificates-and-CardSpace.aspx">do not have CRL field</a>. It contains a <span lang="EN">URL that CardSpace will check for the      revocation list</span>.</li>
<li class="MsoNormal">For ASP.NET developers      there is Toolbox control written by <a target="_blank" href="http://www.codecomplete.de/blogs/digitalidentity/archive/2007/03/18/visual-studio-2005-toolbox-for-windows-cardspace.aspx">Christian Arnold</a>. Add this to your Toolbox and you won&#8217;t need to write a single line of code. <a target="_blank" href="http://www.codecomplete.de/blogs/digitalidentity/archive/2007/04/11/demo-video-use-windows-cardspace-and-the-visual-studio-toolbox-for-windows-cardspace.aspx">Watch demo</a>.</li>
<li class="MsoNormal">When you use CardSpaceLogin controls you must run application over SSL. The application pool also need to be run under <strong>Local System</strong>s identify;      otherwise <em>w3wp.exe</em> process will not be able to retrieve server&#8217;s private key. In such case you may end up with error stating <em>Keyset does not exist</em>. <span style="color: red">Note: This is not advisory if the application pool is shared with other Web applications. </span> [ Edited: Refer Barry Dorrans comment for more <a target="_blank" href="http://idunno.org/archive/2007/07/01/giving-your-web-site-process-access-to-your-ssl-certificate.aspx">details</a>.]</li>
<li class="MsoNormal">When using Information cards there is nothing like <em>passwords</em>.</li>
<li class="MsoNormal">CardSpaceLogin controls are integrated with your identify providers such as Forms Authentication. For example: If you use Information Card to register a user, his details are reflected in the identify source.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2007/06/19/windows-infocard-faq-developers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>TFS &#8211; Free Text search in History Objects</title>
		<link>http://ankitjain.info/ankit/2007/05/29/tfs-free-text-search-in-history-objects/</link>
		<comments>http://ankitjain.info/ankit/2007/05/29/tfs-free-text-search-in-history-objects/#comments</comments>
		<pubDate>Tue, 29 May 2007 07:52:33 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Programming/Code]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[tfs]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/2007/05/29/tfs-%e2%80%93-free-text-search-in-history-objects</guid>
		<description><![CDATA[It&#8217;s a best practice to add comment when you do check-in to the source control. A text comment is associated with the change you made to the item. Some of the times you need to find a particular comment, but the View History tool available with Visual Studio/TFS is limited that you can&#8217;t make a [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a best practice to add comment when you do check-in to the source control. A text comment is associated with the change you made to the item. Some of the times you need to find a particular comment, but the <em>View History</em> tool available with Visual Studio/TFS is limited that you can&#8217;t make a search in the history results. Say you want to find all check-ins by a particular user <img src='http://ankitjain.info/ankit/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><img alt="History Tool in Visual Studio 2005" src="http://ankitjain.info/ankit/wp-content/052907_0752_TFSFreeText12.png" /></p>
<p>Here comes the purpose of this small add-in. It provides search within history comments and find a particular change-set instead of traversing the whole list. The plug-in goes one step forward and facilitates free text search in change-set fields. For example you can use change-set id, username or even date-time as search keywords!!!</p>
<p>The major steps involved in developing this add-in are:</p>
<ol>
<li>Writing an add-in for Visual Studio 2005,</li>
<li>Getting file history from Team Foundation Server (TFS),</li>
<li>Look for the selected item in the Visual Studio IDE,</li>
<li>Free text search along with the tools to compare two files.</li>
</ol>
<p><span id="more-97"></span></p>
<p>Visual Studio 2005 provides templates to build add-ins in few minutes. Refer <a target="_blank" href="http://www.devx.com/vstudioextensibility/Article/31354">www.devx.com</a> for step-by-step guide for building Visual Studio app-ins. Additionally, you can download <a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=79c7e038-8768-4e1e-87ae-5bbbe3886de8&#038;displaylang=en">Visual Studio 2005 Automation Samples</a> for detailed code illustrations with documentation.</p>
<p>Once you have completed the <em>Visual Studio Add-in wizard</em> the IDE generates <span style="font-family: Courier New; font-size: 10pt">Connect.cs</span> file and dumps some code for basic functionality. The next step is to retrieve history from the TFS for selected file. Refer my previous post, <a href="http://ankitjain.info/ankit/2006/12/13/tfs-version-control-build-history">Fetching file history from TFS</a> to find out how to fetch file history objects from Version Control Server.</p>
<p>Moving forward we need to find out the currently selected item in the Visual Studio IDE. Visual Studio exposes various properties/objects allowing you to query almost any UI controls and get their status.  The following code first finds the active window. If it is Source Control Explorer and then looks for the selected item within the same.</p>
<p><!--<br />
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;\red0\green128\blue0;\red163\green21\blue21;}??\fs20 \cf1 public\cf0  \cf1 static\cf0  \cf1 void\cf0  GetServerUriAndItemPath(\cf4 DTE2\cf0  appObj, \cf1 ref\cf0  \cf1 string\cf0  serverUri, \cf1 ref\cf0  \cf1 string\cf0  itemPath, \cf1 ref\cf0  \cf1 bool\cf0  isFolder)\par ??\{\par ??    isFolder = \cf1 false\cf0 ;\par ??\par ??    \cf5 // Get local workspace info\par ??\cf0     \cf4 WorkspaceInfo\cf0 [] wsInfo = \cf4 Workstation\cf0 .Current.GetAllLocalWorkspaceInfo();\par ??    \cf1 if\cf0  (wsInfo.Length == 0)\par ??        \cf1 throw\cf0  \cf1 new\cf0  \cf4 TFSHistorySearchException\cf0 (\cf6 "No workspace found."\cf0 );\par ??\par ??    \cf5 // Get server Uri\par ??\cf0     serverUri = wsInfo[0].ServerUri.AbsoluteUri;\par ??\par ??    \cf5 //\'a0Get\'a0a\'a0reference\'a0to the\'a0Team\'a0Foundation\'a0Server. \par ??\cf0     \cf4 TeamFoundationServer\cf0  tfs = \cf1 new\cf0  \cf4 TeamFoundationServer\cf0 (serverUri);\par ??    \cf4 VersionControlServer\cf0  vcs = tfs.GetService(\cf1 typeof\cf0 (\cf4 VersionControlServer\cf0 )) \cf1 as\cf0  \cf4 VersionControlServer\cf0 ;\par ??\par ??    \cf5 //if Active Window is Source Control Explorer\par ??\cf0     \cf1 if\cf0  (appObj.ActiveWindow.Caption.StartsWith(\cf6 "Source Control Explorer"\cf0 ))\par ??    \{\par ??        \cf4 VersionControlExt\cf0  vce;\par ??        \cf5 // The top level class used to access all other Team Foundation Version Control Extensiblity classes\par ??\cf0         vce = appObj.GetObject(\cf6 "Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt"\cf0 ) \cf1 as\cf0  \cf4 VersionControlExt\cf0 ;\par ??\par ??        \cf1 if\cf0  (!vce.Explorer.Connected)\par ??        \{\par ??            \cf1 throw\cf0  \cf1 new\cf0  \cf4 TFSHistorySearchException\cf0 (\cf6 "Source control explorer is not connected to a Team Foundation Server"\cf0 );\par ??        \}\par ??\par ??        \cf5 // Get all selected items\par ??\cf0         \cf4 VersionControlExplorerItem\cf0  []selectedItems = vce.Explorer.SelectedItems;\par ??\par ??        \cf1 if\cf0  (selectedItems.Length == 0)\par ??            \cf1 throw\cf0  \cf1 new\cf0  \cf4 TFSHistorySearchException\cf0 (\cf6 "You must select one item."\cf0 );\par ??\par ??        \cf1 if\cf0  (selectedItems.Length &amp;amp;gt; 1)\par ??            \cf1 throw\cf0  \cf1 new\cf0  \cf4 TFSHistorySearchException\cf0 (\cf6 "Multiple items selected."\cf0 );\par ??\par ??        \cf1 if\cf0  (selectedItems[0].SourceServerPath.Equals(\cf6 "$/"\cf0 ))\par ??            \cf1 throw\cf0  \cf1 new\cf0  \cf4 TFSHistorySearchException\cf0 (\cf6 "Operation is not supported for the selected item."\cf0 );\par ??        \cf5 //Take the 1st item\par ??\cf0         itemPath = selectedItems[0].SourceServerPath;\par ??        isFolder = selectedItems[0].IsFolder;\par ??    \}\par ??    \cf5 //if Active Window is Solution Explorer\par ??\cf0     \cf1 else\cf0  \cf1 if\cf0  (appObj.ActiveWindow.Caption.StartsWith(\cf6 "Solution Explorer"\cf0 ))\par ??    \{\par ??        isFolder = \cf1 false\cf0 ;\par ??        \cf1 if\cf0  (appObj.SelectedItems.MultiSelect == \cf1 true\cf0 )\par ??            \cf1 throw\cf0  \cf1 new\cf0  \cf4 TFSHistorySearchException\cf0 (\cf6 "Multiple items selected."\cf0 );\par ??\par ??        \cf4 SelectedItem\cf0  selectedItem = appObj.SelectedItems.Item(1);\par ??\par ??        \cf4 SourceControl2\cf0  sc = (\cf4 SourceControl2\cf0 )appObj.SourceControl;\par ??\par ??        \cf1 string\cf0  fileName = \cf4 String\cf0 .Empty;\par ??        \cf1 if\cf0  (selectedItem.ProjectItem != \cf1 null\cf0 )\par ??        \{\par ??            \cf5 //Its a project file\par ??\cf0             fileName = selectedItem.ProjectItem.Properties.Item(\cf6 "URL"\cf0 ).Value.ToString();\par ??            fileName = \cf4 Regex\cf0 .Replace(fileName, \cf6 "file:///"\cf0 , \cf4 String\cf0 .Empty, \cf4 RegexOptions\cf0 .IgnoreCase);\par ??            \cf1 if\cf0  (fileName.EndsWith(\cf6 "\\\\"\cf0 ))\par ??            \{\par ??                fileName = fileName.Substring(0, fileName.LastIndexOf(\cf6 '\\\\'\cf0 ));\par ??                isFolder = \cf1 true\cf0 ;\par ??            \}\par ??            \cf1 try\par ??\cf0             \{\par ??                \cf4 Item\cf0  item = vcs.GetItem(fileName);\par ??                itemPath = item.ServerItem;\par ??            \}\par ??            \cf1 catch\cf0  (Microsoft.TeamFoundation.VersionControl.Client.\cf4 VersionControlException\cf0  ex)\par ??            \{\par ??                \cf1 throw\cf0  \cf1 new\cf0  \cf4 TFSHistorySearchException\cf0 (\cf6 "Item not under source control."\cf0 , ex);\par ??            \}\par ??        \}\par ??        \cf1 else\cf0  \cf1 if\cf0  (selectedItem.Project != \cf1 null\cf0 )\par ??        \{\par ??            \cf5 //Its a project\par ??\cf0             fileName = selectedItem.Project.FileName;\par ??            \cf1 try\par ??\cf0             \{\par ??                \cf4 Item\cf0  item = vcs.GetItem(fileName);\par ??                itemPath = item.ServerItem;\par ??            \}\par ??            \cf1 catch\cf0  (Microsoft.TeamFoundation.VersionControl.Client.\cf4 VersionControlException\cf0  ex)\par ??            \{\par ??                \cf1 throw\cf0  \cf1 new\cf0  \cf4 TFSHistorySearchException\cf0 (\cf6 "Item not under source control."\cf0 , ex);\par ??            \}\par ??        \}\par ??        \cf1 else\par ??\cf0         \{\par ??            \cf1 throw\cf0  \cf1 new\cf0  \cf4 TFSHistorySearchException\cf0 (\cf6 "Operation is not supported for the selected item."\cf0 );\par ??        \}\par ??    \}\par ??    \cf1 else\par ??\cf0     \{\par ??        \cf1 throw\cf0  \cf1 new\cf0  \cf4 TFSHistorySearchException\cf0 (\cf6 "Operation is not supported for the selected item."\cf0 );\par ??    \}\par ??\}\par ??}<br />
--></p>
<div style="background: white none repeat scroll 0% 50%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: blue">public</span> <span style="color: blue">static</span> <span style="color: blue">void</span> GetServerUriAndItemPath(<span style="color: #2b91af">DTE2</span> appObj, <span style="color: blue">ref</span> <span style="color: blue">string</span> serverUri, <span style="color: blue">ref</span> <span style="color: blue">string</span> itemPath, <span style="color: blue">ref</span> <span style="color: blue">bool</span> isFolder)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">isFolder = <span style="color: blue">false</span>;</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: green">// Get local workspace info</span></p>
<p style="margin: 0px"><span style="color: #2b91af">WorkspaceInfo</span>[] wsInfo = <span style="color: #2b91af">Workstation</span>.Current.GetAllLocalWorkspaceInfo();</p>
<p style="margin: 0px"><span style="color: blue">if</span> (wsInfo.Length == 0)</p>
<p style="margin: 0px"><span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">TFSHistorySearchException</span>(<span style="color: #a31515">&#8220;No workspace found.&#8221;</span>);</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: green">// Get server Uri</span></p>
<p style="margin: 0px">serverUri = wsInfo[0].ServerUri.AbsoluteUri;</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: green">// Get a reference to the Team Foundation Server. </span></p>
<p style="margin: 0px"><span style="color: #2b91af">TeamFoundationServer</span> tfs = <span style="color: blue">new</span> <span style="color: #2b91af">TeamFoundationServer</span>(serverUri);</p>
<p style="margin: 0px"><span style="color: #2b91af">VersionControlServer</span> vcs = tfs.GetService(<span style="color: blue">typeof</span>(<span style="color: #2b91af">VersionControlServer</span>)) <span style="color: blue">as</span> <span style="color: #2b91af">VersionControlServer</span>;</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: green">//if Active Window is Source Control Explorer</span></p>
<p style="margin: 0px"><span style="color: blue">if</span> (appObj.ActiveWindow.Caption.StartsWith(<span style="color: #a31515">&#8220;Source Control Explorer&#8221;</span>))</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: #2b91af">VersionControlExt</span> vce;</p>
<p style="margin: 0px"><span style="color: green">// The top level class used to access all other Team Foundation Version Control Extensiblity classes</span></p>
<p style="margin: 0px">vce = appObj.GetObject(<span style="color: #a31515">&#8220;Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt&#8221;</span>) <span style="color: blue">as</span> <span style="color: #2b91af">VersionControlExt</span>;</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: blue">if</span> (!vce.Explorer.Connected)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">TFSHistorySearchException</span>(<span style="color: #a31515">&#8220;Source control explorer is not connected to a Team Foundation Server&#8221;</span>);</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: green">// Get all selected items</span></p>
<p style="margin: 0px"><span style="color: #2b91af">VersionControlExplorerItem</span> []selectedItems = vce.Explorer.SelectedItems;</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: blue">if</span> (selectedItems.Length == 0)</p>
<p style="margin: 0px"><span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">TFSHistorySearchException</span>(<span style="color: #a31515">&#8220;You must select one item.&#8221;</span>);</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: blue">if</span> (selectedItems.Length &gt; 1)</p>
<p style="margin: 0px"><span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">TFSHistorySearchException</span>(<span style="color: #a31515">&#8220;Multiple items selected.&#8221;</span>);</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: blue">if</span> (selectedItems[0].SourceServerPath.Equals(<span style="color: #a31515">&#8220;$/&#8221;</span>))</p>
<p style="margin: 0px"><span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">TFSHistorySearchException</span>(<span style="color: #a31515">&#8220;Operation is not supported for the selected item.&#8221;</span>);</p>
<p style="margin: 0px"><span style="color: green">//Take the 1st item</span></p>
<p style="margin: 0px">itemPath = selectedItems[0].SourceServerPath;</p>
<p style="margin: 0px">isFolder = selectedItems[0].IsFolder;</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px"><span style="color: green">//if Active Window is Solution Explorer</span></p>
<p style="margin: 0px"><span style="color: blue">else</span> <span style="color: blue">if</span> (appObj.ActiveWindow.Caption.StartsWith(<span style="color: #a31515">&#8220;Solution Explorer&#8221;</span>))</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">isFolder = <span style="color: blue">false</span>;</p>
<p style="margin: 0px"><span style="color: blue">if</span> (appObj.SelectedItems.MultiSelect == <span style="color: blue">true</span>)</p>
<p style="margin: 0px"><span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">TFSHistorySearchException</span>(<span style="color: #a31515">&#8220;Multiple items selected.&#8221;</span>);</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: #2b91af">SelectedItem</span> selectedItem = appObj.SelectedItems.Item(1);</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: #2b91af">SourceControl2</span> sc = (<span style="color: #2b91af">SourceControl2</span>)appObj.SourceControl;</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: blue">string</span> fileName = <span style="color: #2b91af">String</span>.Empty;</p>
<p style="margin: 0px"><span style="color: blue">if</span> (selectedItem.ProjectItem != <span style="color: blue">null</span>)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: green">//Its a project file</span></p>
<p style="margin: 0px">fileName = selectedItem.ProjectItem.Properties.Item(<span style="color: #a31515">&#8220;URL&#8221;</span>).Value.ToString();</p>
<p style="margin: 0px">fileName = <span style="color: #2b91af">Regex</span>.Replace(fileName, <span style="color: #a31515">&#8220;file:///&#8221;</span>, <span style="color: #2b91af">String</span>.Empty, <span style="color: #2b91af">RegexOptions</span>.IgnoreCase);</p>
<p style="margin: 0px"><span style="color: blue">if</span> (fileName.EndsWith(<span style="color: #a31515">&#8220;\\&#8221;</span>))</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">fileName = fileName.Substring(0, fileName.LastIndexOf(<span style="color: #a31515">&#8216;\\&#8217;</span>));</p>
<p style="margin: 0px">isFolder = <span style="color: blue">true</span>;</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px"><span style="color: blue">try</span></p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: #2b91af">Item</span> item = vcs.GetItem(fileName);</p>
<p style="margin: 0px">itemPath = item.ServerItem;</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px"><span style="color: blue">catch</span> (Microsoft.TeamFoundation.VersionControl.Client.<span style="color: #2b91af">VersionControlException</span> ex)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">TFSHistorySearchException</span>(<span style="color: #a31515">&#8220;Item not under source control.&#8221;</span>, ex);</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px"><span style="color: blue">else</span> <span style="color: blue">if</span> (selectedItem.Project != <span style="color: blue">null</span>)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: green">//Its a project</span></p>
<p style="margin: 0px">fileName = selectedItem.Project.FileName;</p>
<p style="margin: 0px"><span style="color: blue">try</span></p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: #2b91af">Item</span> item = vcs.GetItem(fileName);</p>
<p style="margin: 0px">itemPath = item.ServerItem;</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px"><span style="color: blue">catch</span> (Microsoft.TeamFoundation.VersionControl.Client.<span style="color: #2b91af">VersionControlException</span> ex)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">TFSHistorySearchException</span>(<span style="color: #a31515">&#8220;Item not under source control.&#8221;</span>, ex);</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px"><span style="color: blue">else</span></p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">TFSHistorySearchException</span>(<span style="color: #a31515">&#8220;Operation is not supported for the selected item.&#8221;</span>);</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px"><span style="color: blue">else</span></p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">TFSHistorySearchException</span>(<span style="color: #a31515">&#8220;Operation is not supported for the selected item.&#8221;</span>);</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">}</p>
</div>
<p>The following code is to compare two source code files and show visual difference. There is an API provided for the same.</p>
<p><!--<br />
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;}??\fs20 \cf1 public\cf0  \cf1 static\cf0  \cf1 void\cf0  CompareLocal(\cf1 string\cf0  localPath, \cf1 string\cf0  sourceChangesetId, \cf1 string\cf0  serverUri, \cf1 string\cf0  srcPath)\par ??\{\par ??    \cf4 TeamFoundationServer\cf0  tfs = \cf4 TeamFoundationServerFactory\cf0 .GetServer(serverUri);\par ??    \cf4 VersionControlServer\cf0  vcs = tfs.GetService(\cf1 typeof\cf0 (\cf4 VersionControlServer\cf0 )) \cf1 as\cf0  \cf4 VersionControlServer\cf0 ;\par ??\par ??    \cf4 VersionSpec\cf0  sourceVersion = \cf4 VersionSpec\cf0 .ParseSingleSpec(sourceChangesetId, vcs.TeamFoundationServer.AuthenticatedUserName);\par ??\par ??    \cf4 Difference\cf0 .VisualDiffItems(vcs, \cf4 Difference\cf0 .CreateTargetDiffItem(vcs, srcPath, sourceVersion, 0, sourceVersion), \cf4 Difference\cf0 .CreateTargetDiffItem(vcs, localPath, \cf1 null\cf0 , 0, \cf1 null\cf0 ));\par ??\}\par ??}<br />
--></p>
<div style="background: white none repeat scroll 0% 50%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<p style="margin: 0px"><span style="color: blue">public</span> <span style="color: blue">static</span> <span style="color: blue">void</span> CompareLocal(<span style="color: blue">string</span> localPath, <span style="color: blue">string</span> sourceChangesetId, <span style="color: blue">string</span> serverUri, <span style="color: blue">string</span> srcPath)</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px"><span style="color: #2b91af">TeamFoundationServer</span> tfs = <span style="color: #2b91af">TeamFoundationServerFactory</span>.GetServer(serverUri);</p>
<p style="margin: 0px"><span style="color: #2b91af">VersionControlServer</span> vcs = tfs.GetService(<span style="color: blue">typeof</span>(<span style="color: #2b91af">VersionControlServer</span>)) <span style="color: blue">as</span> <span style="color: #2b91af">VersionControlServer</span>;</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: #2b91af">VersionSpec</span> sourceVersion = <span style="color: #2b91af">VersionSpec</span>.ParseSingleSpec(sourceChangesetId, vcs.TeamFoundationServer.AuthenticatedUserName);</p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: #2b91af">Difference</span>.VisualDiffItems(vcs, <span style="color: #2b91af">Difference</span>.CreateTargetDiffItem(vcs, srcPath, sourceVersion, 0, sourceVersion), <span style="color: #2b91af">Difference</span>.CreateTargetDiffItem(vcs, localPath, <span style="color: blue">null</span>, 0, <span style="color: blue">null</span>));</p>
<p style="margin: 0px">}</p>
</div>
<p>Once the add-in is installed, it appears in the Tools menu within Visual Studio 2005. Open <em>Source Control Explorer</em> and select an item. Launch the add-in from Tools menu.</p>
<p><img src="http://ankitjain.info/ankit/wp-content/052907_0752_TFSFreeText22.png" /></p>
<p>When you search for the history of a File, you can also compare it with the local version or the latest version in the source control. These option are avaiable as context menu.</p>
<p><img src="http://ankitjain.info/ankit/wp-content/052907_0752_TFSFreeText32.png" /></p>
<p><img alt="Compare options for search results (only for file types)" src="http://ankitjain.info/ankit/wp-content/TFS-History-Compare.PNG" /></p>
<p>Following steps are required only if you download the code and try to deploy the solution to have hands on with the code.</p>
<ol>
<li>Copy the <span style="font-family: Courier New; font-size: 10pt">TFSHistorySearch.AddIn</span> file to <span style="font-family: Courier New; font-size: 10pt">%userprofile%\My Documents\Visual Studio 2005\Addins\</span> directory.</li>
<li>Update the full path of the assembly <span style="font-family: Courier New; font-size: 10pt">TFSHistorySearch.dll </span>under <span style="font-family: Courier New; font-size: 10pt">Extensibility/Addin/Assembly</span> x-path.</li>
<li>Add reference of <span style="font-family: Courier New; font-size: 10pt">TFSHistorySearch.AddIn</span> as link to the project.</li>
</ol>
<p>Download Source code &#038; Installer: <a href="http://ankitjain.info/ankit/wp-content/TFSHistorySearch.zip">TFSHistorySearch.zip</a> ~700 KB<br />
Download Installer only: <a href="http://ankitjain.info/ankit/wp-content/TFSHistorySearch-Setup.zip">TFSHistorySearch-Setup.zip</a> ~400 KB</p>
<p>Implemented by:  <a target="_blank" href="http://www.topcoder.com/tc?module=MemberProfile&#038;cr=15892009&#038;tab=long">Jagdish.Vasani</a> [at] Gmail [dot] com</p>
<p>- Ankit</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2007/05/29/tfs-free-text-search-in-history-objects/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Preview: LINQ</title>
		<link>http://ankitjain.info/ankit/2007/02/14/linq-preview/</link>
		<comments>http://ankitjain.info/ankit/2007/02/14/linq-preview/#comments</comments>
		<pubDate>Wed, 14 Feb 2007 17:47:57 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Programming/Code]]></category>
		<category><![CDATA[Technology Trends]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/2007/02/14/linq-preview</guid>
		<description><![CDATA[Hmmm&#8230; a new tool in my hands &#8230; and following equation makes me crazy about it! C# 2.0 + ADO.NET = LINQ = C# 3.0 In simple words Language Integrated Query (LINQ) exposes the power of SQL queries within C# syntax. This technology along with its tools allows you to connect to SQL database, extract [...]]]></description>
			<content:encoded><![CDATA[<p>Hmmm&#8230; a new tool in my hands<br />
&#8230; and following equation makes me crazy about it!</p>
<p>C# 2.0 + ADO.NET = LINQ = C# 3.0</p>
<p>In simple words Language Integrated Query (<a target="_blank" title="LINQ on Wikipedia" href="http://en.wikipedia.org/wiki/Language_Integrated_Query">LINQ</a>) exposes the power of SQL queries within C# syntax. This technology along with its tools allows you to connect to SQL database, extract metadata, build typed datasets/classes (using <a target="_blank" href="http://msdn2.microsoft.com/en-us/library/512aeb7t%28vs.80%29.aspx">C# Generics</a>) and make you use them along with C# syntax using just two lines of code. And not necessarily SQL databases, it can execute on any collection type.</p>
<blockquote><p class=MsoNormal><span style='font-size:10.0pt;color:blue'>int</span><span style='font-size:10.0pt'>[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };<br />
var lowNums =<br />
</span><span style='color:blue'>&nbsp; &nbsp;&nbsp; from</span> n <span style='color:blue'>in</span> numbers<br />
<span style='font-size:10.0pt;color:blue'>&nbsp; &nbsp;&nbsp; where</span><span style='font-size:10.0pt'> n &lt; 5</span><br />
<span style='font-size:10.0pt;color:blue'>&nbsp; &nbsp;&nbsp; select</span><span style='font-size:10.0pt'> n;</span> Console.WriteLine(&quot;<span style='color:maroon'>Numbers &lt; 5:</span>&quot;);<br />
<span style='color:blue'>foreach</span> (var x <span style='color:blue'>in</span><br />
lowNums)<br />
<span style='font-size:10.0pt'>{<br />
&nbsp; &nbsp; Console.WriteLine(x);<br />
}</span></p>
</blockquote>
<p>Have a look at <a target="_blank" href="http://msdn2.microsoft.com/en-us/vcsharp/aa336745.aspx">Linq Project</a> @ MSDN and <a target="_blank" href="http://msdn2.microsoft.com/en-us/vcsharp/aa336746.aspx">101 Samples</a> all to sense this. Here in this short -n-simple post Iâ€™m just showing how to do things for databases stored as <span style="font-style: italic">*.mdf</span> files and generate wrapper classes.The LINQ preview includes SqlMetal.exe, a utility to auto-generate a strongly-typed C# DataContext class file from an SQL Server 2000 or 2005 database&#8217;s metadata with this execution syntax:</p>
<blockquote>
<p class="MsoNormal">$>sqlmetal.exe /namespace:NWind /language:csharp /code:Northwind.cs c:\ Northwind.mdf</p>
</blockquote>
<p>- Ankit</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2007/02/14/linq-preview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Webservices PowerPoint Presentation</title>
		<link>http://ankitjain.info/ankit/2007/01/06/web-service-ppt-download/</link>
		<comments>http://ankitjain.info/ankit/2007/01/06/web-service-ppt-download/#comments</comments>
		<pubDate>Sat, 06 Jan 2007 13:20:20 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Programming/Code]]></category>
		<category><![CDATA[Tutorial/Links]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[download]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/2007/01/06/web-service-ppt-download</guid>
		<description><![CDATA[My presentation on WebServices Basics is available for download to the *valuable visitors* of my blog. Here is the content: Web services &#8211; Definition: A web service is a collection of protocols and standards used for exchanging data between applications or systems. Characteristics Demo: Writing a simple WebService in Visual Studio 2005 &#038; Consuming WebServices [...]]]></description>
			<content:encoded><![CDATA[<p>My presentation on <a title="Webservices Basics on AnkitJain.info -- Download" href="http://ankitjain.info/ankit/wp-content/WebServices.ppt">WebServices Basics</a> is available for download to the *valuable visitors* of my blog. Here is the content:</p>
<ul type="disc" style="margin-top: 0in">
<li class="MsoNormal">Web      services &#8211; Definition: A web service is a collection of protocols and      standards used for exchanging data between applications or systems.</li>
<li class="MsoNormal">Characteristics</li>
<li class="MsoNormal">Demo: Writing      a simple WebService in Visual Studio 2005 &#038; Consuming WebServices</li>
<li class="MsoNormal">Technologies:      XML (eXtensible Markup Language), SOAP (Simple Object Access Protocol), WSDL      (Web services description language), UDDI (universal description,      discovery, and integration)</li>
<li class="MsoNormal">SOAP: SOAP      is an open protocol specification defining a uniform way of performing      RPCs using HTTP as the underlying communications protocol with XML for the      data serialization.</li>
<li class="MsoNormal">Drilling inside <strong>SoapHttpClientProtocol</strong> class</li>
<li class="MsoNormal">Advantages      of Web services</li>
<li class="MsoNormal">SOA â€“ Service      Oriented Architecture, Four Tenets</li>
</ul>
<p class="MsoNormal">Thanks,</p>
<p class="MsoNormal">~ Ankit</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2007/01/06/web-service-ppt-download/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Fetching file history from TFS : the code way</title>
		<link>http://ankitjain.info/ankit/2006/12/13/tfs-version-control-build-history/</link>
		<comments>http://ankitjain.info/ankit/2006/12/13/tfs-version-control-build-history/#comments</comments>
		<pubDate>Wed, 13 Dec 2006 18:09:35 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Programming/Code]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/2006/12/13/tfs-version-control-build-history</guid>
		<description><![CDATA[These days Iâ€™m writing a tool for Visual Studio that integrates with Team Foundation Server. This post is about how to retrieve/fetch history of a file from source control server using TFS-SDK. Following function takes server name and file path as input and returns an enumerator holding Changeset objects. public static IEnumerable FetchHistory(string serverName, string [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">These days Iâ€™m writing a tool for Visual Studio that integrates with Team Foundation Server. This post is about how to retrieve/fetch history of a file from source control server using TFS-SDK. Following function takes server name and file path as input and returns an enumerator holding <a target="_blank" title="Changeset Class at MSDN" href="http://msdn2.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.changeset(VS.80).aspx">Changeset</a> objects.</p>
<blockquote><p class="MsoNormal"><span style="font-size: 10pt">public</span><span style="font-size: 10pt"> </span><span style="color: blue">static</span> <span style="color: teal">IEnumerable</span> FetchHistory(<span style="color: blue">string</span> serverName, <span style="color: blue">string</span> filePath)<br />
{<br />
<span style="color: teal">TeamFoundationServer</span> tfs = <span style="color: teal">TeamFoundationServerFactory</span>.GetServer(serverName);<br />
<span style="color: teal">VersionControlServer</span> vcs = tfs.GetService(<span style="color: blue">typeof</span>(<span style="color: teal">VersionControlServer</span>)) <span style="color: blue">as</span> <span style="color: teal">VersionControlServer</span>;<br />
<span style="color: teal">ExtendedItem</span>[] itemArray1 = vcs.GetExtendedItems(filePath, <span style="color: teal">DeletedState</span>.NonDeleted, <span style="color: teal">ItemType</span>.Any);</p>
<p class="MsoNormal"><span style="font-size: 10pt"></span><span style="color: blue">if</span> ((itemArray1 == <span style="color: blue">null</span>) || (itemArray1.Length == 0))<br />
<span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: teal">Exception</span>(<span style="color: maroon">&#8220;There are no items.&#8221;</span>);</p>
<p class="MsoNormal"><span style="font-size: 10pt"></span><span style="color: teal">ExtendedItem</span> item1 = itemArray1[0];<br />
<span style="color: teal">IEnumerable</span> enumerable1 = vcs.QueryHistory(filePath,<br />
<span style="color: teal">VersionSpec</span>.Latest, item1.DeletionId,<br />
(item1.ItemType == <span style="color: teal">ItemType</span>.Folder) ? <span style="color: teal">RecursionType</span>.Full : <span style="color: teal">RecursionType</span>.None,<br />
<span style="color: maroon">&#8220;&#8221;</span>, <span style="color: blue">new</span> <span style="color: teal">ChangesetVersionSpec</span>(1),<br />
<span style="color: teal">VersionSpec</span>.Latest, 0x7fffffff, <span style="color: blue">true</span>, <span style="color: blue">false</span>);<br />
<span style="color: blue">return</span> enumerable1;<br />
}</p>
</blockquote>
<p>To compile this successfully you also need to add references of following two assemblies found at <span style="font-size: 10pt">[VS installation directory]\Common7\IDE\PrivateAssemblies\</span>:</p>
<blockquote><p><span style="font-size: 10pt">Microsoft.TeamFoundation.Client.dll<br />
Microsoft.TeamFoundation.VersionControl.Client.dll</span></p></blockquote>
<p>Call to this function should be made as follows:</p>
<blockquote><p><span style="font-size: 10pt">FetchHistory(â€œ[serverName]â€, â€œ$/Project1/Class.csâ€ );</span></p></blockquote>
<p>- Ankit</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2006/12/13/tfs-version-control-build-history/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>3D Full Screen Window and Dynamic XAML Sample with WPF</title>
		<link>http://ankitjain.info/ankit/2006/12/01/wpf-xaml-viewport3d-window-full-screen/</link>
		<comments>http://ankitjain.info/ankit/2006/12/01/wpf-xaml-viewport3d-window-full-screen/#comments</comments>
		<pubDate>Fri, 01 Dec 2006 14:59:07 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[.net 3.0]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Programming/Code]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/2006/12/01/wpf-xaml-viewport3d-window-full-screen</guid>
		<description><![CDATA[One nice feature of WPF (Windows Presentation Foundation, .Net 3.0) is the integration of 3D library with the existing framework. Today I worked with Viewport3D class. This class handles it all for managing 3D views. The &#8220;Hello World&#8221; example I coded here basically demonstrates three features: Loading XAML dynamically at runtime Playing with 3D objects [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">One nice feature of WPF (Windows Presentation Foundation, .Net 3.0) is the integration of 3D library with the existing framework. Today I worked with Viewport3D class. This class handles it all for managing 3D views. The &#8220;Hello World&#8221; example I coded here basically demonstrates three features:</p>
<ul type="circle" style="margin-top: 0in">
<li class="MsoNormal">Loading XAML dynamically at runtime</li>
<li class="MsoNormal">Playing with 3D objects using <span style="font-size: 10pt">Viewport3D</span> and make them rotate using mouse.</li>
<li class="MsoNormal">Creating transparent and full-screen windows</li>
</ul>
<p class="MsoNormal">Let&#8217;s drill down to the technical details of above three aspects:</p>
<p class="MsoNormal">Firstly, loading XAML runtime can be achieved using <span style="font-size: 10pt">System.Windows.Markup.</span><span style="color: teal">XamlReader</span> class. The Load function takes a stream object (containing XAML source) and return appropriate UI control. Actually, it returns the root control in the stream.</p>
<blockquote>
<p class="MsoNormal"><span style="font-size: 10pt">    </span><span style="color: teal">FileStream</span> fs = <span style="color: teal">File</span>.OpenRead(fileName);<br />
<span style="color: blue">this</span>.view3D = (<span style="color: teal">Viewport3D</span>) System.Windows.Markup.<span style="color: teal">XamlReader</span>.Load(fs);</p>
</blockquote>
<p class="MsoNormal">Secondly, the class <span style="font-size: 10pt">Viewport3D</span> does it all for you to handle 3D objects. Here we have just hooked mouse events that allows rotation of 3D object in all directions. Moreover you can zoom in/out using right mouse button. Thanks <a target="_blank" href="http://viewport3d.com/trackball.htm">Daniel</a> for writing TrackBall class.</p>
<p class="MsoNormal">Lastly, setting few parameters as below we can make a Window appear transparent and full-screened:</p>
<p class="MsoNormal"><span style="font-size: 10pt"><span style="color: blue" /></span></p>
<blockquote><p><span style="color: blue">this</span>.win = <span style="color: blue">new</span> <span style="color: teal">Window</span>();<br />
win.Content = view3D;<br />
win.ShowInTaskbar = <span style="color: blue">false</span> ;<br />
win.Background =  <span style="color: teal">Brushes</span>.Transparent ;<br />
win.AllowsTransparency = <span style="color: blue">true</span>;<br />
win.WindowStyle = <span style="color: teal">WindowStyle</span>.None ;<br />
win.WindowStartupLocation = <span style="color: teal">WindowStartupLocation</span>.CenterScreen ;<br />
win.WindowState = <span style="color: teal">WindowState</span>.Maximized;<br />
win.Show();</p></blockquote>
<p class="MsoNormal">Well, I guess that&#8217;s enough for the first WPF post.<br />
Download the source code for sample application: <a title=".Net 3.0 Framework required to run this sample" href="http://ankitjain.info/ankit/wp-content/Load-3D-XAML-Runtime.zip">Load-3D-XAML-Runtime.zip</a></p>
<p class="MsoNormal">Thanks for reading.<br />
~ Ankit</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2006/12/01/wpf-xaml-viewport3d-window-full-screen/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>IE extensions/add-on &#8211; the simplest way (context menu)</title>
		<link>http://ankitjain.info/ankit/2006/09/26/internet-explorer-write-addon-simple-way/</link>
		<comments>http://ankitjain.info/ankit/2006/09/26/internet-explorer-write-addon-simple-way/#comments</comments>
		<pubDate>Tue, 26 Sep 2006 11:47:15 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Programming/Code]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/2006/09/26/internet-explorer-write-addon-simple-way</guid>
		<description><![CDATA[I love writing extensions for applications and filling gaps in between making the world simpler (interacting with each other, giving users flexibility in switching from one application to another.) The power of any application (especially Internet Browsers) lies in how features enriched it is. One of the way to achieve this is to lay down [...]]]></description>
			<content:encoded><![CDATA[<p>I love writing extensions for applications and filling gaps in between making the world simpler (interacting with each other, giving users flexibility in switching from one application to another.) The power of any application (especially Internet Browsers) lies in how features enriched it is. One of the way to achieve this is to lay down extensible architecture and <u>promote developers</u> to write extensions for you application. Moreover such architecture should provide</p>
<ul type="disc" style="margin-top: 0in">
<li>the simplest method to write an extension in few seconds (â€œhello worldâ€ example)</li>
<li>more flexible in term of autonomy to developer for by exposing a rich set of API, that they can code almost everything,</li>
<li>and the last, limiting them touching sensible data of user.</li>
</ul>
<p>Well, the power of FireFox lies in more than thousands of extensions that it provides. This could also have been for Internet Explorer, if Microsoft has provided detailed documentation and samples for Internet Explorer when they released IE 5. Over the years Microsoft had always concentrated on the Web development front of IE, not on the extensibility part of it even though providing great ways to extend.</p>
<p>Letâ€™s go through Internet Explorer for writing the simplest extension in just 5 minutes.        So, what we want to do? Here I;m showing how to access Html DOM and change it on the fly. All you need to know is simple JavaScript and basic programming concepts. Here are the steps on MSDN that <a href="http://msdn.microsoft.com/workshop/browser/ext/tutorials/context.asp">details adding a context menu to Internet Explorer</a>.</p>
<p><span id="more-70"></span></p>
<ol type="1" style="margin-top: 0in" start="1">
<li>Open Registry Editor and point it to <span style="font-size: 10pt">HKEY_CURRENT_USER\Software\Microsoft\Internet<br />
Explorer\MenuExt</span></li>
<li>Create a new key that represents the text on the context menu. This may include â€˜&#038;â€™ for keyboard shortcut.</li>
<li>Create a blank Html file, say <span style="font-size: 10pt">myMenu.html</span> and open it in notepad. Clicking on the new item in the context menu this is the script file which gets executed. Point the default value of the key (created in the step 2) to this html file.</li>
<li>Create a binary value Contexts, and sets its value as 0&#215;1. This can be 0&#215;2 if you want our item to appear when we right click on an image. Or 0&#215;10 if it should appear only it some text is selected. These values can also be binary OR-ed with each other.</li>
</ol>
<p>Next, open IE and right click (as whatever contexts you have set), you can see your new text appearing in the menu. Then we need to handle the event that Internet Explorer sends to the <span style="font-size: 10pt">myMenu.html</span> file. This should contain a script block. It receives an event as<span style="font-size: 10pt"> external.menuArguments</span>. This menu argument contains a document object that is same as what we use in JavaScript to access the html of the webpage. This can be accessed as below:</p>
<pre><font color="blue">&lt;SCRIPT LANGUAGE = "JavaScript"&gt;

// Get the window object where the context menu was opened.
var oWindow = window.external.menuArguments;

// Get the document object exposed through oWindow.
var oDocument = oWindow.document;

// Get the selection from oDocument.
// in oDocument.
var oSelect = oDocument.selection;

// Create a TextRange from oSelect.
var oSelectRange = oSelect.createRange();

// Get the text of the selection.
var sNewText = oSelectRange.text;

// If nothing was selected, insert some text.
if (sNewText.length == 0){
oSelectRange.text = "INSERT TEXT";
}

// Otherwise, convert the selection to uppercase.
else{
oSelectRange.text = sNewText.toUpperCase();
}
&lt;/SCRIPT&gt;
</font></pre>
<p>One another script is for Orkut users, for which Orkut does not shows images when accessed from images.orkut.com</p>
<pre><font color="blue">&lt;SCRIPT&gt;
if ( external.menuArguments.document.URL.indexOf("images.orkut.com") &gt;=0
)
{
if (external.menuArguments.document.URL.indexOf("http://") &gt;=0 )
{
external.menuArguments.document.URL = external.menuArguments.document.URL.replace("http://","https://");
}
else
{
var count = external.menuArguments.document.images.length ;
for( var i = 0; i &lt; count ; i++ )
{
var strSrc = external.menuArguments.document.images[i].src;
strSrc = strSrc.replace("http://","https://");
external.menuArguments.document.images[i].src = strSrc ;
}
}
}
else
{
alert("Ooops...nI work only for images.orkut.com");
}
&lt;/SCRIPT&gt;
</font></pre>
<p>The above script just replaces <strong>http</strong> with <strong>https</strong><br />
for all images in the Html Dom.</p>
<p>The ready-made setup is available <a href="http://ankitjain.info/ankit/2006/09/08/orkut-blocked-internet-problem">here</a>.</p>
<p>The same can done using C#, but it requires .Net framework that makes it difficult<br />
to deploy. Even you can hide your script in a â€˜dllâ€™ as resource and point it in<br />
registry (default content) as follows:</p>
<p><font color="blue">@=â€œres://C:\WINDOWS\system32\abc32.dll/script.html&#8221;</font></p>
<p>~ Ankit</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2006/09/26/internet-explorer-write-addon-simple-way/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
