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

FileLoadException #59

Closed
elliotritchie opened this issue Jun 5, 2011 · 13 comments
Closed

FileLoadException #59

elliotritchie opened this issue Jun 5, 2011 · 13 comments
Assignees
Milestone

Comments

@elliotritchie
Copy link

A FileLoadException (Could not load file or assembly. Access is denied.) is being thrown by the HostServiceLocator on line 25 (NServiceBus v2.5) when starting many endpoints simultaneously (Easy to repro with 20+ endpoints). This doesn't seem to be a problem with windows file system permissions or background indexers/virus scanners deadlocking the files.

Magnum.StateMachine.StateMachineException was unhandled
Message=Exception occurred in
Topshelf.Internal.ServiceController`1[[NServiceBus.Host.Internal.GenericHost,
NServiceBus.Host, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=9fc386479f8a226c]] during state Initial while handling OnStart
Source=NServiceBus.Host
StackTrace:
Server stack trace:
at Magnum.StateMachine.ExceptionActionDictionary`1.HandleException(T
stateMachine, Event event, Object parameter, Exception exception)
at Magnum.StateMachine.EventActionList`1.Execute(T stateMachine, Event
event, Object parameter)
at Magnum.StateMachine.State`1.RaiseEvent(T instance, BasicEvent`1
eevent, Object value)
at Magnum.StateMachine.StateMachine`1.RaiseEvent(Event raised)
at
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr
md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext,
Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage
msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at Topshelf.Internal.ServiceControllerProxy.Start()
at Topshelf.Internal.ServiceCoordinator.Start()
at Topshelf.Internal.Hosts.ConsoleHost.Run()
at NServiceBus.Host.Program.Main(String[] args)
InnerException:
Message=Exception when starting endpoint, error has been logged. Reason:
Could not load file or assembly 'file:///MyEndpoint.dll' or one of its dependencies.
Access is denied.
Source=NServiceBus.Host
StackTrace:
at NServiceBus.Host.Internal.GenericHost.Start()
at Magnum.StateMachine.EventActionList`1.Execute(T stateMachine,
Event event, Object parameter)
InnerException:
@andreasohlund
Copy link
Member

What container are you using? ( structuremap?)
http://andreasohlund.net

http://twitter.com/andreasohlund

Date: Sun, 5 Jun 2011 14:08:13 -0700
From: reply@reply.github.com
To: andreas_ohlund@hotmail.com
Subject: [NServiceBus] FileLoadException (#59)

A FileLoadException (Could not load file or assembly. Access is denied.) is being thrown by the HostServiceLocator on line 25 (NServiceBus v2.5) when starting many endpoints simultaneously (Easy to repro with 20+ endpoints). This doesn't seem to be a problem with windows file system permissions or background indexers/virus scanners deadlocking the files.

Magnum.StateMachine.StateMachineException was unhandled
Message=Exception occurred in
Topshelf.Internal.ServiceController`1[[NServiceBus.Host.Internal.GenericHost,
NServiceBus.Host, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=9fc386479f8a226c]] during state Initial while handling OnStart
Source=NServiceBus.Host
StackTrace:
Server stack trace:
at Magnum.StateMachine.ExceptionActionDictionary`1.HandleException(T
stateMachine, Event event, Object parameter, Exception exception)
at Magnum.StateMachine.EventActionList`1.Execute(T stateMachine, Event
event, Object parameter)
at Magnum.StateMachine.State`1.RaiseEvent(T instance, BasicEvent`1
eevent, Object value)
at Magnum.StateMachine.StateMachine`1.RaiseEvent(Event raised)
at
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr
md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext,
Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage
msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at Topshelf.Internal.ServiceControllerProxy.Start()
at Topshelf.Internal.ServiceCoordinator.Start()
at Topshelf.Internal.Hosts.ConsoleHost.Run()
at NServiceBus.Host.Program.Main(String[] args)
InnerException:
Message=Exception when starting endpoint, error has been logged. Reason:
Could not load file or assembly 'file:///MyEndpoint.dll' or one of its dependencies.
Access is denied.
Source=NServiceBus.Host
StackTrace:
at NServiceBus.Host.Internal.GenericHost.Start()
at Magnum.StateMachine.EventActionList`1.Execute(T stateMachine,
Event event, Object parameter)
InnerException:

Reply to this email directly or view it on GitHub:
#59

@elliotritchie
Copy link
Author

StructureMap v2.6.2

@joliver
Copy link

joliver commented Jun 7, 2011

I've encountered this exact error as well--and I'm using Autofac. The trouble is that it cannot be consistently reproduced. I'm actually wondering if it's a bug in the .NET framework relative to locks during file loading...

@PeterLehmann
Copy link

I have seen this problem with one assembly is x64 and rest is anyCpu.
nservicebus.host is x86 and then you get this error

@Bishbulb
Copy link
Contributor

I am also experiencing this issue quite regularly. I have 12 handlers that I'm trying to start simultaneously, and about 40% of the time I get the Access is denied error.

Any more thoughts on what could be causing this?

@andreasohlund
Copy link
Member

We had troubles reproducing. Can you reliably reproduce the issue?

Sent from my iPhone

On 31 jan 2012, at 03:28, Dan Bishop
reply@reply.github.com
wrote:

I am also experiencing this issue quite regularly. I have 12 handlers that I'm trying to start simultaneously, and about 40% of the time I get the Access is denied error.

Any more thoughts on what could be causing this?


Reply to this email directly or view it on GitHub:
#59 (comment)

@Bishbulb
Copy link
Contributor

Bishbulb commented Feb 1, 2012

Yes, I can reproduce it quite regularly. It doesn't happen every time I start up a number of projects, but the problem is definitely worse as the number of projects increases above ~10. If I try to load ~20 handlers simultaneously (via F5 in Visual Studio), I will almost always get the error. This of course makes it difficult to do full integration testing on a developer machine.

On average, the handlers that I'm starting have about 20 DLLs in their \bin\Debug directory, in case that is relevant.

@lcorneliussen
Copy link
Contributor

I also have that issue quite often. I think you should talk to the MEF team (Glenn Block); they have been fiddling alot with assembly loading. I'm quite sure that can be fixed with a combination of using separate app domains for introspection + retries.

@daltondfranklin
Copy link

Our project has been plagued by this issue and we have had to literally put sleep statements within the batch files that start many endpoints. I can reproduce the scenario consistently. To do so, I created a solution with 40 projects that reference only log4net and NServiceBus assemblies and have nothing other than an app.Config file and a class that implements IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization. In order to reproduce the scenario, I run a script that clears the contents of the global assembly download cache (gacutil.exe /cdl) and then executes a powershell script that runs NServiceBus.Host.Exe from within the various build directories in my solution. Note that I am not doing anything to intentionally put anything in the GAC. Any help would be IMMENSELY appreciated.

@johnsimons
Copy link
Member

Here is a project that replicates this issue - https://github.com/johnsimons/FileLoadException

@ghost ghost assigned johnsimons Jul 10, 2012
@johnsimons
Copy link
Member

I nearly gave up!
But then Process Monitor came to the rescue :)

@daltondfranklin
Copy link

I'm curious how you recognized the shadow copy service. I watched in
process monitor quite a bit myself and couldn't nail it down.

On Jul 9, 2012, at 10:07 PM, John Simons
reply@reply.github.com
wrote:

I nearly gave up!
But then Process Monitor came to the rescue :)


Reply to this email directly or view it on GitHub:
#59 (comment)

@johnsimons
Copy link
Member

It was a lucky shot ;)

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

No branches or pull requests

8 participants