DateTime.UtcNow is generally preferable to DateTime.Now

This seems to be commonly known and accepted best practice to use DateTime.UtcNow for non-user facing scenarios such as time interval and timeout measurement. I’ve just done an audit of the Roslyn codebase and replaced most DateTime.Now calls with DateTime.UtcNow. I thought it’d be useful to post my changeset description here (although none of it…

9

How to get DTE from Visual Studio process ID?

DTE is an automation framework that is used to programmatically control Visual Studio, often from another process. It internally uses COM remoting to execute commands from another process on the VS UI thread. A while back I have written about How to start Visual Studio programmatically and get the DTE object to control the devenv.exe…

5

' is in XML, in HTML use '

I just got hit by a very confusing "by design" behavior and it took me a while to figure out what’s going on. Here is the line of code: text = System.Security.SecurityElement.Escape(text); This method replaces invalid XML characters in a string with their valid XML equivalent. The problem that I had is that when escaping…

6

Unable to cast COM object … to IVsGlobalUndoCapableUndoManager

Hi all, sorry for the absense – we’re all really busy fixing Visual Studio 2010 performance, memory consumption, improving stability and fixing last minute bugs. Good news: if you’re seeing this: Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘Microsoft.VisualStudio.Editor.Implementation.IVsGlobalUndoCapableUndoManager’. This operation failed because the QueryInterface call on the COM component for…

3

Saving images (.bmp, .png, etc) in WPF/Silverlight

I’ve recently added a new feature to Live Geometry that allows users to save the current drawing as a bitmap or a .png file. Just push the save button and pick the desired image format in the Save dialog: Fortunately, both WPF and Silverlight support saving full visual contents of any visual into a file…

10

Dump Environment Folder Paths

This is just a quick snippet to dump the value of Environment.GetFolderPath for all special folders on a machine (so I don’t have to write it again next time): public static string DumpEnvironmentPaths() { var paths = Enum.GetValues(typeof(Environment.SpecialFolder)) .Cast<Environment.SpecialFolder>() .Select(folder => folder + " = " + Environment.GetFolderPath(folder)) .Aggregate((line1, line2) => line1 + Environment.NewLine +…

7

Tip: Don’t enter your CodePlex credentials every time

I just ran across an awesome tip at Scott’s blog that is going to save me a whole lot of time: Save Your Codeplex Repository Credentials I was entering my username and password everytime I connected to a CodePlex TFS server. Now I don’t have to! P.S. To make this work on XP, go to…

0

Visual Studio disappears when creating a Silverlight 3 Application

I have Visual Studio 2008 SP1 and Silverlight 3 tools on the laptop I’m writing this post on. Ten minutes ago I was trying to create a new Silverlight 3 application through the New Project Dialog and after creating the project Visual Studio just disappeared on me. Usually when VS disappears instantly without the Watson…

2

Visual Studio 2010 Beta1 + TFS + HTTPS (TF31001): The ServicePointManager does not support proxies with the https scheme.

This is just a little note to myself and others who might run into this. I was using Visual Studio 2010 and Team Foundation Client to access a CodePlex project over HTTPS (port 443), and got this error message: ————————— Microsoft Visual Studio ————————— Microsoft Visual Studio TF31001: Cannot connect to Team Foundation Server at…

1

Remote Desktop: /span across multiple monitors

I spent some time searching the web about Remote Desktop, fullscreen and multiple monitors, so I decided to write down my findings to avoid having to search for them again. /span for multiple monitors If you pass /span to mstsc.exe, the target session’s desktop will become a huge rectangle that equals to the summary area…

24