Deleting and purging items from Team Foundation Server

When you delete an item from TFS, it’s not actually permanently gone.

You can view deleted items by going to Tools > Options > Source Control > Visual Studio Team Foundation Server and checking the Show deleted items in the Source Control Explorer option:


You can then see folders and files that have been deleted, which allows you to right click on them to choose Undelete (or go to File > Source Control > Undelete).

It’s useful to show deleted items by default, but you may find that your source tree ends up a bit clogged with all the deleted files and folders.

You can purge items you want to delete permanently by using the TFS command-line tools.

TF.EXE is found with Visual Studio 2010 under C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDE for 64 bit machines, and C:Program FilesMicrosoft Visual Studio 10.0Common7IDE on 32 bit.

You might find it useful to add that path to your command line.

The commandlet you want to use is destroy, which tf.exe can give us info on:

C:WindowsSystem32>tf help destroy
TF - Team Foundation Version Control Tool, Version 10.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Destroys, or permanently deletes, version-controlled items from Team
Foundation version control.

tf destroy [/keephistory] itemspec1 [;versionspec]
[itemspec2...itemspecN] [/stopat:versionspec] [/preview]
[/startcleanup] [/noprompt] [/silent]

Date/Time         D"any .Net Framework-supported format"
or any of the date formats of the local machine
Changeset number  Cnnnnnn
Label             Llabelname
Latest version    T
Workspace         Wworkspacename;workspaceowner

To run the command, you have to specify the collection URL. An easy way to get this is open your Team Explorer window in Visual Studio (View > Team Explorer), select the root server node and look in the Properties window at the Url property.

Now you need the server name of the folder or file you want to purge. Locate the file or folder in the Source Control Explorer, right click and choose Properties…

The Server Name: value is what you want and can be selected and copied to the clipboard.

Now you can run the command:

tf destroy $/MyProject/Main/Bin /collection:http://servername:8080/tfs/myproject
Do you want to destroy $/MyProject/Main/Bin and all of its children? (Yes/No) y
Destroyed: $/MyProject/Main/Bin;X3601
Destroyed: $/MyProject/Main/Bin/Native;X3601

Now if you refresh in Solution Explorer, the purged items won’t even show up anymore.

Manually schedule a disk check at next restart

You can schedule a chkdsk at reboot time for a drive by using the Windows command line utility fsutil.

You do this by setting the “dirty” flag for a drive, which marks the drive for a chkdsk when you next reboot.


fsutil dirty query <volume pathname>


fsutil dirty set C:

You can check if a drive has been marked as dirty by using the query command:

fsutil dirty query <volume pathname>

Error building project when referencing native assembly dependency in app.manifest

If you’re using an app.manifest, and defining assembly dependencies (i.e. for SxS / Side by side / Reg-free COM etc), you may encounter this error when you build the project:

Could not find file ‘AssemblyName, Version=x.x.x.x, PublicKeyToken=xxxxxxxxxxx, ProcessorArchitecture=x86, Type=win32′.

This is even when the native assembly is in place where the project can find it.


For example, your app.manifest may contain this fragment:

<assemblyIdentity name=Native.Custom version= processorArchitecture=x86 type=win32 publicKeyToken=12345678/>

This manifest is available to the project, with the manifest file in the project directory or in a subdirectory called “Native.Custom”.

In this case, I have a sub directory called Native.Custom, which contains my Native.Custom.manifest file.


The problem may be because the ClickOnce manifests are being generated.

  1. Open your project file in a text editor (or right click it in Visual Studio and choose Edit Project)
  2. Find the  GenerateManifests element and set it to false:
  3. <GenerateManifests>false</GenerateManifests>
  4. Save the project and reload it.

Now you should hopefully be able to build.

Running .NET 2 Runtime applications under the .NET 4 Runtime

In some situations, you might want to run a .NET 2 Runtime application (.NET 2, 3.0, 3.5 SP1 etc) under the .NET 4 Runtime – without recompiling.

You can configure your app to execute under the .NET 4 runtime by adding these lines to the executable’s configuration file, under the root  configuration element:

  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

Because the security framework has changed in the .NET 4 runtime, you will likely encounter some exceptions containing a message similar to:

System.NotSupportedException: This method explicitly uses CAS policy, which has been obsoleted by the .NET Framework. In order to enable CAS policy for compatibility reasons, please use the NetFx40_LegacySecurityPolicy configuration switch. Please see for more information.

To avoid this, you  have to enable the legacy support by adding a runtime element :

  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  <NetFx40_LegacySecurityPolicy enabled="true"/>

If your application also uses mixed assemblies that contain both managed and native code (such as System.Data.SQLite.dll), you’ll see an error message like this:

Mixed mode assembly is built against version ‘v2.0.50727′ of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

You will need to enable the legacy activation to allow these to be loaded also:

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  <NetFx40_LegacySecurityPolicy enabled="true"/>


<startup> Element @ MSDN

<supportedRuntime> Element @ MSDN

<NetFx40_LegacySecurityPolicy> Element @ MSDN

<startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
        <NetFx40_LegacySecurityPolicy enabled="true"/>

Opera 10.5 Beta and Windows 7 Integration

Opera 10.5 Beta is out and it’s very impressive, and looks pretty stunning due to its Windows 7 integration.

One thing I don’t really like is how it shows all the tabs using Aero Peek when you click it in the Task Bar.

You can turn this off:

  1. Type “opera:config” in the address bar and hit Enter
  2. Scroll down to User Prefs and expand it, or type in “Windows 7″ in the search box
  3. Untick the “Use Windows 7 Taskbar Thumbnails” setting
  4. Click Save
  5. Restart Opera

Running 32-bit Remote Desktop Connection on Windows 64 bit

Solution: Rename the 64-bit mstsc.exe from System32 to prevent it from replacing the 32-bit process. This is simple if you have rights to rename that file. If you’re on NTFS you may get a “You require permission from TrustedInstaller to make changes to this file” error. To get by this error, you can take Ownership of the file and give yourself full permissions:

  1. Browse to %SystemRoot%System32
  2. Right click mstsc.exe and choose Properties
  3. Go to the Security tab
  4. Click Advanced
  5. Go to the Owner tab
  6. Click Edit
  7. From the “Change owner to:” list, choose your user name
  8. Click OK
  9. Go to the Permissions tab
  10. Click Change Permissions⬦
  11. Click Add
  12. Enter your user name and click OK
  13. Tick the box in the Allow column for Full control
  14. Click OK
  15. Click OK
  16. A Windows Security warning will come up; click Yes to proceed
  17. Click OK
Now, you can rename the file mstsc.exe to something like mstsc.exe.bak Then, you can launch mstsc.exe from %SystemRoot%SysWOW64 and you will have 32-bit Remote Desktop Connection running.]]>

Generating GUIDs from Visual Studio 2008

Tools > Create GUID tool is too cumbersome for this. I found a blog post that has a simple macro you can customize to bind a keyboard shortcut to paste in a new GUID Here are some full instructions, using their simple macro code:

  1. Tools > Macros > Macro Explorer (or hit ALT+F8)
  2. Right click Macros, choose New Macro Project…
  3. Choose a location for the Macro project and give it a meaningful name then click Add
  4. Rename Module1 to something more meaningful, then double-click to edit the module
  5. Insert the code to paste a new GUID into the current cursor position / selection: Public Sub PasteNewGuid() DTE.ActiveDocument.Selection.Text = "{" & System.Guid.NewGuid().ToString("D").ToUpper() & "}" End Sub
  6. Save the macro project and close the Macro IDE
  7. In Visual Studio: Tools > Options, select Environment > Keyboard
  8. Find the macro command you created (you can use the Show commands containing: to search on guid)
  9. Select the command in the list
  10. Ensure Use new shortcut in: has Global selected
  11. Place the cursor in Press shortcut keys: and hit the shortcut (ALT+G for me)
  12. Hit OK
  13. Test it out

Solution: Explorer open each folder in same window error and SQL Management Studio, IE and Team Explorer errors


  • When attempting to open a folder in Windows Explorer, the folder opens in a new window, even if “Open each folder in the same window” is selected in Folder Options.
  • Some links in Internet Explorer don’t open correctly
  • Microsoft SQL Server Management Studio: An error with a message like “Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘Microsoft.VisualStudio.OLE.Interop.IServiceProvider’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{6D5140C1-7436-11CE-8034-00AA006009FA}’ failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). (Microsoft.VisualStudio.OLE.Interop)
  • Visual Studio Team Explorer: When browsing using the Team Explorer window, you may get COM errors similar to those in the SQL Management Studio error above


