TypeScript IntelliSense

We are going to use TypeScript in our product, so imagine my disappointment when I realized that IntelliSense is not working for TypeScript files in Visual Studio 2012, despite it should.

I have tried everything I could – played with VS settings, uninstalled and reinstalled TypeScript, ReSharper, whole Visual Studio… Nothing. Finally, I had to reset my Windows and start from scratch. After two full days completely wasted trying to get IntelliSense working, I finally got to the magic point of having fresh Windows, Visual Studio, and TypeScript. Started it all up, and bang – no IntelliSense again! After pulling some hair out, and crying quietly in the corner, I started second round of uninstalling and installing TypeScript, including older version 0.8.2, Web Essentials, resetting VS settings, etc. Same result. Finally I checked my Visual Studio plugins, and, to my surprise, spotted MySQL Tools for Visual Studio extension, despite I did not want to install it in the first place when MySQL was installed earlier. Removed this plugin, and voila, TypeScript IntelliSense at its best!

What is strange, I have tried to install MySQL server and its Connector/.NET at home (although a newer version 5.6.10.1 package), and surely got the unwelcome MySQL Tools for Visual Studio extension with them. But! The TypeScript IntelliSense works nevertheless, despite a completely different picture was observed at work twice. Go figure.

So, if TypeScript’s IntelliSense is not working, I would recommend to remove all extensions, starting from those more exotic (e.g. MySQL, and those less used by wide population) – it might actually repair the thing.

Visual Studio Behind Proxy: Expectation Failed

We have a transparent proxy at work, and it was causing troubles in Visual Studio 2012 when going to the Extensions and Updates. Contrary to your expectations, “The remote server returned an unexpected response: (417) Expectation failed” message was appearing. The fix is pretty easy, and involves editing devenv.exe.config file in the Visual Studio 2012 folder (normally C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\). Somewhere towards the end of that file there is a

<system.net>
    <settings>
        <ipv6 enabled="true"/>
    </settings>
</system.net>

fragment, which has to be fixed to read

<system.net>
    <settings>
        <ipv6 enabled="true"/>
        <servicePointManager expect100Continue="false"/>
    </settings>
</system.net>

That’s it.

Windows Phone 8 SDK + VirtualBox = Problem

Just installed the Windows Phone 8 SDK and got disappointed when running the sample app on the phone emulator failed with the following cryptic message:

The Windows Phone Emulator wasn’t able to create the virtual machine. Something happened while creating a switch: Xde couldn’t find an IPv4 address for the host machine.

Some people suggested that the problem might be related to the VirtualBox being installed on the machine (I had it). Uninstalling VirtualBox helped, although it is a bit annoying, as I need VirtualBox to access my work VPN.

Toolbox Scrollbar Disappeared in Visual Studio

My colleague just hit into a problem with his Visual Studio 2012 – the Toolbox (the one keeping UI controls) lost its scrollbar. The scrollbar was appearing if he was filtering controls by name, and disappearing again when filtering was off. After searching a bit on the net I found that people were seeing the same problem in Visual Studio 2010 as well. The workaround Barney Nicholls, that post’s author, proposes for Visual Studio 2010 involves deleting toolbox*.* files from the Visual Studio settings’ folder:

  1. Close Visual Studio.
  2. Delete toolbox settings using the commands below.
  3. Start Visual Studio.

The commands (script) to delete the toolbox settings (those files are normally hidden, thus we need to remove the hidden file attribute before):

attrib -h %userprofile%\appdata\local\microsoft\visualstudio\10.0\toolbox*.*
del %userprofile%\appdata\local\microsoft\visualstudio\10.0\toolbox*.*

Needless to say, that this worked for Visual Studio 2012 as well – just substitute 10.0 with 11.0 in the commands above. And, of course, you can perform these operations in Explorer, FAR, or any other file manager as well.

PS Just occurred to me, that there is one more problem, similar in its nature, but with different symptoms – IntelliSense stops working after some actions, e.g. renaming some function. Usually, deleting the hidden .suo file with the same name as the solution .sol file and located in the same folder as the solution file resolves the problem. Of course, Visual Studio must be closed when performing this operation.

Managed/Native Debugging in C#/C++

