# Upgrade Version 4 to 5 Upgrading a major dependency like NServiceBus requires careful planning, see the [general recommendations](/nservicebus/upgrades/index.md) article to learn more about the optimal upgrade process. ## Move to .NET 4.5 The minimum .NET version for NServiceBus version 5 is .NET 4.5. **This means consumers must update all projects that reference NServiceBus to .NET 4.5 before upgrading to NServiceBus version 5. ** Note that smaller changes are easier to verify; as such, it is recommended to update to .NET 4.5 and perform a full migration to production before updating to NServiceBus version 5. For more details on the reasons to upgrade to .NET 4.5, refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2078 ## Interfaces assembly and NuGet deprecated The NServiceBus interfaces assembly was created to allow a smaller dependency when creating a message assembly. With the introduction of message conventions, the interfaces assembly is no longer required. As such, `NServiceBus.dll` has been merged into NServiceBus.Core.dll. Also, the `NServiceBus.Interfaces` NuGet has been deprecated. For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2113 ### If using NuGet packages No extra work should be required. A normal NuGet update should result in no `NServiceBus.Interfaces` NuGet being used and version 5 of the `NServiceBus` NuGet being used. This is achieved through some [NuGet sleight of hand]( https://github.com/Particular/NServiceBus/issues/2113). If, for some reason, this sleight of hand fails, then manually remove usages of the `NServiceBus.Interfaces` NuGet and ensure that version 5 of the `NServiceBus` NuGet is used. ### If using manual references * Remove all references to `NServiceBus.dll` * Update all references of `NServiceBus.Core.dll` to version 5 ### Reflection Reflection calls that make assumptions on the assembly name of `NServiceBus.dll` must be updated and re-tested. ### Binding redirects Any binding redirects pointing to `NServiceBus.dll` should be removed. ### Use of interfaces and attributes from NServiceBus.Interfaces.dll The following have been moved into `NServiceBus.Core.dll` (part of the `NServiceBus` NuGet) * `IMessage` * `IEvent` * `ICommand` * `ExpressAttribute` * `DataBusProperty` and `IDataBusProperty` * `TimeToBeReceivedAttribute` * `WireEncryptedString` * `ExpressAttribute` If these markers are still required, they can be referenced via `NServiceBus.Core.dll`. If "no reference" is required, the equivalent conventions can be used instead. ```cs // --- NServiceBus 4.x --- // configure.DefiningCommandsAs(...); // --- NServiceBus 5.x --- var conventions = busConfiguration.Conventions(); conventions.DefiningCommandsAs(...); ``` ## Configure API The configuration API has been modified to fix several bugs related to the method invocation order. The new API takes an `Action` that configures a `ConfigurationBuilder`. ```cs // --- NServiceBus 4.x --- // var configure = Configure.With(AllAssemblies.Except("NotThis.dll")); // configure.DefaultBuilder(); // configure.DefineEndpointName("MyEndpointName"); // configure.DefiningEventsAs(...); // --- NServiceBus 5.x --- busConfiguration.AssembliesToScan(AllAssemblies.Except("NotThis.dll")); var conventions = busConfiguration.Conventions(); conventions.DefiningEventsAs(...); busConfiguration.EndpointName("MyEndpointName"); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/356 ## Transport definitions for UseTransport have been renamed When using `UseTransport` the transport definition types have been suffixed with `Transport`. ```cs // --- NServiceBus 4.x --- // Choose one of the following: // configure.UseTransport(); // configure.UseTransport(); // configure.UseTransport(); // configure.UseTransport(); // configure.UseTransport(); // --- NServiceBus 5.x --- // Choose one of the following: busConfiguration.UseTransport(); busConfiguration.UseTransport(); busConfiguration.UseTransport(); busConfiguration.UseTransport(); busConfiguration.UseTransport(); ``` ## Logging NServiceBus now has sensible defaults for logging built in. NLog and Log4net integration have been extracted to external NuGet packages. For more information see [Logging in NServiceBus](/nservicebus/logging/index.md) ## Obsolete sending and publishing batches of messages together in a single call Batch sending of messages has been removed in NServiceBus version 5. Previous code such as: ```cs bus.Send(new Message1(), new Message2(), new Message3()); ``` should be changed to: ```cs bus.Send(new Message1()); bus.Send(new Message2()); bus.Send(new Message3()); ``` The full list of replacements is below Old Method | Replacement Method :--- |:--- Publish(T[] messages); | Publish(T message); SendLocal(object[] messages); | SendLocal(object message); Send(object[] messages); | Send(object message); Send(string destination, object[] messages); | Send(string destination, object message); Send(Address address, object[] messages); | Send(Address address, object message); Send(string destination, string correlationId, object[] messages); | Send(string destination, string correlationId, object message); SendToSites(IEnumerable siteKeys, object[] messages); | SendToSites(IEnumerable siteKeys, object message); Defer(TimeSpan delay, object[] messages); | Defer(TimeSpan delay, object message); Defer(DateTime processAt, object[] messages); | Defer(DateTime processAt, object message); Reply(object[] messages); | Reply(object message); For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/1346 ## InMemory transport removal Due to significant confusion about the usage of this API, the InMemory transport has been removed in NServiceBus version 5. People using this API should either * Move to `Publish` or * Call the required methods explicitly For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2084 As an alternative, consider using an implemeantion of the [mediator pattern](https://en.wikipedia.org/wiki/Mediator_pattern) or the [event aggregator pattern](https://martinfowler.com/eaaDev/EventAggregator.html): * [MediatR](https://github.com/jbogard/MediatR) * [Mediator.Net](https://github.com/mayuanyang/Mediator.Net) * [Reactive.EventAggregator](https://github.com/shiftkey/Reactive.EventAggregator) ## Remove IMessageModule in favor of IManageUnitsOfWork In NServiceBus version 4, an improved abstraction (`IManageUnitsOfWork`) was introduced, and `IMessageModule` was deprecated. In version 5, this change is being completed with the removal of `IMessageModule`. Uses of `IMessageModule` should be replaced with [`IManageUnitsOfWork`](/nservicebus/pipeline/unit-of-work.md). For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2191 ## Remove Bus.CreateInstance In NServiceBus version 4, messages could be created with two approaches. In version 5, the same can be achieved using only one of those approaches. ```cs // --- NServiceBus 4.x --- // var message = Bus.CreateInstance( // action: interfaceMessage => // { // interfaceMessage.OrderNumber = 1234; // }); // Bus.Publish(message); // or: // Bus.Publish( // messageConstructor: interfaceMessage => // { // interfaceMessage.OrderNumber = 1234; // }); // --- NServiceBus 5.x --- Bus.Publish(o => { o.OrderNumber = 1234; }); ``` ### How to publish an interface event using reflection In some contexts, it may not be possible to invoke the generic `IBus.Publish()`, for example, when receiving a message via a non-typed webservice. In these cases, use `IMessageCreator` to construct the instance. `IMessageCreator` can be accessed via the container. The recommended way to do this is to pass it into the constructor of the class (e.g. `Handler`, `Saga`, `IWantToRunWhenBusStartsAndStops`, etc.). ```cs // This type would be derived from some other runtime information var messageType = typeof(MyInterfaceMessage); var instance = messageCreator.CreateInstance(messageType); // use reflection to set properties on the constructed instance Bus.Publish(instance); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2244 ## Pull gateway out of the core The gateway has been moved to a separate `NServiceBus.Gateway` NuGet. For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/1603 ## Update to RavenDB 2.5 NServiceBus version 5 has been updated to use Raven 2.5. The standard approach for updating RavenDB is to update the server first and then update the client. The benefit of this approach is that the risk is split, and each part can be verified individually. While this approach can be taken when updating to RavenDB 2.5, there are known issues when talking from a Raven 2.0 client to a RavenDB 2.5 server. However, this issue only occurs in rare circumstances, so it is the decision of the consumer to decide which approach is best for their scenario. See [using RavenDb in NServiceBus](/persistence/ravendb/installation.md#upgrading-ravendb) for additional details on upgrading from Raven 2.0 to 2.5. ## RavenDB is split from the core To allow a more regular cadence of RavenDB updates and isolate those changes, the RavenDB integration for NServiceBus has been extracted to its own NuGet. To move over to this NuGet after updating to version 5: For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/1605 #### 1. Install the NServiceBus.RavenDB NuGet package `Install-Package NServiceBus.RavenDB` #### 2. Use the new configuration API ```cs // --- NServiceBus 4.x --- // configure.RavenPersistence("http://localhost:8080", "MyDatabase"); // --- NServiceBus 5.x --- var documentStore = new DocumentStore { Url = "http://localhost:8080", DefaultDatabase = "MyDatabase", }; documentStore.Initialize(); var busConfiguration = new BusConfiguration(); var persistence = busConfiguration.UsePersistence(); persistence.SetDefaultDocumentStore(documentStore); ``` ## Pull the distributor out of the core The distributor feature has been extracted into its own NuGet. More details on this change: https://github.com/Particular/NServiceBus/issues/1604 To move over to this NuGet after updating to version 5: 1. Install the [NServiceBus.Distributor.MSMQ NuGet package](https://www.nuget.org/packages/NServiceBus.Distributor.MSMQ/) 2. Replace old profile names with their new counterparts: Old Profile | New Profile :--- |:--- `NServiceBus.Distributor` | `NServiceBus.MsmqDistributor` `NServiceBus.Master` | `NServiceBus.MsmqMaster` `NServiceBus.Worker` | `NServiceBus.MsmqWorker` ## Obsolete the IWantToRunBeforeConfiguration API The `IWantToRunBeforeConfiguration` API is no longer needed and is obsolete. The replacement is to use either `INeedInitalization` or use a [feature](/nservicebus/pipeline/features.md) where a `Default(s=>..)` can be setup in the constructor of the feature. For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/pull/2180 ## Remove UnicastBus.Start(Action) The `startupAction` parameter of `UnicastBus.Start` executed the action immediately before the start of the bus. This provided no real value since a consumer can execute the action prior to calling `Start`. ```cs // --- NServiceBus 4.x --- // configure.UnicastBus(); // var startableBus = configure.CreateBus(); // startableBus.Start( // startupAction: () => // { // MyCustomAction(); // }); // --- NServiceBus 5.x --- var startableBus = Bus.Create(new BusConfiguration()); MyCustomAction(); startableBus.Start(); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2168 ## Remove ForInstallationOn, Windows and IEnvironment This API has been simplified. ```cs // --- NServiceBus 4.x --- // var configure = Configure.With(); // configure.UnicastBus(); // var startableBus = configure.CreateBus(); // startableBus.Start( // startupAction: () => // { // configure.ForInstallationOn().Install(); // }); // --- NServiceBus 5.x --- busConfiguration.EnableInstallers(); // this will run the installers Bus.Create(busConfiguration); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2167 ## Make Scheduler API instance-based ```cs public class ScheduleMyTasks : IWantToRunWhenBusStartsAndStops { IBus bus; Schedule schedule; public ScheduleMyTasks(IBus bus, Schedule schedule) { this.bus = bus; this.schedule = schedule; } public void Start() { // --- NServiceBus 4.x --- // Schedule.Every(TimeSpan.FromMinutes(5)) // .Action(() => // { // var myMessage = new MyMessage(); // bus.SendLocal(myMessage); // }); // --- NServiceBus 5.x --- schedule.Every( timeSpan: TimeSpan.FromMinutes(5), task: () => { var message = new MyMessage(); bus.SendLocal(message); }); } ... } ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/pull/2192 ## Make ConfigureHowToFindSaga abstract Many bugs are caused by this method, not being overridden. As such, it is abstract in NServiceBus version 5. ```cs public class MySaga : Saga, IAmStartedByMessages, IHandleMessages { // --- NServiceBus 4.x --- // public override void ConfigureHowToFindSaga() // { // ConfigureMapping(message => message.SomeId) // .ToSaga(sagaData => sagaData.SomeId); // } // --- NServiceBus 5.x --- protected override void ConfigureHowToFindSaga(SagaPropertyMapper mapper) { mapper.ConfigureMapping(message => message.SomeId) .ToSaga(sagaData => sagaData.SomeId); } ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2137 ## Standardize extension methods to configure persisters In the interest of keeping the API consistent, a standard approach for choosing and configuring persistence has been applied. ```cs // --- NServiceBus 4.x --- // Configure to use InMemory // configure.InMemorySagaPersister(); // configure.UseInMemoryTimeoutPersister(); // configure.InMemorySubscriptionStorage(); // configure.RunGatewayWithInMemoryPersistence(); // configure.UseInMemoryGatewayDeduplication(); // --- NServiceBus 5.x --- // Configure to use InMemory for all persistence types busConfiguration.UsePersistence(); // Or configure to use InMemory for specific persistence types busConfiguration.UsePersistence() .For( Storage.Sagas, Storage.Subscriptions); // --- NServiceBus 4.x --- // Configure to use NHibernate // configure.UseNHibernateSagaPersister(); // configure.UseNHibernateTimeoutPersister(); // configure.UseNHibernateSubscriptionPersister(); // configure.UseNHibernateGatewayPersister(); // configure.UseNHibernateGatewayDeduplication(); // --- NServiceBus 5.x --- // Configure to use NHibernate for all persistence types busConfiguration.UsePersistence(); // Or configure to use NHibernate for specific persistence types busConfiguration.UsePersistence() .For( Storage.Sagas, Storage.Subscriptions); // --- NServiceBus 4.x --- // Configure to use RavenDB // configure.RavenSagaPersister(); // configure.UseRavenTimeoutPersister(); // configure.RavenSubscriptionStorage(); // configure.RunGatewayWithRavenPersistence(); // configure.UseRavenGatewayDeduplication(); // --- NServiceBus 5.x --- // Configure to use RavenDB for all persistence types busConfiguration.UsePersistence(); // Or configure to use RavenDB for specific persistence types busConfiguration.UsePersistence() .For( Storage.Sagas, Storage.Subscriptions); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2102 ## Obsolete the SerializationSettings properties WrapSingleMessages and DontWrapSingleMessages In NServiceBus version 5, multi-message sends is removed, and wrapping messages is no longer required. Usages of these settings should be removed. For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2104 ## Change IMessageSerializer.Serialize to take a single message In NServiceBus version 5, multi-message sends has been removed, and serialization of an array of messages is no longer required. Implementations of `IMessageSerializer` should be updated to take a single object. Usages of `IMessageSerializer` should no longer pass in an array of objects. For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2105 ## Replace ISaga with non-generic base class Saga Use abstract classes `Saga` (for generic access to the saga data) or `Saga` (for non-generic access to the saga data) instead. This should only affect scenarios that are leveraging more advanced NServiceBus extensions. This is because, in version 4, it was not possible to use `ISaga` to create a saga. For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2095 ## Remove Bus.Subscribe predicate overloads Instead, create a handler that does this filtering logic and then optionally calls `DoNotContinueDispatchingCurrentMessageToHandlers`. This handler should be ordered to run before other handlers. For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2088 ## Remove this.Bus() extension method for IHandleMessages implementations In NServiceBus version 4, there was an extension method on `IHandleMessages` that supplied a static instance of the `IBus`. This allowed consumers to write `this.Bus().Reply(response);`. While this was convenient, the tax of allowing static access to an instance of the `IBus` was too high. As such this extension has been removed. The replacement is to inject an instance of `IBus` as a constructor parameter and then assign it to a field for later use. ```cs // --- NServiceBus 4.x --- // public class MyHandler : IHandleMessages // { // public void Handle(MyMessage message) // { // var otherMessage = new OtherMessage(); // this.Bus().Reply(otherMessage); // } // } // --- NServiceBus 5.x --- public class MyHandler : IHandleMessages { IBus bus; public MyHandler(IBus bus) { this.bus = bus; } public void Handle(MyMessage message) { var otherMessage = new OtherMessage(); bus.Reply(otherMessage); } } ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2082 ## Remove .RunCustomAction() ```cs // --- NServiceBus 4.x --- // var configure = Configure.With(); // configure.UnicastBus(); // configure.RunCustomAction(MyCustomAction); // var startableBus = configure.CreateBus(); // startableBus.Start(); // --- NServiceBus 5.x --- var startableBus = Bus.Create(new BusConfiguration()); MyCustomAction(); startableBus.Start(); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/1366 ## Moved DefineCriticalErrorAction to be a ConfigurationBuilder extension ```cs // --- NServiceBus 4.x --- // var configure = Configure.With(); // configure.DefineCriticalErrorAction( // (message, exception) => // { // ... // }); // --- NServiceBus 5.x --- busConfiguration.DefineCriticalErrorAction( (message, exception) => { ... }); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2254 ## Moved FileShareDataBus to a ConfigurationBuilder extension ```cs // --- NServiceBus 4.x --- // var configure = Configure.With(); // configure.FileShareDataBus(databusPath); // --- NServiceBus 5.x --- var dataBus = busConfiguration.UseDataBus(); dataBus.BasePath(databusPath); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2257 ## Moved PurgeOnStartup to be a ConfigurationBuilder extension ```cs // --- NServiceBus 4.x --- // var configure = Configure.With(); // configure.PurgeOnStartup(true); // --- NServiceBus 5.x --- busConfiguration.PurgeOnStartup(true); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2257 ## Moved License configuration API to be a ConfigurationBuilder extension ```cs // --- NServiceBus 4.x --- // configure.LicensePath("PathToLicense"); // --- NServiceBus 5.x --- busConfiguration.LicensePath("PathToLicense"); ``` ```cs // --- NServiceBus 4.x --- // configure.License("YourCustomLicenseText"); // --- NServiceBus 5.x --- busConfiguration.License("YourCustomLicenseText"); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2278 ## Moved EncryptionService to be a ConfigurationBuilder extension ### RijndaelEncryption ```cs // --- NServiceBus 4.x --- // var configure = Configure.With(); // configure.RijndaelEncryptionService(); // --- NServiceBus 5.x --- busConfiguration.RijndaelEncryptionService(); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2265 ### Custom IEncryptionService ```cs // where EncryptionService implements IEncryptionService var configure = Configure.With(); var components = configure.Configurer; components.RegisterSingleton(new EncryptionService()); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/pull/2270 ## Moved Transaction config to ConfigurationBuilder ```cs // --- NServiceBus 4.x --- // Enable // Configure.Transactions.Enable(); // Disable // Configure.Transactions.Disable(); // --- NServiceBus 5.x --- // Enable busConfiguration.Transactions().Enable(); // Disable busConfiguration.Transactions().Disable(); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/pull/2283 ## Moved static endpoint config to ConfigurationBuilder ```cs // --- NServiceBus 4.x --- // var endpoint = Configure.Endpoint; // endpoint.AsSendOnly(); // --- NServiceBus 5.x --- Bus.CreateSendOnly(busConfiguration); ``` ```cs // --- NServiceBus 4.x --- // var endpoint = Configure.Endpoint; // endpoint.Advanced(settings => settings.DisableDurableMessages()); // endpoint.Advanced(settings => settings.EnableDurableMessages()); // --- NServiceBus 5.x --- busConfiguration.DisableDurableMessages(); busConfiguration.EnableDurableMessages(); ``` ```cs // --- NServiceBus 4.x --- // var endpoint = Configure.Endpoint; // endpoint.AsVolatile(); // --- NServiceBus 5.x --- var transactions = busConfiguration.Transactions(); transactions.Disable(); busConfiguration.DisableDurableMessages(); busConfiguration.UsePersistence(); ``` ## Moved performance monitoring and SLA to ConfigurationBuilder ```cs // --- NServiceBus 4.x --- // var configure = Configure.With(); // configure.EnablePerformanceCounters(); // configure.SetEndpointSLA(TimeSpan.FromMinutes(3)); // --- NServiceBus 5.x --- busConfiguration.EnableSLAPerformanceCounter(); // or busConfiguration.EnableSLAPerformanceCounter(TimeSpan.FromMinutes(3)); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2284 ## Configure.Instance deprecated `Configure.Instance` has been deprecated. The alternatives for configuring an instance now include: ### At configuration time In NServiceBus version 4, some configuration APIs require access to an instance of `Configure` via `Configure.Instance`. For example `IWantToRunBeforeConfigurationIsFinalized` and `IWantToRunWhenConfigurationIsComplete`. These interfaces have been modified in version 5 so an instance of `Configure` is passed in. ### To resolve IBuilder In version 4, it is possible to use `Configure.Instance` to get access to an instance of `IBuilder`. Instead of using `IBuilder` to access other runtime instances that exist in dependency injection, resolve them via [dependency injection](/nservicebus/dependency-injection/index.md). An alternative to using `IBuilder` is to configure NServiceBus to use a custom dependency injection instance. After starting the bus, this instance can be used to resolve instances. Each of the dependency injection integrations have an [associated sample](/samples/dependency-injection/index.md) that show how to pass in a custom instance. ### To statically resolve IBus One common use of `Configure.Instance` in NServiceBus version 4 was to access an instance of `IBus` in the static context, i.e., with `Configure.Instance.Builder.Build()`. It is recommended to avoid using the static context and instead construct the instances via the container. For example, to inject `IBus`, add a constructor parameter of the type `IBus` and store that in a field for when it is needed. If the class cannot be constructed through dependency injection, store the instance of `IBus` returned from `Bus.Create(busConfiguration).Start()` in a static variable and access it in the global context. ### Static resolution via IWantToRunWhenBusStartsAndStops Access to `IBuilder` and `IBus` via `Bus.Create(busConfiguration).Start()` is no longer available when using the NServiceBus host or plugging into NServiceBus in a generic library. If this functionality is necessary, capture both `IBuilder` and `IBus` via `IWantToRunWhenBusStartsAndStops` and storing them statically. ```cs public class BusInstance : IWantToRunWhenBusStartsAndStops { public BusInstance(IBus bus, IBuilder builder) { Bus = bus; Builder = builder; } public static IBuilder Builder; public static IBus Bus; ... } ``` Note that this approach should be considered only when it's not possible to resolve the components via dependency injection. ## Moved SendOnly mode to ConfigurationBuilder ```cs // --- NServiceBus 4.x --- // configure.UnicastBus(); // var bus = configure.SendOnly(); // --- NServiceBus 5.x --- var sendOnlyBus = Bus.CreateSendOnly(busConfiguration); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/pull/2295 ## Removed EndpointName to ConfigurationBuilder and removed Func overload ```cs // --- NServiceBus 4.x --- // configure.DefineEndpointName("MyEndpoint"); // --- NServiceBus 5.x --- busConfiguration.EndpointName("MyEndpoint"); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/pull/2275 ## Moved DoNotCreateQueues to a ConfigurationBuilder extension ```cs // --- NServiceBus 4.x --- // configure.DoNotCreateQueues(); // --- NServiceBus 5.x --- busConfiguration.DoNotCreateQueues(); ``` For more details refer to the following GitHub issue: https://github.com/Particular/NServiceBus/issues/2263 ## Remove RunHandlersUnderIncomingPrincipal The `RunHandlersUnderIncomingPrincipal` method has been removed. This API was frequently assumed to be a security feature. In fact, this API exposes the username from the message sending code to executing handlers. It does this by setting `Thread.CurrentPrincipal` to a fake principal containing the username of the user who sent the message and extracts this username from the message headers. The handler code is free to use `Thread.CurrentPrincipal` or to ignore. It does not add any security or perform any true impersonation. To re-enable this feature, a [message mutator](/nservicebus/pipeline/message-mutators.md) can be used . ```cs public class PrincipalMutator : IMutateIncomingTransportMessages { public void MutateIncoming(TransportMessage message) { var headers = message.Headers; var windowsIdentityName = headers[Headers.WindowsIdentityName]; var identity = new GenericIdentity(windowsIdentityName); var principal = new GenericPrincipal(identity, new string[0]); Thread.CurrentPrincipal = principal; } } ``` ## INeedToInstallInfrastructure The interface `INeedToInstallInfrastructure` has been removed.