CTC Files and Package Delay Loading

VSIP Extras certainly does a lot to help out with moving into the managed code world for package writers, but it seems that you still can't escape native code entirely. One of the things you may notice if you use the package wizard is that even when you create a package in C#, one of the projects in the resulting solution is in C++. As much as I'd like to say this is a bug that we missed, sadly this is by design. :) Most of the files in the project should be recognized by a C++ developer: .h, .bmp, .ico, .rc.....pretty standard. However, there is a strange file there with an extension of “.ctc” that appears to be some kind of pseudo-C++ syntax. What is this file? What is it for?

Have you ever noticed that the first time you access a major set of features in Visual Studio that it may take a few extra seconds to load? This is partially because of memory caching, but primarily because of package delay loading in Visual Studio. This means that Visual Studio will not load your package (or any package) until it absolutely has to. It wouldn't make much sense to make you sit there and wait while Visual Studio loads up all it's packages for Visual Basic, C++, HTML, XML, etc.... when all you want to do right now is edit a C# file.

This is a good design, but what happens when you want a menu command or some other UI to appear when the user first launches Visual Studio? This is where a CTC file comes into play. The CTC file tells Visual Studio what UI your package offers. When a user interacts with that UI element (e.g. selects your menu item), then your package is loaded into the Visual Studio process. The details of what's going on between a .ctc file and actual UI I'll save for another blog entry.