_builder = new ContainerBuilder();
_builder.RegisterInstance(
BusClientFactory.CreateDefault()).As<IBusClient>().SingleInstance();
But this throws an exception with a not really helpful error:
_builder = new ContainerBuilder();
_builder.RegisterInstance(
BusClientFactory.CreateDefault(new RawRabbitConfiguration
{
Username = "guest",
Password = "guest",
Port = port,
Hostnames = new List<string> {host}
})).As<IBusClient>().SingleInstance();
Exception
String reference not set to an instance of a String.
Parameter name: s
Stacktrace
at RawRabbit.Channel.ChannelFactory..ctor(IConnectionFactory connectionFactory, RawRabbitConfiguration config, ChannelFactoryConfiguration channelConfig)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.TransientCallSite.Invoke(ServiceProvider provider)
at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance[T](IServiceProvider provider, Object[] parameters)
at RawRabbit.vNext.IServiceCollectionExtensions.<>c.<AddRawRabbit>b__0_0(IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at RawRabbit.vNext.BusClientFactory.CreateDefault(IServiceCollection services)
at RawRabbit.Topshelf.RawShelf`1..ctor(String host, UInt16 port) in C:\Users\CMENGU\Desktop\RawRabbit.Topshelf\src\RawRabbit.Topshelf\RawShelf.cs:line 18
at RawRabbit.Topshelf.Demo.Program.Main(String[] args) in C:\Users\CMENGU\Desktop\RawRabbit.Topshelf\src\RawRabbit.Topshelf.Demo\Program.cs:line 12
I am probably doing something wrong but error doesn't really say what's going on
If you just new up the configuration all strings will have their default values (null). My guess is that you haven't declared Vhost, which cannot be null.
This works OK
But this throws an exception with a not really helpful error:
Exception
Stacktrace
I am probably doing something wrong but error doesn't really say what's going on