Comments (7)
Is this the same as #1372?
from autofac.
This would eliminate the need for it as this would be a general solution to that specific case.
from autofac.
Then I'll close the other as duplicate. No need to address the same request twice.
from autofac.
to create collections of the specified types
Can you provide a specific list of types you think qualify here? "Just know about all the types" isn't specific or feasible. Put another way, if we were to write unit tests to make sure this is "done," what would we test to verify it's done and we can close the issue?
Also, FYI, "Autofac" - no cap F 😉
from autofac.
Hi,
It seems a recent change in the 8.0.300 SDK made this more urgent. We are unable to run our application with the latest SDK as it's using a new type called ReadOnlySingleElementList
that seems to be used for collection expressions of one element: https://github.com/dotnet/dotnet/blob/84c07ba732cfaf598d5691c1203041af91993b7c/src/roslyn/src/Compilers/CSharp/Portable/Symbols/Synthesized/ReadOnlyListType/SynthesizedReadOnlyListTypeSymbol.cs#L21
This is the kind of errors we are getting now:
Autofac.Core.DependencyResolutionException : An exception was thrown while activating λ:Microsoft.Extensions.Hosting.IHost -> Microsoft.Extensions.Hosting.Internal.ApplicationLifetime -> Microsoft.Extensions.Logging.Logger`1[[Microsoft.Extensions.Hosting.Internal.ApplicationLifetime, Microsoft.Extensions.Hosting, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]] -> Microsoft.Extensions.Logging.LoggerFactory -> Microsoft.Extensions.Options.OptionsMonitor`1[[Microsoft.Extensions.Logging.LoggerFilterOptions, Microsoft.Extensions.Logging, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]] -> Microsoft.Extensions.Options.OptionsFactory`1[[Microsoft.Extensions.Logging.LoggerFilterOptions, Microsoft.Extensions.Logging, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]] -> <>z__ReadOnlySingleElementList`1[[Microsoft.Extensions.Options.IPostConfigureOptions`1[[Microsoft.Extensions.Logging.LoggerFilterOptions, Microsoft.Extensions.Logging, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]], Microsoft.Extensions.Options, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].
---- Autofac.Core.DependencyResolutionException : None of the constructors found on type '<>z__ReadOnlySingleElementList`1[Microsoft.Extensions.Options.IPostConfigureOptions`1[Microsoft.Extensions.Logging.LoggerFilterOptions]]' can be invoked with the available services and parameters:
Cannot resolve parameter 'Microsoft.Extensions.Options.IPostConfigureOptions`1[Microsoft.Extensions.Logging.LoggerFilterOptions] item' of constructor 'Void .ctor(Microsoft.Extensions.Options.IPostConfigureOptions`1[Microsoft.Extensions.Logging.LoggerFilterOptions])'.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating ?:Microsoft.Extensions.Hosting.IHost -> Microsoft.Extensions.Hosting.Internal.ConsoleLifetime -> Microsoft.Extensions.Options.UnnamedOptionsManager`1[[Microsoft.Extensions.Hosting.ConsoleLifetimeOptions, Microsoft.Extensions.Hosting, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]] -> Microsoft.Extensions.Options.OptionsFactory`1[[Microsoft.Extensions.Hosting.ConsoleLifetimeOptions, Microsoft.Extensions.Hosting, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]] -> <>z__ReadOnlySingleElementList`1[[Microsoft.Extensions.Options.IConfigureOptions`1[[Microsoft.Extensions.Hosting.ConsoleLifetimeOptions, Microsoft.Extensions.Hosting, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]], Microsoft.Extensions.Options, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].
---> Autofac.Core.DependencyResolutionException: None of the constructors found on type '<>z__ReadOnlySingleElementList`1[Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.Extensions.Hosting.ConsoleLifetimeOptions]]' can be invoked with the available services and parameters:
Cannot resolve parameter 'Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.Extensions.Hosting.ConsoleLifetimeOptions] item' of constructor 'Void .ctor(Microsoft.Extensions.Options.IConfigureOptions`1[Microsoft.Extensions.Hosting.ConsoleLifetimeOptions])'.
Could you please look into it?
from autofac.
@MaQy, can you please raise a new issue for reporting this issue rather than adding to a feature request?
Please ensure you include a minimal reproducible code example that causes the failure on 8.0.300. A public repo with an example is ideal.
from autofac.
Hi again,
It took me a while to pinpoint the issue as I was not able to reproduce it in an isolated way. The problem was actually partially in our code, though I think Microsoft is also to be blamed for the sudden change they did. As mentioned above, it seems they have introduced new collections for collection expressions:
int[] a = [1];
This now gets compiled into an auto-generated collection that is inserted into the assembly where that code is located. The name of the class is <>z__ReadOnlySingleElementList
. This class is not marked as compiler generated with the CompilerGeneratedAttribute
attribute. We have the typical "catch all" method for generic interfaces for some of our assemblies, and this type was suddenly getting registered for IEnumerable
. That caused problems with the Autofac
resolution when an IEnumerable
was requested to find all existing registrations.
I'm sorry for the off-topic and the false alarm, but I wanted to leave this somewhere as a word of warning in case anyone else encounters this issue.
from autofac.
Related Issues (20)
- Delegate factory vs func factory - different resolution HOT 3
- Instantiated services not disposed on exception during IStartable HOT 1
- Service is not register in Eureka because of Autofac HOT 4
- Trouble with Autofac Container Disposal when Resolving Dependencies in Another Method/Class HOT 7
- ```Scope.TryResolve(FactoryTypes, out var Instance)``` throws HOT 1
- [Xamarin.iOS] Application crashes during apple review process HOT 1
- AttributedMetadataModule slows down service resolution considerably HOT 1
- Type equivalence for the embedded interop types not working HOT 1
- Decorators does not follow ExternallyOwned - problem with lifetime scope on decorator with `IDisposable` implementation
- Are the container and the root lifetime scope different objects after the first child lifetime scope begins? HOT 2
- Add option to fail on ambiguous service resolution HOT 3
- Required properties not working with WebAPI controllers HOT 6
- Configure Autofac so that it's ExternallyOwned for default, and "InternallyOwned" for separate services HOT 1
- Startable Singleton instantiated twice HOT 1
- AutoFac WebForms object[] problem HOT 5
- Resolutions with many TypedParameter of the same type HOT 2
- ComponentNotRegisteredException thrown when using NUnit Console Runner HOT 1
- Can Autofac Dispose queue cause buffer overflow or heap corruption? HOT 1
- Register service with Interceptor, then register multiple decorator, auto apply Interceptor to the outermost decorator HOT 13
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 autofac.