A personal repository of technical notes. - CSC

Open TFS Output Window in Visual Studio

Problem
Can't see TFS output window in Visual Studio.

Solution
Run macro to open window.
  

Public Sub OpenTFSOutputWindowPane()

Dim window As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)

Dim outputWindow As OutputWindow = CType(window.Object, OutputWindow)

Dim tfsOutputWindowPane As OutputWindowPane = outputWindow.OutputWindowPanes.Item("Source Control - Team Foundation")

tfsOutputWindowPane.Activate()

window.Visible = True

End Sub

TFS Team Foundation Server Command Line Tips

How to get all items checked out to user
tf status /user:myusername /format:Detailed

How to get all items checked out to all users in a specific source location
tf status /user:* /recursive "$/My Folder1/My Folder2"

Variation: Pipe the results to the FIND command in order to filter the results. This example shows only items of change type "add".
tf status /user:* /recursive "$/My Folder1/My Folder2" | FIND " add "

How to undo other user's checkout.
Step 1) Get workspace and user name of checked out file.
tf status /user:* /format:detailed "$/My Folder1/My File1.txt"

Step 2) Undo checked out file.
tf undo /workspace:myworkspace;myusername "$/My Folder1/My File1.txt"

References
"Status Command." MSDN | Microsoft Development, Subscriptions, Resources, and More. Web. 16 Aug. 2010.
<http://msdn.microsoft.com/en-us/library/9s5ae285(v=VS.90).aspx>.
"Undo Command." MSDN | Microsoft Development, Subscriptions, Resources, and More. Web. 16 Aug. 2010.
<http://msdn.microsoft.com/en-us/library/c72skhw4(v=VS.90).aspx>.
"Command-Line Syntax (Team System)." MSDN | Microsoft Development, Subscriptions, Resources, and More. Web. 23 Sept. 2010.
<http://msdn.microsoft.com/en-us/library/56f7w6be(v=VS.90).aspx>.

Updates
2010-09-23 Added "Get items checked out to all users in a specific source location"; reference to "Command-Line Syntax (Team System)."
2010-09-24 Added "Variation: Pipe the results to the FIND command..."

Change GridView SortDirection Default

Problem
Need to change the default SortDirection in a GridView for certain columns from ascending to descending.

Solution
Note: This was tested and implemented in ASP.NET 2.0.
  

<asp:GridView DataSourceID="MySqlDataSource" AllowSorting="true" AutoGenerateColumns="false"

ID="MainGridView" runat="server" OnSorting="MainGridView_Sorting">

<Columns>

<asp:BoundField DataField="MyDataField01" SortExpression="MyDataField01" />

<asp:BoundField DataField="MyDataField02" SortExpression="MyDataField02" />

<asp:BoundField DataField="MyDataField03" SortExpression="MyDataField03" />

<asp:BoundField DataField="MyDataField04" SortExpression="MyDataField04" />

<asp:BoundField DataField="MyDataField05" SortExpression="MyDataField05" />

<asp:BoundField DataField="MyDataField06" SortExpression="MyDataField06" />

</Columns>

</asp:GridView>

protected void MainGridView_Sorting(object sender, GridViewSortEventArgs e)

{

// Change default sort order to Descending for certain columns.

switch (e.SortExpression)

{

case "MyDataField01":

case "MyDataField03":

case "MyDataField06":

// Current sort column is different than previous sort column

if (e.SortExpression != MainGridView.SortExpression)

{

e.SortDirection = SortDirection.Descending;

}

break;

default:

break;

}

}

Customize Context Menu of Visual Studio

Problem
Need to customize context menus (also known as shortcut menus) in Visual Studio .NET.

Solution
Note: This technique allows you to modify main menus and context menus.

Instructions tested in VS2013, VS2010 and SSMS 2012, SSMS 2014
  1. Tools/Customize.../Commands tab
  2. Click "Context menu"
  3. Select the menu to modify from the drop down menu
Instructions tested in VS2005, VS2008
  1. Tools/Customize.../Toolbars tab
  2. Check "Context Menus"
    Note: Context Menus may also be modified directly in the toolbar added on this step and the rest of the steps may be skipped.
  3. Commands tab/Rearrange Commands...
  4. Follow detailed steps in Microsoft reference titled "How to: Customize Main Menus and Shortcut Menus".
Common menus to modify
  • C# code-behind: Other Context Menus/Code Window
  • ASPX, ASCX front-end: Other Context Menus/ASPX Context
  • CSS style sheet: Other Context Menus/CSSSource
  • SQL Stored Proc: Other Context Menus | SqlEditorContextMenu
  • Solution Explorer: Project and Solution Context Menus | Item
  • Solution Explorer: Project and Solution Context Menus | Web Item
  • SSMS: File editor: Other Context Menus | SQL Files Editor Context
  • HTML, Classic ASP: Other Context Menus | HTML Context
Common commands to add
  • Edit/Collapse All Outlining
  • Macros/{Custom Macros} (Prior to VS2012)
  • Tools/{Custom Extensions}
  • File/TfsGetLatestVersion
  • File/TfsCheckOut
  • File/TfsCheckIn
  • File/TfsUndoCheckout
  • File/TfsHistory
  • File/TfsCompare
  • Tools/Customize...
Miscellaneous menus and commands
  • SQL Results Pane: Other Context Menus | SqlEditorResultsContextMenu
    • Data/Show/Hide Results Pane
Example


