The correct syntax would be:
configuration.RegisterComponents(r =>
{
r.ConfigureComponent<MyDependency>(DependencyLifecycle.SingleInstance);
...
}
The dependency mechanism will investigate the constructor(s) of the MyDependency type and chooses the simplest one it can completely resolve. So, you'll need to create your MyDependency type like this:
public class MyDependency
{
public MyDependency(IBus bus)
{
}
}
More information in the NServiceBus Documentation
If you only know what type of service you need at runtime, you can use the IServiceProvider service like this:
public class MyDependency
{
public MyDependency(IServiceProvider serviceProvider)
{
...
var myService = (IMyService)serviceProvider.GetService(typeof(IMyService));
...
}
}