Hi,
I have been investigating the possibility of creating a VSPackage extension to add support for another programming language to visual studio for my final computer science project before graduating university. I am a big fan of automated testing and was glad to see the custom editor template project had some options to automatically generate some test projects for me.
The problem is that even without making a single code change to the code generated by the VSPackage wizard, three of the automatically generated tests fail. The first one I'm going to ask help with, because I suspect it might be leading to the other two, is testing the package's SetSite method. The code for the test is:
[TestMethod()]
public void SetSite()
{
// Create the package
IVsPackage package = new BooLanguageExtensionPackage() as IVsPackage;
Assert.IsNotNull(package, "The object does not implement IVsPackage");
// Create a basic service provider
OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();
// Add site support to register editor factory
BaseMock registerEditor = BooLanguageExtension_UnitTests.EditorTests.RegisterEditorsServiceMock.GetRegisterEditorsInstance();
serviceProvider.AddService(typeof(SVsRegisterEditors), registerEditor, false);
int hr = package.SetSite(serviceProvider);
ErrorHandler.ThrowOnFailure(hr);
// Site the package
Assert.AreEqual(VSConstants.S_OK, hr, "SetSite did not return S_OK");
hr = package.SetSite(null);
// Unsite the package
Assert.AreEqual(VSConstants.S_OK, hr, "SetSite(null) did not return S_OK");
}
The exception I get is: System.InvalidOperationException: The service 'Microsoft.VisualStudio.Shell.Interop.SVsActivityLog' must be installed for this feature to work. Ensure that this service is available. Using step through debugging I discovered the exception is thrown during the call to the SetSite method.
Now if I understood my tutorials correctly, packages are not able to grab services like SVsActivityLog untilafter they've been sited into the visual studio IDE, which makes me wonder why someone is trying to access it already in the SetSite method itself. I double checked the BooLanguageExtensionPackage class it generated for me and it does not override the SetSite method, it inherits it from the Package class.
Furthermore running the project directly it seems to work fine, I can see my package registered in the about window of the experimental hive. Is there perhaps something missing from the above generated code that needs to be done before the call to SetSite?
I am working on VisualStudio 2013 Ultimate on a Windows 7 64 bit OS.