Comments (3)
Patch release v5.4.2 has been published to NuGet.
Thank you for raising this issue.
from simpleinjector.
Thanks for responding to my issue so quickly. I hadn't noticed these exceptions being thrown in VS. I must have set something to suppress them. I'll update to the latest version of the package when I get a chance.
from simpleinjector.
When it comes to building generic types, sometimes the only way to verify that a type matches certain type constraints is to try build the type. I believe that there's now some sort of CanCreateGenericType
method in .NET 6 or 7, but that's of to little use of Simple Injector, which needs to be compatible with older frameworks as well. The problem, unfortunately, is that CreateGenericType
will throw an exception when the type constraints don't match. In that case Simple Injector catches the exception, but now knows that the type constraints didn't match.
This wasn't a big issue with older Visual Studio versions. More recent versions of VS, however, automatically break the debugger when a first-chance exception is encounters; even if it's not your own code. This new VS behavior is quite troublesome, as it stops the developer flow and can leave you in a confused state. I myself burned many hours tracking down a bug that didn't exist because I didn't realize that I was looking at a first-chance exception. Because of this change in behavior, quite some big internal changes were made in Simple Injector v5 to prevent most first-chance exceptions from occurring. I wrote more extensively about this change here.
Unfortunately, for the time being, Simple Injector can't prevent all first-chance exceptions from happening. On the plus side, these first-chance exceptions are harmless, you can ignore them, and you can configure your IDE to suppress them.
That said, using the code you provided, I've been looking at the code base and did notice that in your case (which I consider to be a happy-path scenario) the first-chance could actually be prevented. And even better, the type constraint check can be skipped, which improves performance of the registration process.
I will push a patch release shortly that fixes this issue.
from simpleinjector.
Related Issues (20)
- Is there a way to check if the Scope was disposed? HOT 5
- Using Microsoft DI and Simple injector the other way around (reversed crosswire) to integrate with NServiceBus? HOT 1
- How to handle mixed constructor parameters with multiple instances? ex. (DependentSvc svc, string p1, string p2) HOT 2
- d__15 MoveNext Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. HOT 1
- Single constructor requirement incompatible with ASP.NET Core HOT 2
- Resolution of IEnumerable<T> for non registered service T. HOT 1
- Hybrid Async Scoped MVC 5 + Async Method bug HOT 12
- Degraded Register performance when AllowOverridingRegistrations is set to true HOT 10
- Exception thrown when attempting to inject COM interface HOT 4
- Remove COM support
- How to register third party constructor with runtime string arguments HOT 7
- What would happen in case of duplicate registrations? HOT 1
- @inject support in .NET Core MVC views HOT 9
- ThreadScopedLifestyle vs AsyncScopedLifestyle HOT 1
- Sharing Instances between Parent and child scopes HOT 4
- Add debug information for Scopes HOT 2
- How to use decorator for shared interface? HOT 4
- What's best way to get .net 3.5 SimpleInjector Decorator Memory Leak bug fix? HOT 1
- Open-generic registrations for types with generic array generic type arguments can't be resolved
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simpleinjector.