I’m not sure of the exact details, but this is what I think I’ve found. Perhaps someone at Microsoft would correct or elaborate on this. Previously, actxprxy.dll (ActiveX Interface Marshaling Library) was used as the proxy for a multitude of system interfaces, such as IShellFolder and IServiceProvider. In Windows 7 (and probably Vista also), the GUID of this library has changed from {B8DA6310-E19B-11D0-933C-00A0C90DCAA9} to {C90250F3-4D7D-4991-9B69-A5C5BC1C2AE6} Secondly, there is also a new Proxy/Stub provider found in ieproxy.dll of Internet Explorer (IE ActiveX Interface Marshaling Library). Some interfaces that previously used actxprxy.dll are now registered to use ieproxy.dll. Now various problematic software (such as Vault 3.x) will try to register against actxproxy using the old GUID, and for interfaces now proxied by ieproxy.dll.


Solution 1

You must use regsvr32 to re-register the two proxy DLLs, then reboot You can use the below batch file to do this. You must run this batch file with administrative privileges (right click on the file and choose Run as administrator): RunAsAdministrator If you don’t run the batch file as an administrator, you will get an error as pictured: ActxprxyRegisterError [Download RegisterActxprxyAndIeproxy.cmd] RegisterActxprxyAndIeproxy.cmd source:
@echo off

:: 32 bit and 64 bit
IF EXIST "%SystemRoot%System32actxprxy.dll" "%SystemRoot%System32regsvr32.exe" "%SystemRoot%System32actxprxy.dll"
IF EXIST "%ProgramFiles%Internet Explorerieproxy.dll" "%SystemRoot%System32regsvr32.exe" "%ProgramFiles%Internet Explorerieproxy.dll"

:: 64 bit only (32bit on 64 bit)
IF EXIST "%WinDir%SysWOW64actxprxy.dll" "%WinDir%SysWOW64regsvr32.exe" "%WinDir%SysWOW64actxprxy.dll"
IF EXIST "%ProgramFiles(x86)%Internet Explorerieproxy.dll" "%WinDir%SysWOW64regsvr32.exe" "%ProgramFiles(x86)%Internet Explorerieproxy.dll"
Don’t forget to reboot after re-registering the DLLs! Edit: The script has been updated to support 64-bit Windows

Solution 2

Some people have reported that  the following command may fix the problem when Solution 1 does not work (first mentioned by snir in the comments):
  1. Open up a Command Prompt (presumably in Administrator  mode) Start > Programs > Accessories > Command Prompt
  2. Type in sfc /scannow and hit Enter
For those for which this solution works, I’d like for someone to find what file(s) were affected and repaired, so we can get a more specific solution and see if it’s related to Solution 1. This solution was one I looked at before I made this post which did not work for me. ]]>

Using batch parameter modifiers to get specific portions or file info from a full filename

Using batch parameters []:

Cmd.exe provides the batch parameter expansion variables %0 through %9. When you use batch parameters in a batch file, %0 is replaced by the batch file name, and %1 through %9 are replaced by the corresponding arguments that you type at the command line
These batch parameter modifiers variable arguments are immensely useful. That document is missing some examples, so I’ve put together a simple table:


Original argument

“C:UsersDMooreDocumentsDocument Name.txt”


Expands %1 and removes any surrounding quotation marks (“”).

C:UsersDMooreDocumentsDocument Name.txt


Expands %1 to a fully qualified path name.

C:UsersDMooreDocumentsDocument Name.txt


Expands %1 to a drive letter.



Expands %1 to a path.



Expands %1 to a file name.

Document Name


Expands %1 to a file extension.



Expanded path contains short names only.



Expands %1 to file attributes.



Expands %1 to date and time of file.

19/08/2009 02:53 p.m.


Expands %1 to size of file. (bytes)



Unit testing multi-threaded, asynchronous code and/or events

ManualResetEvent class (MSDN) seems a good choice for this, and this post has a small example of using it in a unit test:

public void AfterRunAsync()
    ManualResetEvent manualEvent = new ManualResetEvent(false);

    TestTestCase tc = new TestTestCase(1, "", 0, 0);
    bool eventFired = false;
    tc.RunCompleted +=
        delegate(object sender, AsyncCompletedEventArgs e) {
            Assert.IsInstanceOfType(typeof (TestTestCase), sender, "sender is TestCase");
            bool passed = tc.Passed;
            string output = tc.Output;
            eventFired = true;
    manualEvent.WaitOne(500, false);
    Assert.IsTrue(eventFired, "RunCompleted fired");