Browse by Tags

Tagged Content List
  • Blog Post: Warning: DataContractSerializer won’t call your constructor!

    Consider the following naïve data contract: [DataContract] public class Data { private int [] array; public Data() { this .array = new int [13]; } public int Length { get { return this .array.Length; } } } It looks ok, right? Let’s use it then: DataContractSerializer serializer = new...
  • Blog Post: Running a SQL Statement on all Databases

    exec sp_MsForEachDB 'SELECT "?", 1' The ? will be replaced by the current database name. To run a query that references a table, you need to make sure that the table exists first, as this query will run on system databases as well.
  • Blog Post: Adding HTTP Headers to WCF Calls

    To add HTTP headers, request messages have to be intercepted before they are sent to the server. This can be done by implementing the IClientMessageInspector.BeforeSendRequest method: /// <summary> /// Represents a message inspector object that can be added to the <c>MessageInspectors<...
  • Blog Post: Extending XElement to Match Child Elements by LocalName

    If you want to ignore the child elements’ namespaces, and match by local name only, you can do something similar to the following: /// <summary> /// Represents an extension for <see cref="XElement"/>. /// </summary> internal static class XElementExtension { /// <summary>...
  • Blog Post: Adding Custom SOAP Headers in WCF

    First, you need to decide whether to create the custom header using the MessageHeader.CreateHeader method, or by extending the abstract MessageHeader class. Under the hood, the CreateHeader method returns an instance of an internal class called XmlObjectSerializerHeader, which uses a serializer to write...
  • Blog Post: Overriding an Abstract Property vs. Passing a Parameter

    An abstract class may require a value to be passed through the constructor like the following example: public abstract class Node { private readonly Uri _uri; protected Node( string address, string relativePath) { _uri = new Uri(Path.Combine(address, relativePath)); } } public class Element ...
  • Blog Post: Changing the Foreground Color of an Indeterminate ProgressBar

    You would think that the following XAML changes the indeterminate progress bar’s foreground color: < ProgressBar IsIndeterminate ="True" Foreground ="Aquamarine" /> Unfortunately, that doesn’t work. You will need to override the following value in the default theme resource...
  • Blog Post: Making HTML Elements Scrollable

    I’ve been styling my blog recently to make it more Win8-like (thank you for noticing!). I created some custom CSS file, but I ran into a problem with code. I use wide screens at work and at home, so I tend to break the guidelines and write more than 120 characters in a line of code. When I paste...
  • Blog Post: Windows Store App Settings Flyout

    Prerequisites Please read the following articles first: Guidelines for app settings (Windows Store apps) Quickstart: Adding app settings using Windows Runtime In this post, I’ll be walking through how to create a custom UI for settings (required for C#, C++, and VB) that satisfies the UX design requirements...
  • Blog Post: DefaultNetworkCredentials in Windows Store Apps

    Disclaimer: I'm still getting acquainted with Windows Store Apps, so I could be totally wrong; proceed with caution. It's been a while since I last wrote a blog post, and it's 4 AM right now, this may give you an idea why I had to get this out. Hopefully I may save poor souls that are destined to...
  • Blog Post: How to: Create Interfaces with Static Methods via IL?

    If you try to add a static member to an interface, you will get the following error: The modifier 'static' is not valid for this item In this case, you should create an abstract class instead of an interface, because interfaces are contracts and should not implement any methods. However, it’s...
  • Blog Post: How to: Use Locks and Prevent Deadlocks?

    Multi-threading is used in almost all real-life applications. I summed up my thoughts on use of locks and deadlock prevention in the following related topics: Thread Safety From a thread safety perspective, resources (memory) is classified as either thread-exclusive, read-only, or lock-protected...
  • Blog Post: How to: Debug Deadlocks Using Windbg?

    Attach the debugger to the process Load SOS ~* e !clrstack to view the CLR stack of all the threads and where they are Look for System.Threading.Monitor.Enter(System.Object) in the top frames Load SOSEX.dll from http://www.stevestechspot.com/SOSEXUpdatedV11Available.aspx !dlk to detect...
  • Blog Post: How to: Query All Labels on a Folder Recursively?

    To do this, you can't call query labels with a wildcard character, you need to do the following: - Get all items blow $/Dir1 using GetItems - Loop through them calling QueryLabels on each one. Here's a code snippet: VersionControlServer sc = tfs.GetService< VersionControlServer >(); List < VersionControlLabel...
  • Blog Post: How to: Move a Shelveset to Another Branch?

    A very handy power tool is tfpt unshelve. It’s capable of migrating a shelveset from a branch to another, it does that by performing a baseless merge, so you will need to resolve the conflicts produced. The syntax of the command looks like the following: tfpt unshelve shelvsetName /migrate /source:$...
  • Blog Post: How to: Diff Shelved Files?

    You can run: tf diff /shelveset:shelvesetName;DOMAIN\ownerUserName Please note that this will diff the shelved changes against the unmodified version, not necessarily the latest version, just like what the you get from clicking compare in the shelveset details dialog. If you want to diff the shelved...
  • Blog Post: How to: List Changesets Between Two Labeled Versions?

    You can achieve that behavior by running: tf hist rootItemSpec /r /version:LstartLabel~LendLabel Here’s my scenario: tf hist /i File.cs Changeset Change User Date Comment --------- -------------------------- ------------- ---------- -------- 65 edit mohamedg 4/2/2009 63 edit mohamedg 4/2/2009 60 edit...
  • Blog Post: How to: Switch Between TFS and VSS in Old IDEs?

    If you have an IDE that uses the MSSCCI provider, like VS 2003 or VB6, and you want to switch between TFS and VSS because you have projects on both systems, you will have to change the provider every time you switch. The thing is that setting is stored in the Windows registry, therefore, you will have...
  • Blog Post: How to: Force a Check-in to be Linked to Work Items?

    Well, the answer to this one is pretty easy and straight-forward. You can accomplish that using a check-in policy. For example, to force users to link check-ins to work items that are not closed, you may do the following: Add a Team Query to the desired project, call it "Not Closed" and specify the condition...
  • Blog Post: How to: Change TFS Temp Folder?

    TFS uses a temp folder to get files that you view. The location of that folder is %TMP%\TFSTemp. It’s not configurable via TFS, tf.exe, or Visual Studio. However, you can just set the TMP environment variable. Simply: set TMP=D:\Temp set TEMP=%TMP% md %TMP% Then you can starting using tf.exe afterwards...
  • Blog Post: How to: Copy Workspace Mappings?

    A common scenario that you may see is the need to share/sync workspace mappings amongst team members. A developer adds a new dependency in a certain project and changes his/her mappings to get this library, and everyone else in the team now needs to do the same thing. Since workspace mappings are stored...
  • Blog Post: How to: Switch Branches in a Workspace Without Getting All the Files of the New Branch?

    One of the new features added in VSTF 2008 SP1 is that you can switch to another branch in your workspace and you don’t need to download all the files of the new branch. TFS will only download the files that differ in the new branch, if you use tf get /remap . It will also tell the server that you’re...
  • Blog Post: How to: Move Your Workspace to Another Drive?

    A common problem occurs when the drive that contains your workspaces runs out of disk space, or when you find yourself in a situation that you have to move your workspace to another drive. This might get tricky because your workspace mappings are stored on the server side. TFS knows about the local path...
  • Blog Post: How to Get List of Changes in a Shelveset Programmatically?

    In a previous post , we used the command-line to list the changes in a shelveset. This time we are going to use an API to get the changes by calling: VersionControlServer.QueryShelvedChanges You have to be a valid user that can connect to Version Control, and you don't need a workspace to call this method...
  • Blog Post: How to: List Changes in a Shelveset?

    When you run tf shelvesets shelvesetName /format:detailed you get the shelveset’s name and some metadata associated with it, but not the changes. To get a list of the changes in a changeset, run: tf stat /shelveset:shelvesetName;DOMAIN\ownerUserName The output is similar to that of a workspace.
Page 1 of 3 (52 items) 123