I had a problem debugging my solution consisting of C#, C++/CLI, and native C++ projects. I was not able to get breakpoints working in the native C++ parts – after running the solution with breakpoints set, they were turning gray with warning sign, and their tooltip stated that “The breakpoint will not currently be hit. No symbols have been loaded for this document.” despite all debug properties were set right on those projects and all debugging symbols existed. After fighting it for a few hours and almost giving up, I started to think that the problem might not be with the native C++ projects, but rather somewhere else, e.g. in the StartUp project, which is C#. Checked that project’s properties, and guess what! Debug > Enable unmanged code debugging option was off!!! Switched it on, and voila – breakpoints work fine in native C++ DLL now!!! :)

Debugging MSBuild Scripts (VS2010)

I did not actively search for the subject, but once I bumped into a three-part article about the MSBuild script debugging (Part I, Part II, Part III) on The Visual Studio Blog I immediately though that it is worth remembering about it when (I am not saying if, but rather when here) I need it in the future. The blog itself is also worth checking, as there is much information about VS IDE, MSBuild, and extensibility from the Visual Studio development team.

Help in the Visual Studio 2010

Mmmmm… I don’t know what kind of daemon possessed Microsoft usability engineers when they were designing Visual Studio 2010 help system, but something definitely went very-very-very wrong. :( What’s wrong, you might ask?

  • It opens in a web browser, which kind of sucks as it breaks my normal work-flow (I have to track help tabs in browser, and then close them, and if I open some new tabs, then help is not in place I expect it, etc. etc. etc.)
  • It’s content tree (the thing on the left side) is not really a tree anymore – it just shows top-level hierarchy and then also “path” to current topic. No more, no less. And if you need to go to some other topic, you will immediately lose track of previous topic. So, if you want to “browse around” the documentation – tough luck. What’s even more ugly is that the online help can be at least configured to show full content tree, but offline help won’t allow you any customizations.
  • There is no index. Full stop. Yes, yes – N-O—I-N-D-E-X. They say that there is search, but try to find some API related to paths and that you vaguely remember exists and has name PathBlaBlaBla (where BlaBlaBla is some meaningful name) and you will see that the search is as useless as it can only get.

Conclusion: new help system is VS2010 is light years behind that of VS2008 or VS2005.

Can something be done about it? There are at least two partial solutions:

  1. Microsoft Help Viewer Power Tool – simply adds keyword index capability to the Help Viewer, with an option to display help in a standalone window.
  2. Help 3 Viewer goes much further: it shows VS 2010 help in a traditional help viewer (similar to “old” DExplore) with full TOC and Index, and features multiple document tabs. There are other features too, and it can be set as default VS2010 help viewer.

I hope that these tools will help you with your help experience :) .

VS2008 SP1 WPF Designer Hotfix

Microsoft released a hotfix for Visual Studio 2008 SP1 WPF Designer. Following issues have been fixed:

  • When a resource in an external resource dictionary is updated, Visual Studio 2008 crashes.
  • WPF Designer cannot load read-only attached properties, such as the VisualStateManager. VisualStateGroups property.
  • If users or codes set a data binding locally, and then the users or codes clear the data binding, WPF designer reports the following error message: ‘System.Windows.Data.Binding’ is not a valid value for property.
  • If a Win32 project is set as the startup project, WPF Designer cannot load solutions in Visual Studio 2008 or in Visual Studio 2008 Service Pack 1.
  • When you set and then delete the Source property of a WPF WebBrowser control, Visual Studio crashes.
  • When you move a control that uses the MultiTrigger class or the DataTrigger class in the Style class, WPF Designer may generate an InvalidCastException exception.

The package can be dowloaded directly from the MSDN Code Gallery. This hotfix is not needed and you must not install it if you have Silverlight Tools for Visual Studio 2008 SP1 (or plan to install it).

Visual Studio Productivity

It is impossible to use Visual C++ 2008′s IDE, as nothing really works there – no IntelliSence, no refactorings, nothing. The same sad story can be told about the Visual Studio’s XAML editor – it just sucks (by the way, you get much better experience by using Visual Studio’s XML editor to edit XAML files). So, finally I got really tired of this, and decided to do something.

I went through quite many packages, and settled down on two – Visual Assist X for Visual Studio by Whole Tomato ($249 retail) and ReSharper by Jetbrains ($349 retail, although Euro price is 315€, weird).

Visual Assist X is super-great for C++. In fact, it is “Visual C++ IDE made right” kind of tool – fixes all problems existing in VS and adding a lot of nice extra goodies that can really improve your productivity: working IntelliSense, refactorings, code outlining and browsing, searching for symbols, code coloring, etc. etc. etc. Some of the abovementioned features are available for C# and VB.NET as well.

ReSharper is doing similar things for C#, VB.NET and XAML, as well as for ASP.NET, XML, MS Build scripts and NAnt. Finally you can browse XAML files and have the ability to quickly jump to referenced resources!

So far so good. These tools can work together on one Visual Studio 2008 setup seemingly without major issues. The only bad thing I have noticed is their “competition” for IntelliSense in C# – both are showing their pop-ups and it is a bit annoying. This problem is not seen in XAML, as VAX is not supporting XAML, and in C++, as ReSharper is not supporting C++. So far I couldn’t resolve this issue, as I do not see any configuration settings that would allow me to switch off IntelliSense for C# in one tool or another. In the end of the day, it is not major issue and I should say these tools work very well together.

I do not understand, why Microsoft cannot do something similar to what these tools are doing straight out of the box? If Microsoft’s team cannot do this on its own (because they are busy developing one more piece of useless fancy marketing crappy feature), then I do not get why they cannot buy e.g. Whole Tomato? If they were ready to waste billions on Yahoo (which would give them what advantage? and please, do not tell me about advertisement business – I do not understand why Microsoft being software house should go to Internet business “just because”), then they should rather spending miniscule fraction of that cost and get real boost for all the developers that use their unfinished tools and technologies (WPF, VS2008, Blend, you name it). Just my 2 cents…

UPDATE The abovementioned issue with conflicting IntelliSense pop-ups can be partially resolved by switching off IntelliSense support in ReSharper (Options… and then Environment > IntelliSense > General page).

Problem with C++/CLI + ATL Combo

Exactly… Wanted to use ATL (for CComPtr class and some other things) in my C++/CLI project (VS2008 with or without SP1) and… got nice assert on _CrtIsValidHeapPointer(pUserData) in dbgheap.c. Cool! Exactly that was missing to make my day better!

Some investigation, and I had answer to my problem. Actually two answers. Both pretty simple:

  1. As I had /NOENTRY specified in the No Entry Point item in the Linker/Advanced section of the project settings, I could add __DllMainCRTStartup@12 to the Force Symbol References item in the Linker/Input section of the project settings
  2. Alternatively, I could set No Entry Point item in the Linker/Advanced section of the project settings to No (as I said, I had /NOENTRY there)

I have tried both solutions, and both worked; I settled on the latter as more intuitive and clean. Always live, always learn…

Monitoring Last Error Code in Visual Studio

Found this trick in the Jeffrey Richter’s Windows via C/C++ book (in Chapter 1). Visual Studio debugger has a very useful feature – it can monitor the thread’s last error code. You can display this error code together with its text description in the Watch window by typing $err,hr. In case some API call fails, the Watch window will show the error code (the one that would be returned by the GetLastError function). Thanks to the ,hr qualifier, the Watch window shows the error description as well (the string mentioned in the WinError.h header file for the occured error code).

Clone Detective for Visual Studio

Clone Detective for Visual Studio allows you to analyze C# projects for source code that is duplicated somewhere else. I have not tried the tool myself yet, but the idea is really nice. One thing I do not like so far – it needs Java (yes, right, the J-word!) to run.

The tool currently supports only C#, but C++ and VB are promised too, although it is not clear when they will come. Support for these (and some other) languages is already available in the ConQAT toolkit that is used by the Clone Detective, so it might not take very long time.

VS2008 SP1 and .NET 3.5 SP1 are Here!

The long awaited SP1 for .NET 3.5 and Visual Studio 2008 are finally here! ISO is available here and EXE – here. Before installing you need to run Visual Studio 2008 Service Pack Preparation Tool in case you had SP1 beta or some hotfixes installed earlier.

There are also Visual Studio 2008 Service Pack 1 Remote Debugger and Visual Studio 2008 Service Pack 1 Stand-Alone Profiler.

And, of course, here is the .NET Framework 3.5 Service Pack 1 itself, either as a bootstrapper or as a full package. Note, that you do not need these if you are installing VS2008 SP1 – .NET 3.5 SP1 is already included with it.