Exception when use RabbitHutch call "CreateBus" method, version EasyNetQ 0.36.2.308
Hi, I've just created a sample follow this Quick Start https://github.com/mikehadlow/EasyNetQ/wiki/Quick-Start But when I ran this sample, it threw exception on using (var bus = RabbitHutch.CreateBus("host=localhost"))
Exception details:
System.Reflection.TargetInvocationException was unhandled
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at EasyNetQ.DefaultServiceProvider.Resolve(Type serviceType)
at EasyNetQ.DefaultServiceProvider.2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at EasyNetQ.DefaultServiceProvider.CreateServiceInstance(Type implementationType)
at EasyNetQ.DefaultServiceProvider.ResolveTService
at EasyNetQ.RabbitHutch.CreateBus(IConnectionConfiguration connectionConfiguration, Action1 registerServices) at EasyNetQ.RabbitHutch.CreateBus(String connectionString, Action1 registerServices)
at EasyNetQ.RabbitHutch.CreateBus(String connectionString)
at EasynetQSender.Program.Main(String[] args) in C:\Users\ricky.nguyen\Documents\Visual Studio 2010\Projects\RabbitMQ\EasynetQSender\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Reflection.TargetInvocationException
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at EasyNetQ.DefaultServiceProvider.Resolve(Type serviceType)
at EasyNetQ.DefaultServiceProvider.2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at EasyNetQ.DefaultServiceProvider.CreateServiceInstance(Type implementationType)
at EasyNetQ.DefaultServiceProvider.ResolveTService
InnerException: System.Reflection.TargetInvocationException
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at EasyNetQ.DefaultServiceProvider.Resolve(Type serviceType)
at EasyNetQ.DefaultServiceProvider.2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at EasyNetQ.DefaultServiceProvider.CreateServiceInstance(Type implementationType)
at EasyNetQ.DefaultServiceProvider.ResolveTService
InnerException: System.Reflection.TargetInvocationException
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at EasyNetQ.DefaultServiceProvider.Resolve(Type serviceType)
at EasyNetQ.DefaultServiceProvider.2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at EasyNetQ.DefaultServiceProvider.CreateServiceInstance(Type implementationType)
at EasyNetQ.DefaultServiceProvider.ResolveTService
InnerException: System.Reflection.TargetInvocationException
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at EasyNetQ.DefaultServiceProvider.Resolve(Type serviceType)
at EasyNetQ.DefaultServiceProvider.2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at EasyNetQ.DefaultServiceProvider.CreateServiceInstance(Type implementationType)
at EasyNetQ.DefaultServiceProvider.ResolveTService
InnerException: System.Reflection.TargetInvocationException
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
at EasyNetQ.DefaultServiceProvider.CreateServiceInstance(Type implementationType)
at EasyNetQ.DefaultServiceProvider.ResolveTService
InnerException: System.IO.FileNotFoundException
HResult=-2147024894
Message=Could not load file or assembly 'System.Collections.Immutable.Net40, Version=1.0.27.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Source=EasyNetQ
FileName=System.Collections.Immutable.Net40, Version=1.0.27.0, Culture=neutral, PublicKeyToken=null
FusionLog==== Pre-bind state information ===
LOG: DisplayName = System.Collections.Immutable.Net40, Version=1.0.27.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Users/ricky.nguyen/Documents/Visual Studio 2010/Projects/RabbitMQ/EasynetQSender/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : EasyNetQ, Version=0.36.2.308, Culture=neutral, PublicKeyToken=null.
LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\ricky.nguyen\Documents\Visual Studio 2010\Projects\RabbitMQ\EasynetQSender\bin\Debug\EasynetQSender.vshost.exe.config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///C:/Users/ricky.nguyen/Documents/Visual Studio 2010/Projects/RabbitMQ/EasynetQSender/bin/Debug/System.Collections.Immutable.Net40.DLL. LOG: Attempting download of new URL file:///C:/Users/ricky.nguyen/Documents/Visual Studio 2010/Projects/RabbitMQ/EasynetQSender/bin/Debug/System.Collections.Immutable.Net40/System.Collections.Immutable.Net40.DLL. LOG: Attempting download of new URL file:///C:/Users/ricky.nguyen/Documents/Visual Studio 2010/Projects/RabbitMQ/EasynetQSender/bin/Debug/System.Collections.Immutable.Net40.EXE. LOG: Attempting download of new URL file:///C:/Users/ricky.nguyen/Documents/Visual Studio 2010/Projects/RabbitMQ/EasynetQSender/bin/Debug/System.Collections.Immutable.Net40/System.Collections.Immutable.Net40.EXE.
StackTrace:
at EasyNetQ.EventBus..ctor()
InnerException:
When i install older version, it works well. Please fix this issue. Thanks,
I suspect this is due to pull request #282. It pulls in a .NET 4.5 library that cannot be installed via NuGet on to .NET 4 targeted applications.
:+1: I confirm, I have the same problem with EasyNetQ version 0.36.2.308:
the inner exception to look at is:
InnerException: System.IO.FileNotFoundException
HResult=-2147024894
Message=Could not load file or assembly 'System.Collections.Immutable.Net40, Version=1.0.27.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Source=EasyNetQ
FileName=System.Collections.Immutable.Net40, Version=1.0.27.0, Culture=neutral, PublicKeyToken=null
so it is a System.IO.FileNotFoundException, @mikehadlow do you forgot to embed the assembly using ILRepack?
In the meanwhile a easy/fast work around is to manually add the dependency on your project using nuget, just write this in the "Package Manager Console":
Install-Package System.Collections.Immutable.Net40 -Version 1.0.27
Hi
I am the one responsible for pull request https://github.com/mikehadlow/EasyNetQ/pull/282. I don't believe that it brings any .NET 4.5 libraries, but you are unfortunately correct that my pull request broke EasyNetQ. Unfortunately I wasn't aware that i had to add the new dependency to the EasyNetQ.nuspec file. I have just made a new pull request https://github.com/mikehadlow/EasyNetQ/pull/285