Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The type 'IConfiguration' exists in both Microsoft.Extensions.Configuration.Abstractions and Serilog.Sinks.Http #135

Closed
brian-pickens opened this issue Sep 30, 2020 · 15 comments
Assignees
Labels
bug Something isn't working

Comments

@brian-pickens
Copy link

brian-pickens commented Sep 30, 2020

Describe the bug
Serilog.Sinks.Http contains Microsoft.Extensions.Configuration.Abstractions.IConfiguration type and conflicts with the same type inside Microsoft's configuration package. Why not put a package dependency on Microsoft.Extensions.Configuration.Abstractions instead?

Is there currently a recommened way to deal with this?

Error	CS0433	The type 'IConfiguration' exists in both 'Microsoft.Extensions.Configuration.Abstractions, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' and 'Serilog.Sinks.Http, Version=7.0.1.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10'	SomeProject	C:\...\SomeFile.cs	18	Active

Edit:
I dug into the source for this type and noticed that it is wrapped with compiler flags to include it into non netcore 2.0 targeted applications. Is there a reason for this? That means that I can't use this sink with any other framework along with Microsoft's configuration library?

@brian-pickens brian-pickens added the bug Something isn't working label Sep 30, 2020
@github-actions
Copy link
Contributor

Hi there and welcome to this repository!

A maintainer will be with you shortly, but first and foremost I would like to thank you for taking the time to report this issue. Quality is of the highest priority for us, and we would never release anything with known defects. We aim to do our best but unfortunately you are here because you encountered something we didn't expect. Lets see if we can figure out what went wrong and provide a remedy for it.

@brian-pickens
Copy link
Author

FYI - My short term solution to fixing this is downgrading to v6, before the type was added.

@FantasticFiasco
Copy link
Owner

Maybe I've misconfigured the compiler flag. Which .NET version are you using?

@FantasticFiasco
Copy link
Owner

And which version of Microsoft.Extensions.Configuration are you referencing?

@brian-pickens
Copy link
Author

brian-pickens commented Oct 1, 2020

The version of the Microsoft.Extensions.Configuration extension I'm using is 3.1.8, but I'm sure almost every version of that library has an IConfiguration type in that namespace. For our application we are targeting full net framework. Which is why the compiler flag is including your custom type. However this issue would occur for any lower version of netstandard, as well as for netstandard 2.1 which is soon to release.

@FantasticFiasco
Copy link
Owner

Yeah I think you are correct. I'll have to fix this issue, but haven't got the time tonight. I'll start working on it during the weekend, are you able to use the old version until a fix has been created?

@ShreyasJejurkar
Copy link

@FantasticFiasco As the type will be available for all .NET Standards version, do we need to remove that type from the library?

@FantasticFiasco
Copy link
Owner

Yes, that will be the first thing I investigate. I'm happy to do it, but if any of you are participating in Hackoctober you are free to open up a PR and count is as a part of your monthly goal. Just make sure I've got permissions to push to your fork.

@ShreyasJejurkar
Copy link

@FantasticFiasco yeah, I just forked the repo, and will try to fix this issue, and will create PR with a solution! 😀

@FantasticFiasco
Copy link
Owner

I just wanted to wrap my head around this thing. My intention is to keep the same API for all supported versions, and shim IConfiguration where it isn't supported. But I think I got it wrong, let me explain why.

Let's start with the .NET version we build for.

  • net45
  • net461
  • netstandard1.3
  • netstandard2.0

Now let's look at the versions Microsoft.Extensions.Configuration v3.1.8 is built for.

  • netcoreapp3.1
  • netstandard2.0

According to .NET implementation support, this is the .NET implementation support.

.NET Standard 1.3 2
.NET Framework 4.6 4.6.1

That ought to mean that the following versions we build for is supported by netstandard2.0.

  • net45
  • net461
  • netstandard1.3
  • netstandard2.0

Which lets me believe that the only version we need to shim support for IConfiguration is net45.

Can any of you please verify my reasoning?

@aleksaradz
Copy link
Contributor

@FantasticFiasco Your reasoning looks correct to me... Projects that target .NET 4.6.1 can consume .NET Standard 2.0 libraries and can consume IConfiguration directly from Microsoft.Extensions.Configuration v3.1.8 because it has a target to .NET Standard 2.0. I also tested Microsoft.Extensions.Configuration v3.1.9 and the same is true.

I can help with the pullrequest if you want

@FantasticFiasco
Copy link
Owner

I would love it, if you are willing. Please let me know if I can help in any way.

@aleksaradz
Copy link
Contributor

@FantasticFiasco I just open pullrequest #139

aleksaradz added a commit to aleksaradz/serilog-sinks-http that referenced this issue Oct 18, 2020
@FantasticFiasco
Copy link
Owner

@aleksaradz, the changes where perfect!
@brian-pickens-web, I'll continue with creating a release.

@FantasticFiasco
Copy link
Owner

@brian-pickens-web v7.1.0 is now live on nuget.org. Would you be able to verify that it fixes this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants