Coder Social home page Coder Social logo

Comments (7)

tillig avatar tillig commented on June 9, 2024

Is this the same as #1372?

from autofac.

TonyValenti avatar TonyValenti commented on June 9, 2024

This would eliminate the need for it as this would be a general solution to that specific case.

from autofac.

tillig avatar tillig commented on June 9, 2024

Then I'll close the other as duplicate. No need to address the same request twice.

from autofac.

tillig avatar tillig commented on June 9, 2024

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.

MaQy avatar MaQy commented on June 9, 2024

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.

alistairjevans avatar alistairjevans commented on June 9, 2024

@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.

MaQy avatar MaQy commented on June 9, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.