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

Readme.md docs don't work and throw InvalidCastException #194

Closed
CreepyGnome opened this issue Aug 14, 2019 · 5 comments · Fixed by #220
Closed

Readme.md docs don't work and throw InvalidCastException #194

CreepyGnome opened this issue Aug 14, 2019 · 5 comments · Fixed by #220

Comments

@CreepyGnome
Copy link

Created a clean .NET Core console app. Followed the readme.md doc and Configuration extension method used has such ReadFrom.Configuration(configuration) throws System.InvalidCastException.

System.InvalidCastException HResult=0x80004002 Message=Invalid cast from 'System.String' to 'Serilog.Core.IDestructuringPolicy'. Source=System.Private.CoreLib StackTrace: at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) at Serilog.Settings.Configuration.StringArgumentValue.ConvertTo(Type toType, ResolutionContext resolutionContext) at Serilog.Settings.Configuration.ConfigurationReader.<>c__DisplayClass18_2.<CallConfigurationMethods>b__3(<>f__AnonymousType92 <>h__TransparentIdentifier0)
at System.Linq.Utilities.<>c__DisplayClass2_03.<CombineSelectors>b__0(TSource x) at System.Linq.Enumerable.SelectListPartitionIterator2.ToList()
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Serilog.Settings.Configuration.ConfigurationReader.CallConfigurationMethods(ILookup2 methods, IList1 configurationMethods, Object receiver) at Serilog.Settings.Configuration.ConfigurationReader.Configure(LoggerConfiguration loggerConfiguration) at Serilog.Configuration.LoggerSettingsConfiguration.Settings(ILoggerSettings settings) at FunWithSerilogNetCore.Program.Main(String[] args) in C:\src\Playgroud\FunWithSerilogNetCore\Program.cs:line 15

If I remove the Destructure property from the appsettings.json it works.

See the attached project for example.

FunWithSerilogNetCore.zip

So if you could fix the readme.md so that the code will work maybe just remove the json property that it is failing on or better yet add what is missing so that it works with that json file.

@nblumhardt
Copy link
Member

Thanks for the note, we'll check it out

@CreepyGnome CreepyGnome changed the title Readme.md docs don't work and throw FileLoadException Readme.md docs don't work and throw InvalidCastException Aug 15, 2019
@UltimateForm
Copy link

This was fixed? How? I still get the same error, and the message is still the same....

@nblumhardt
Copy link
Member

@UltimateForm are you running the latest -dev* version of the package?

@UltimateForm
Copy link

@nblumhardt no, just the nuget release, thought this fix had been released already, my bad 🙏

@nblumhardt
Copy link
Member

The -dev* packages are on NuGet, too: https://www.nuget.org/packages/Serilog.Settings.Configuration/3.2.0-dev-00272

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants