InvalidOperationException: while injecting SAMLConfiguration

Hi,

I am using ComponentSpace V2.0.2 for .Net Core and when I try to add SAML module in the startup.cs file in configureServices method as of this way below:


services.Configure(Configuration.GetSection(“SAML”));
services.AddSaml();


it then gives me an exception: InvalidOperationException: Cannot consume scoped service ‘ComponentSpace.Saml2.Configuration.SamlConfigurations’ from singleton ‘ComponentSpace.Saml2.Configuration.Resolver.ISamlConfigurationResolver’.

Any help on this please.

Thanks,
Amr

Hi Amr
Please take a look at the startup code in our examples.
The code should be:


services.AddSaml(Configuration.GetSection(“SAML”));


[quote]
ComponentSpace - 4/25/2019
Hi Amr
Please take a look at the startup code in our examples.
The code should be:


services.AddSaml(Configuration.GetSection("SAML"));


[/quote]

Hi ,

Thank you for your answer, however your solution works for version 2.3 or above of ComponentSpace and we are currently using V2.0, Any advice.

Thanks,
Amr

My apologies. I missed that.
Your code matches the examples startup code shipped with v2.0.2.
This code did work with the various Microsoft package dependencies at the time of its release.
However, it’s possible that an updated package dependency is causing this issue through more stringent checking etc.
We reviewed the scope of the various classes a little while back.
ISamlConfigurationResolver was a singleton in v2.0.2 but is now a transient in later releases.
Version 2.0.2 was released in 2017.
Are you able to move up to the latest SAML release?


[quote]
ComponentSpace - 4/25/2019
My apologies. I missed that.
Your code matches the examples startup code shipped with v2.0.2.
This code did work with the various Microsoft package dependencies at the time of its release.
However, it's possible that an updated package dependency is causing this issue through more stringent checking etc.
We reviewed the scope of the various classes a little while back.
ISamlConfigurationResolver was a singleton in v2.0.2 but is now a transient in later releases.
Version 2.0.2 was released in 2017.
Are you able to move up to the latest SAML release?


[/quote]

Hi,

Thank you once again for this answer, unfortunately as per your policy we have to pay for the upgrade, and currently I don't think we will be able to, so my question is what should I do so I can make it works as it used to before, is there any upgrades happened for .Net Core or something, please your help would be appreciated.

Thanks,
Amr


Are you targeting .NET Core 2.0 or a later release?
Back in 2017, .NET Core 2.0 would have been used to run these examples.

[quote]
ComponentSpace - 4/25/2019
Are you targeting .NET Core 2.0 or a later release?
Back in 2017, .NET Core 2.0 would have been used to run these examples.
[/quote]

Yes, I am targeting .Net Core 2.0

Do the example applications run for you?
Was your application working at some stage and then stopped working?
I’ll build and run the examples apps with v2.0.2 to see if I can reproduce the issue.

[quote]
ComponentSpace - 4/25/2019
Do the example applications run for you?
Was your application working at some stage and then stopped working?
I'll build and run the examples apps with v2.0.2 to see if I can reproduce the issue.
[/quote]

Hi,

Please let me know if you have been able to reproduce the issue, as we are stuck on it.

Thanks a lot for your help.

Amr

I wasn’t able to reproduce the issue.
I installed the v2.0.2 product, built and ran the examples without any issues using VS 2017.
I didn’t make any changes to the projects and I didn’t updates any of the project dependencies.
Below is a screenshot of the installed packages.



Various updates are available by I didn’t update any of the packages.



Please see if you can build and run the ExampleIdentityProvider and ExampleServiceProvider projects.

[quote]
ComponentSpace - 4/25/2019
I wasn't able to reproduce the issue.
I installed the v2.0.2 product, built and ran the examples without any issues using VS 2017.
I didn't make any changes to the projects and I didn't updates any of the project dependencies.
Below is a screenshot of the installed packages.



Various updates are available by I didn't update any of the packages.



Please see if you can build and run the ExampleIdentityProvider and ExampleServiceProvider projects.
[/quote]

Hi,

Thank you very much once again, I will presume that you run it on .Net Core v2.0, as I realised that our servers .Net Core version was upgraded to v2.2 and this is probably the root cause of the issue as per your explanation.

Thanks,
Amr

Yes, this was run with .NET Core 2.0.
You’re picking up new package versions with .NET Core 2.2 which are causing the issue you’re seeing.

[quote]
ComponentSpace - 4/26/2019
Yes, this was run with .NET Core 2.0.
You're picking up new package versions with .NET Core 2.2 which are causing the issue you're seeing.
[/quote]

Thanks, I think we have got to upgrade the component space version.

Thanks for your support.

You’re welcome.