Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to configure bus from command line application #1964

Closed
davidgladstone opened this issue Feb 16, 2014 · 21 comments
Closed

Failure to configure bus from command line application #1964

davidgladstone opened this issue Feb 16, 2014 · 21 comments
Assignees
Labels
Milestone

Comments

@davidgladstone
Copy link

I have a simple console application that configures a bus (MSMQ) and sends a single message. Between version 4.3.4 and 4.4.0 the application has stopped working with the exception in the stack trace below.

Note that this only happens when running from a command window. It does not happen when running from visual studio (using host process or not). In both cases I am running in a non-elevated context.

In case it is down to user error, here is the guts of the bus configuration code that is failing:

Configure.Serialization.Xml();
bus = Configure.With()
    .Log4Net()
    .DefaultBuilder()
    .UseTransport<Msmq>()
    .UnicastBus()
    .SendOnly();

Here is the exception:

Unhandled Exception: Autofac.Core.DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor()' on type 'UnicastBus'. ---> Index was outside the bounds of the array. (See inner exception for details.) ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at NServiceBus.Unicast.UnicastBus..ctor() in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 41
   at lambda_method(Closure , Object[] )
   at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   --- End of inner exception stack trace ---
   at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Resolving.InstanceLookup.Execute() in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Activators.Reflection.AutowiringPropertyInjector.InjectProperties(IComponentContext context, Object instance, Boolean overrideSetValues) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Registration.ComponentRegistration.RaiseActivating(IComponentContext context, IEnumerable`1 parameters, Object& instance) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Resolving.InstanceLookup.Execute() in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Autofac.Features.Collections.CollectionRegistrationSource.<>c__DisplayClass4.<RegistrationsFor>b__0(IComponentContext c, IEnumerable`1 p) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Resolving.InstanceLookup.Execute() in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Scheduling\ScheduledTask.cs:line 0
   at NServiceBus.ObjectBuilder.Autofac.AutofacObjectBuilder.ResolveAll(IComponentContext container, Type componentType) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\ObjectBuilder\Autofac\AutofacObjectBuilder.cs:line 192
   at NServiceBus.ObjectBuilder.Common.CommonObjectBuilder.BuildAll[T]() in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\ObjectBuilder\Common\CommonObjectBuilder.cs:line 179
   at NServiceBus.Configure.Initialize() in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Configure.cs:line 368
   at NServiceBus.ConfigureExtensions.SendOnly(Configure config) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Config\ConfigureExtensions.cs:line 19
   at DtcTest1.Program.CreateBus() in c:\dev\src\DtcTest1\DtcTest1\Program.cs:line 19
   at DtcTest1.Program.Main(String[] args) in c:\dev\src\DtcTest1\DtcTest1\Program.cs:line 32
@johnsimons
Copy link
Member

Hi @davidgladstone

Is this error being thrown from v4.3.4 or v4.4.0?
Also, you say "It does not happen when running from visual studio", what happens when you run first from VS and the console?

Could it be that the queues are not created and you need to "install" the endpoint?

@davidgladstone
Copy link
Author

Hi @johnsimons,

Thanks for following up.

The failure occurs in 4.4.0. Order does not seem to matter (I was trying this over and over in both the IDE and from a command prompt). This is a send-only endpoint.

The send is to a remote queue so queue configuration should not be a problem. Note that I never get to the bus.Send() operation.

David

@johnsimons
Copy link
Member

Found the bug @davidgladstone

It looks like https://github.com/Particular/NServiceBus/blob/develop/src/NServiceBus.Core/Hosting/HostInformation.cs#L17 is the culprid, we need to fix this cc @andreasohlund @SimonCropp

A workaround for now is to double quote the exe name, eg if your project output is Program1.exe then from the cmd line run it as "Program1.exe" or "C:\Mypath\Program1.exe" <- With the double quotes

@davidgladstone
Copy link
Author

Hi @johnsimons

I can confirm that your workaround is successful in my situation.

Thanks.

@andreasohlund andreasohlund added this to the 4.5.0 milestone Feb 17, 2014
@Erwinvandervalk
Copy link

This issue also appears to occur when trying to start the application as an Azure worker role. I'm using NServiceBus.Azure 5.1.0 and NServicebus 4.4.0. Any thoughts on how to go around this in azure?

@yvesgoeleven
Copy link
Contributor

Erwin, are you referring to a regular worker role entrypoint, or when running as a child process on an azure worker role entrypoint?

@Erwinvandervalk
Copy link

Hi yves,

Right now i'm running as a regular worker role entrypoint.

Here's the exception:
Calling constructor NServiceBus.Unicast.UnicastBus()
---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
at NServiceBus.Hosting.HostInformation.CreateDefault() in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Hosting\HostInformation.cs:line 17
at NServiceBus.Unicast.UnicastBus..ctor() in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Unicast\UnicastBus.cs:line 34
at BuildUp_NServiceBus.Unicast.UnicastBus(IBuilderContext )

