Вопрос

i am trying to use NLog along with Rebus but i am getting an exception: Cannot access the constructor of type: Rebus.Configuration.RebusConfigurer. Is the required permission granted?

adapter.Register(() => new DownloadHandler());

            Configure.With(adapter)
                .Logging(l => l.NLog())
                .Transport(t => t.UseMsmq("my.input", "my.error"))
                .CreateBus()
                .Start();

Any clues?

For clarification both packages are 0.32.3 and stacktrace is:

   at NLog.Internal.FactoryHelper.CreateInstance(Type t)
   at NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey)
   at NLog.LogFactory.GetLogger(String name, Type loggerType)
   at NLog.LogManager.GetCurrentClassLogger(Type loggerType)
   at Rebus.NLog.NLogLoggerFactory.GetLogger(Type type)
   at Rebus.Logging.AbstractRebusLoggerFactory.GetCurrentClassLogger()
   at Rebus.Configuration.RebusConfigurer.<.cctor>b__0(IRebusLoggerFactory f)
   at Rebus.Logging.RebusLoggerFactory.<>c__DisplayClass1.<set_Current>b__0(Action`1 h)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at Rebus.Logging.RebusLoggerFactory.set_Current(IRebusLoggerFactory value)
   at Rebus.Configuration.ConfigurationBackbone.set_LoggerFactory(IRebusLoggerFactory value)
   at Rebus.Configuration.LoggingConfigurer.Use(IRebusLoggerFactory loggerFactory)
   at Rebus.NLog.NLogLoggingExtension.NLog(LoggingConfigurer configurer)
   at OpenTokDownloader.OpenTokDownloader.<Start>b__2(LoggingConfigurer l) in H:\Test\Downloader.cs:line 28
   at Rebus.Configuration.RebusConfigurerWithLogging.Logging(Action`1 configurer)
   at OpenTokDownloader.OpenTokDownloader.Start() in H:\Test\Downloader.cs:line 27
   at OpenTokDownloader.Program.<Main>b__3(OpenTokDownloader tc) in H:\Test\Downloader\Program.cs:line 19
   at Topshelf.ServiceConfiguratorExtensions.<>c__DisplayClass7`1.<WhenStarted>b__6(T service, HostControl control)
   at Topshelf.Builders.DelegateServiceBuilder`1.DelegateServiceHandle.Start(HostControl hostControl)
   at Topshelf.Hosts.ConsoleRunHost.Run()
Это было полезно?

Решение

Turns out there was a bug in Rebus' NLogLoggerFactory that would cause it to ask NLog to try to instantiate and use RebusConfigurer as a logger... as you have experienced, that cannot be done :)

I have fixed the bug, so if you update-packages Rebus.NLog in your solution, you should be good to go!

Thanks for reporting this issue!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top