Nlog: LayoutRenderer assembly not found

Created on 28 Nov 2019  路  3Comments  路  Source: NLog/NLog

So I thought let me try a custom renderer anyway (I already added an issue around getting level in fullname, but I think this is a different issue/question). So I created a new dll with a custom renderer, Added the assembly name to the extensions nlog.config. The assembly is in the directory the executable is in. But unfortunately I get this: 2019-11-28 13:39:30.5110 Warn Error has been raised. Exception: NLog.NLogConfigurationException: Error loading extensions: LevelRenderer.dll ---> System.IO.FileNotFoundException: Could not load file or assembly 'LevelRenderer.dll' or one of its dependencies. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at NLog.Internal.AssemblyHelpers.LoadFromName(String assemblyName)
at NLog.Config.LoggingConfigurationParser.ParseExtensionWithAssembly(String assemblyName, String prefix)
--- End of inner exception stack trace ---
2019-11-28 13:39:30.5770 Info Adding target FileTarget(Name=file)
2019-11-28 13:39:30.5860 Info Adding target ConsoleTarget(Name=console)
2019-11-28 13:39:30.7030 Error Error parsing layout levelFullname will be ignored. Exception: System.ArgumentException: LayoutRenderer cannot be found: 'levelFullname'

No idea why it would say file not found, the assembly is there.

question

Most helpful comment

I solved it by using ConfigurationItemFactory.Default.LayoutRenderers .RegisterDefinition("levelFullname", typeof(LevelFullNameRenderer));

All 3 comments

Think you have to upload an example solution that includes your two projects. The main-project with Nlog.config and the LevelRenderer-project.

I solved it by using ConfigurationItemFactory.Default.LayoutRenderers .RegisterDefinition("levelFullname", typeof(LevelFullNameRenderer));

Still strange the <extensions> load is not working out. But happy you found a work-around.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

imanushin picture imanushin  路  3Comments

BobSeu picture BobSeu  路  3Comments

ErcinDedeoglu picture ErcinDedeoglu  路  3Comments

Rapiiidooo picture Rapiiidooo  路  3Comments

ericnewton76 picture ericnewton76  路  3Comments