MissingFieldException (SimpleInjector.Lifestyle.Singleton) with SimpleInjector 5 integration
See original GitHub issueIs this a bug report?
Yes
Can you also reproduce the problem with the latest version?
Yes
Environment
- Operating system: MS Windows 10 Pro
- Visual Studio version: VS Community 2019 v16.7.5
- Dotnet version: .NET Framework 4.8
Steps to Reproduce
- Create a VS Console application targeting .NET Framework 4.8
- Install nuget package SimpleInjector version 5.0.3
- Install nuget package MassTransit.SimpleInjector version 7.0.4
- In Main method, Create a SimpleInjector container and configure MassTransit with an empty action
container.AddMassTransit(x => { });
Expected Behavior
The app must run and terminate without errors.
Actual Behavior
The app throws a System.MissingFieldException for the field SimpleInjector.Lifestyle.Singleton.
Reproducible Demo
using MassTransit;
using SimpleInjector;
using SimpleInjector.Lifestyles;
namespace MassTransitWithSimpleInjector5.Net48
{
class Program
{
static void Main(string[] args)
{
var container = new Container();
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
container.AddMassTransit(x => { });
}
}
}
The same happens when targeting .NET Core 3.1 and SimpleInjector 5 (the code is the same).
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Lifestyle.Singleton Field
The lifestyle that caches components during the lifetime of the Container instance and guarantees that only a single instance of that component is...
Read more >In Simple Injector why is it an error for a singleton or ...
Autofac does not contain a Transient lifestyle. Instead it has an InstancePerDependency lifestyle. Technically this is the same as transient, ...
Read more >SimpleInjector
An easy, flexible, and fast Dependency Injection library that promotes best practice to steer developers towards the pit of success.
Read more >Chapter 14: The Simple Injector DI Container
A Lifestyle is configured as part of registering components. It's as easy as this: container.Register<SauceBéarnaise>(Lifestyle.Singleton);. This example ...
Read more >How to use Simple Injector in ASP.NET Core MVC
Following these steps will create a new ASP.NET Core MVC project in Visual Studio 2019 using .NET 5. Launch the Visual Studio IDE....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, sure! I’ll do a pull request as soon as possible.
Any chance you’d be willing to submit these changes as a pull request?