Are there any technical reasons why Simple Injector does not support the Web API on .NET 4.0?

This is really a continuation of this issue . One of the developers of Simple Injector pointed to a useful tidbit about Simple Injector, and I thought it would be nice to make it more accessible.

So, are there any technical barriers to supporting Simple Injector with Web API 1 and .NET 4.0? The source code is simple enough to download and compile. Everything seems to be working fine.

+4
source share
2 answers

We deliberately chose NOT to support .NET 4.0 for the web API, because it WebApiRequestLifestyleuses CallContext.LogicalGetData , which behaves differently with .NET 4.0. This behavior is so significantly different that it can cause errors when using nested instances ExecutionContextScopein the background thread and Tasksthat work in parallel.

What has changed in this regard is that, in .NET 4.5, the logical call context demonstrates copy-to-write behavior , which means that when the logical call context is changed from a parallel operation, it does not affect the original operation that generated this parallel operation. In .NET 4.0, any change to the context of a logical call from a parallel operation will be observed from the main operation.

.NET.NET, , ExecutionContextScope ( , -API ), . , , . , , , , . , , , - API .

- , , , . , ( , ). , , .

ExecutionContextScope ( ) , , , .NET 4.0 .NET 4.5.

, , .NET 4.5, , .NET 4.0 . , , , , , , .NET 4.0 , Stackoverflow, Simple Injector, .

+8

Source: https://habr.com/ru/post/1531658/


All Articles