How do I make sure my service gets registered in the AsyncPackage
of my Visual Studio extension? I have been following a sample from VSSDK-Extensibility-Samples. I have also taken a look at how other extensions do it. I tried to do the same yet I cannot obtain my service from global service provider.
Steps I did:
[Shell.ProvideService(typeof(SMyService), IsAsyncQueryable = true)]
for my async package class[Guid(...)] interface SMyService { }
defined interface in a new filepublic class MyService { }
as service implementation. It is created byCreateServiceAsync
methodvar container = (Shell.IAsyncServiceContainer)this; container.AddService(typeof(SMyService), CreateServiceAsync);
inside ofAsyncPackage.InitializeAsync
method before callingbase.InitializeAsync
Is there something I am missing to make my service accessible from other VS Extextension services?
When I Do AsyncServiceProvider.GlobalProvider.GetServiceAsync(typeof(SMyService))
inside of say MEF component method I get a null.
Do I need to register the service anywhere else?