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

${assembly-version} returns "Could not find entry assembly" in ASP.NET #46

Closed
3 tasks
304NotModified opened this issue Apr 4, 2016 · 1 comment · Fixed by #66
Closed
3 tasks

${assembly-version} returns "Could not find entry assembly" in ASP.NET #46

304NotModified opened this issue Apr 4, 2016 · 1 comment · Fixed by #66

Comments

@304NotModified
Copy link
Member

304NotModified commented Apr 4, 2016

moved from NLog/NLog#275

reported by @slolife:


the ${assembly-version} layout renderer returns "Could not find entry assembly" in ASP.NET. It seems that:

var assembly = Assembly.GetEntryAssembly();

Returns null in ASP.NET situations.

There is a StackOverflow question/answer that seems to have a solution:

http://stackoverflow.com/a/4803419/698

For myself, I've been able to make it work with:

Assembly assembly = HttpContext.Current == null ? Assembly.GetEntryAssembly() : Assembly.GetExecutingAssembly();

edit:
this only works in the assembly itself


Steps

If everything works as expected, the layout renderer can be added with the same name to NLog.Web. It should overwrite the one from core. (double check that).

Steps:

  • Create a subclass of the current layout renderer in NLog.Web, same name, different namespace.
  • Implement proposed code
  • Test with unit test in NLog.web
@304NotModified
Copy link
Member Author

304NotModified commented Aug 6, 2016

We are working on this.

As a work around, since NLog 4.3.7 you can specificy the assembly name, e.g. ${assembly-version:NLogAutloadExtension}. See https://github.com/NLog/NLog/wiki/AssemblyVersion-Layout-Renderer

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

Successfully merging a pull request may close this issue.

1 participant