References
"How To: Customize Menus and Toolbars (Visual Studio)." MSDN Explore Desktop, Web, Cloud, and Phone Software Development. Web. 23 Aug. 2011.
<http://msdn.microsoft.com/en-us/library/wdee4yb6.aspx>.
"How To: Customize Main Menus and Shortcut Menus." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. Web. 07 May 2010.
<http://msdn.microsoft.com/en-us/library/ms241445(VS.80).aspx>.

Updates
2015-05-28 Added VS2013, SSMS 2014 References
2013-09-30 Added SSMS references.
2013-02-01 Added Common commands to add. Changed example images.
2011-08-23 Added VS2010 References

Excel Tips

Create Custom Macro Workbook
  1. Create new workbook for custom macros.
  2. Save workbook in a folder with no other items.
  3. Hide workbook:
    Window/Hide
  4. Configure Custom Macro Workbook to automatically open by placing folder name in:
    Excel/Tools/Options/General/At startup, open all files in:
Dynamic Hyperlink Formula
View Web PageQuery String Value
=HYPERLINK("http://www.mydomain.com/mypage.htm?name="&B2, "View Web Page")MyValue1
=HYPERLINK("http://www.mydomain.com/mypage.htm?name="&B3, "View Web Page")MyValue2
=HYPERLINK("http://www.mydomain.com/mypage.htm?name="&B4, "View Web Page")MyValue3

Macro to Convert Text Hyperlink to Working Hyperlink

Sub HyperLinkConvert()
       ' From Microsoft: http://support.microsoft.com/kb/271856
       ' Converts each text hyperlink selected into a working hyperlink
       For Each xCell In Selection
              ActiveSheet.Hyperlinks.Add(Anchor:=xCell, Address:=xCell.Formula)
       Next xCell
End Sub

Updates
2012-10-30 Added "Macro to Convert Text Hyperlink"
2012-08-30 Added "Dynamic Hyperlink Formula"

Enable NTLM Authentication in Firefox

Problem
Need to be able to perform NTLM Authentication for Single Sign-On Integrated Authentication using Firefox browser.

Solution
Create a whitelist in Firefox settings (about:config) by adding comma delimited list of domains to network.automatic-ntlm-auth.trusted-uris

Example: myintranet, www.mydomain.com, etc

References
"Integrated Authentication - MDC." Mozilla Developer Center - MDC. Web. 23 Mar. 2010.
<https://developer.mozilla.org/En/Integrated_Authentication>.

Membership.DeleteUser() Throws REFERENCE constraint Error

Problem

Membership.DeleteUser("myMembershipUser")

Threw the following error:

The DELETE statement conflicted with the REFERENCE constraint "FK__aspnet_Me__UserI__15502E78". The conflict occurred in database "MyDatabase", table "dbo.aspnet_Membership", column 'UserId'.
The statement has been terminated.


Solution

This particular issue was resolved by adding SELECT permission to view vw_aspnet_MembershipUsers:
  

use [MyDatabase]

GO

GRANT SELECT ON [dbo].[vw_aspnet_MembershipUsers] TO [MyDatabaseUser]

GO

References

"Membership.deleteUser error - ASP.NET Forums." Forums.asp.net - Home. Web. 05 Feb. 2010.
<http://forums.asp.net/t/1254087.aspx>.

App_GlobalResources maps to a directory outside this application, which is not supported.

Problem

Error thrown when virtual folder has trailing backslash at end of Local Path setting in IIS.

Solution

Remove trailing backslash at end of Local Path setting in IIS of virtual folder.

Error message in ASP.NET v2.0
Server Error in '/MyBadVirtualFolder/MyApplicationFolder' Application.
The path '/MyBadVirtualFolder/MyApplicationFolder/App_GlobalResources/' maps to a directory outside this application, which is not supported.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Error message in ASP.NET v1.1
Server Error in '/MyBadVirtualFolder/MyApplicationFolder' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
References
brutter. "App_GlobalResources maps to a directory outside this application, which is not supported. - ASP.NET Forums." Forum. 19 Sept. 2005. Forums.asp.net - Home. Web. 22 Jan. 2010.
<http://forums.asp.net/t/889911.aspx>.

Google on SEO (Search Engine Optimization)

References

"Google's Search Engine Optimization Starter Guide" Official Google Webmaster Central Blog. 13 Nov. 2008. Web. 22 Jan. 2010. [PDF file]
<http://www.google.com/webmasters/docs/search-engine-optimization-starter-guide.pdf>.


"Google's SEO Starter Guide." Official Google Webmaster Central Blog. Web. 22 Jan. 2010.
<http://googlewebmastercentral.blogspot.com/2008/11/googles-seo-starter-guide.html>.


"Google SEO resources for beginners." Official Google Webmaster Central Blog. Web. 22 Jan. 2010.
<http://googlewebmastercentral.blogspot.com/2010/01/google-seo-resources-for-beginners.html>.

Windows Explorer Command-Line Options for Windows XP

BAT file code
@echo off
start %SystemRoot%\explorer.exe /n,/root, "C:\MyFolder"


References
"Explorer.exe Command-Line Options for Windows XP." Microsoft Support. Web. 24 Dec. 2009. <http://support.microsoft.com/kb/314853>.

The options that you can use with Explorer.exe are /n, /e, /root (plus an object), and /select (plus an object).

Option            Function
----------------------------------------------------------------------
/n Opens a new single-pane window for the default
selection. This is usually the root of the drive that
Windows is installed on. If the window is already
open, a duplicate opens.

/e Opens Windows Explorer in its default view.

/root,<object> Opens a window view of the specified object.

/select,<object> Opens a window view with the specified folder, file,
or program selected.