GithubHelp home page GithubHelp logo

Comments (5)

HaoK avatar HaoK commented on July 26, 2024

We changed the implementation/behavior of IOptionsSnapshot entirely in 2.0, we basically repurposed the type name as its still meant to be used to capture the state of an options instance for the lifetime of a request, instead of having a lifetime timed to the IOptionsMonitor

I can help you migrate to 2.0 if you get stuck, IOptionsMonitor is still mostly the same in 2.0. Were you using snapshot for getting updating/reloading options?

from options.

Aurel avatar Aurel commented on July 26, 2024

Hey @HaoK - I'm quite well aware that the IOptionsSnapshot has changed, but in the process of changing, did the backwards compatibility break? Essentially, my old class libraries that I have just don't work with NetCore 2.0 apps. Let's say that I need my class libraries to remain as < 2.0 NetStandard apps.

Yes, originally, I was using snapshot for reloading options on the fly. Is that not what it does anymore? In the case, the documentation is a bit out of date and should reference that. Does this also mean that my old class library that has all of this functionality can only work with older versions of .net core, and not with newer ones?

I've come up with a number of fixes, and I got it working, but the fixes are hacky, and force me to use dynamic everywhere so I can try calling .Value, and if that throws I can try calling .Get(string.Empty), even though I'm in a NetStandard1.3 app that doesn't have that function. It's one way I've found of solving this problem. However, I'm just trying to report that something goes horribly wrong here.

Additionally, it only happens if the options are requested by a Service. If I just request the options themselves, not much is happening, but if I request a service, and in its constructor requests the POCO object I showed above, I consistently get this error about MissingMethodException

from options.

HaoK avatar HaoK commented on July 26, 2024

@Aurel yes, the 2.0 IOptionsSnapshot type is not backwards compatible with 1.0 at all

from options.

Aurel avatar Aurel commented on July 26, 2024

Interesting - I've found a fix locally that uses a bunch of dynamics so I don't have to know about the type I'm invoking, but can you explain to me then, why this might be happening? I don't understand why the get_Value() method would be missing, when it's clearly there both in 1.1.2 and in 2.0.0! (In 2.0.0 it's inherited from IOption<T>)

from options.

aspnet-hello avatar aspnet-hello commented on July 26, 2024

This issue was moved to dotnet/aspnetcore#2387

from options.

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.