I seem to be having a problem since updating my version of Windows on my dev machine. I can’t seem to be able to launch a web app (asp.net core 2.0.0 on full .net framework 4.6.2) with NServiceBus (version 6) endpoint without encountering a FileLoadException.
This happens during assembly scanning and it seems to only be an issue when the machine is updated to the latest Fall Creators Update on Windows 10 Pro (update version 1709). Assembly scanning was working fine prior to updating and seems to work again after rolling the update back.
I am using the included msmq transport, NewtosoftSerializer (version 1.1.0) and ServiceControl.Plugin.Nsb6.Heartbeat (version 3.0.1)
The stack trace I get is (with personal information redacted)…
{System.IO.FileLoadException: API restriction: The assembly 'file:///<WEB APP LOCATION>\bin\Debug\net462\netstandard.dll' has already loaded from a different location. It cannot be loaded from a new location within the same appdomain.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)
at NServiceBus.Hosting.Helpers.AssemblyScanner.ReferencesNServiceBus(String assemblyPath)
at NServiceBus.Hosting.Helpers.AssemblyScanner.ScanAssembly(String assemblyPath, AssemblyScannerResults results)
at NServiceBus.Hosting.Helpers.AssemblyScanner.GetScannableAssemblies()
at NServiceBus.EndpointConfiguration.GetAllowedTypes(String path)
at NServiceBus.EndpointConfiguration.Build()
at NServiceBus.Endpoint.Create(EndpointConfiguration configuration)
at NServiceBus.Endpoint.<Start>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at <WEB APP NAME>.Startup.ConfigureServices(IServiceCollection services) in <WEB APP LOCATION>\Startup.cs:line 118
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at <WEB APP NAME>.Program.BuildWebHost(String[] args) in <WEB APP LOCATION>\Program.cs:line 15
at <WEB APP NAME>.Program.Main(String[] args) in <WEB APP LOCATION>\Program.cs:line 11}
Any ideas what may be causing this issue?