Thanks,
Erwin

@yvesgoeleven
Copy link
Contributor

Don't think there is a workaround for windows azure role entrypoints, we need to fix this. Also a mistery to me how this did not occur when testing 5.1 release

@Erwinvandervalk
Copy link

Would switching to the child processes entrypoint provide a workaround?

@yvesgoeleven
Copy link
Contributor

For local debug it would yes, you could pass in the command line info required here. But for production hosting it still would'nt work

@andreasohlund andreasohlund modified the milestones: 4.3.5, 4.5.0 Feb 25, 2014
@yvesgoeleven
Copy link
Contributor

Fixed in 6678625

@jakejscott
Copy link

Boom! Stoked I found this on here we just ran into the exact same issue wow

@Erwinvandervalk
Copy link

Very nice that this issue is fixed!

Any thoughts on when this is available on nuget?

@andreasohlund
Copy link
Member

It was released 2 days ago

On Fri, Feb 28, 2014 at 10:31 AM, Erwinvandervalk
notifications@github.comwrote:

Very nice that this issue is fixed!

Any thoughts on when this is available on nuget?

Thanks,
Erwin

From: John Simons [mailto:notifications@github.com]
Sent: woensdag 26 februari 2014 04:19
To: Particular/NServiceBus
Cc: Erwin van der Valk
Subject: Re: [NServiceBus] Failure to configure bus from command line
application (#1964)

Closed #1964#1964.

Reply to this email directly or view it on GitHub<
https://github.com/Particular/NServiceBus/issues/1964>.

Reply to this email directly or view it on GitHubhttps://github.com//issues/1964#issuecomment-36334322
.

@Erwinvandervalk
Copy link

.Sorry, I was looking at the wrong package (nservicebus.azure). Thanks!

@andreasohlund
Copy link
Member

No worries!

Please lets us know if you have any issues!

On Fri, Feb 28, 2014 at 10:38 AM, Erwinvandervalk
notifications@github.comwrote:

.Sorry, I was looking at the wrong package (nservicebus.azure). Thanks!

Sent from my Windows Phone


From: Andreas Öhlundmailto:notifications@github.com
Sent: 28-2-2014 10:34
To: Particular/NServiceBusmailto:NServiceBus@noreply.github.com
Cc: Erwin van der Valkmailto:erwin@ireckon.nl
Subject: Re: [NServiceBus] Failure to configure bus from command line
application (#1964)

It was released 2 days ago

On Fri, Feb 28, 2014 at 10:31 AM, Erwinvandervalk
notifications@github.comwrote:

Very nice that this issue is fixed!

Any thoughts on when this is available on nuget?

Thanks,
Erwin

From: John Simons [mailto:notifications@github.com]
Sent: woensdag 26 februari 2014 04:19
To: Particular/NServiceBus
Cc: Erwin van der Valk
Subject: Re: [NServiceBus] Failure to configure bus from command line
application (#1964)

Closed #1964#1964.

Reply to this email directly or view it on GitHub<
https://github.com/Particular/NServiceBus/issues/1964>.

Reply to this email directly or view it on GitHub<
https://github.com/Particular/NServiceBus/issues/1964#issuecomment-36334322>

.

Reply to this email directly or view it on GitHub<
https://github.com/Particular/NServiceBus/issues/1964#issuecomment-36334487>.

Reply to this email directly or view it on GitHubhttps://github.com//issues/1964#issuecomment-36334785
.

@larshagrot
Copy link

Hi!
I got this behavior in a worker role but not when I run it in the emulator.
In what package and version is this/will this be fixed.
Regards
Lars

@andreasohlund
Copy link
Member

It was fixed in 4.4.1

On Thu, Mar 20, 2014 at 6:55 PM, larshagrot notifications@github.comwrote:

Hi!
I got this behavior in a worker role but not when I run it in the emulator.
In what package and version is this/will this be fixed.
Regards
Lars

Reply to this email directly or view it on GitHubhttps://github.com//issues/1964#issuecomment-38199763
.

@SimonCropp
Copy link
Contributor

@larshagrot can you please confirm what version you are using.

@larshagrot
Copy link

I was using 4.4.0 and NServiceBus.Azure 5.1.0
This morning I upgraded to 4.4.2 and 5.1.1 and got rid of the problem

I am verifying a configuration where we run NServiceBus in Azure worker roles and connect them with NServiceBus run on premise as Windows Services. The worker roles hooks up on an Azure Network subnet which is connected to by VPN (S2S). The transport is MSMQ.

Thank you for your attention.

@yvesgoeleven
Copy link
Contributor

@larshagrot Are you planning to run msmq in azure through VPN? If so, please don't do that, you'll get into trouble

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants