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

Failed obtaining configuration for Common.Logging in dotnet versions #179

Open
robsosno opened this issue Jul 20, 2019 · 0 comments
Open

Comments

@robsosno
Copy link

Steps to reproduce:
Simple console application, Set properly LogConfiguration configuration from file or from strings.
Then:
LogManager.Configure(configuration);
log = LogManager.GetLogger(); <-- crashes

Stack trace:
Common.Logging.ConfigurationException
HResult=0x80131500
Message=Failed obtaining configuration for Common.Logging from configuration section 'common/logging'.
Source=Common.Logging
StackTrace:
at Common.Logging.Configuration.ArgUtils.Guard[T](Function`1 function, String messageFormat, Object[] args)
at Common.Logging.Configuration.ArgUtils.Guard(Action action, String messageFormat, Object[] args)
at Common.Logging.LogManager.BuildLoggerFactoryAdapter()
at Common.Logging.LogManager.get_Adapter()
at Common.Logging.LogManager.GetLoggerT
at TestOldFramework.Program.Main(String[] args) in d:\dokumenty\Visual Studio 2019\source\repos\Common.Logging.Ext\TestOldFramework\Program.cs:line 25

Inner Exception 1:
FileNotFoundException: Nie można załadować pliku lub zestawu 'System.Reflection.TypeExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' lub jednej z jego zależności. Nie można odnaleźć określonego pliku.
"Nie można załadować pliku lub zestawu" = "File or assembly could not be loaded"

Console application is in .Net 4.6.1 and Common.Logging is in Netstandard 1.3

An error occurs in ArgUtils.cs on following line:
if (!typeof(T).IsAssignableFrom(valType))
This is because NetStandard doesn't have IsAssignableFrom method and System.Reflection.TypeExtensions is used. However it cannot be loaded in .NET 4.6.1

Suggested solution:
#if DOTNETCORE
if (!typeof(T).GetTypeInfo().IsAssignableFrom(valType.GetTypeInfo()))
#else
if (!typeof(T).IsAssignableFrom(valType))
#endi

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

No branches or pull requests

1 participant