This project has moved. For the latest updates, please go here.

How to register more than one file extension?

Feb 14, 2011 at 11:52 PM
Edited Feb 14, 2011 at 11:54 PM


How do I register the shell extension for more than one file extension?

For example, I tried to do the following:

1. unregister VvvSample.dll if it is already registered

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /u "C:\codeplex\mmsf\VvvSample\bin\Debug\VvvSample.dll"



Line 21, add the following line to associate with ".sln" files: 

RootKey.Register(".sln", ProgId);

Line 31, add the following line to remove the association with ".sln" files: 


3. rebuild VvvSample.dll (in debug mode)

4. C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /codebase "C:\codeplex\mmsf\VvvSample\bin\Debug\VvvSample.dll"

5. kill explorer.exe

6. re-launch explorer, and attach to it in Visual Studio 2010 for debugging purposes.

But then when I right-click on an sln file, neither the ContextMenu constructor not the QueryContextMenuCore method get called.

.mvvv files still work as expected.

Note that .sln files already had "OpenWithProgId" associations in HKCR (ex. Visual Studio 2010 and Expression Blend 4).


I am running on Windows 7 Ultimate x64.


Any advice?


Thank you.

Feb 17, 2011 at 9:31 PM

I will try to look at this issue at the weekend. 

Feb 19, 2011 at 10:24 PM

If you want to add an ContextMenu extension to a file extension that is already present and actually owned by another application (Visual Studio in this case) some steps are needed:

1) Get the ProgId that the application is using (I have added a helper function it the latest code, but most of the time this ProdId is fixed)


public static void ComRegisterFunction(Type type)
  string slnProgId;

  if (RootKey.TryGetProgIdForFileExension(".sln", out slnProgId))
    ComRegister(type, "VVV ContextMenu (MMSF Sample)", slnProgId);


2) Add the file extension in the ContextMenu constructor:


3) Don't remove the file extension or the ProdId when uninstalling your shell extension, otherwise the user will lose the connection between .sln and the app Visual Studio)

4) If your shell exension is installed before Visual Studio is installed, you will need to add .sln and ProgId. Again during uninstall, keep those entries untouched.

With these changes I got it working on Windows 7 Sp1 x64



Feb 20, 2011 at 9:17 PM

Thank you; it works great! :)