markmcdowell / NLog.Targets.ElasticSearch

NLog target for Elasticsearch
MIT License
176 stars 89 forks source link

Assembly Version Mismatch #88

Closed madisonleavo closed 5 years ago

madisonleavo commented 5 years ago

Hello! I'm using your lib integrated with COM interop, registering in GAC, where all dependencies have to have StrongName (which i notice you just implemented signing--thanks!). But I'm having issue with the version of the assembly. In NuGET its version 6.1.0 but when NLog is trying to load, its looking for NLog.Targets.ElasticSearch, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3eb62cd298662c6a. File version: 1.0.0.0. Product version: 1.0.0, and in my case, fails to find it. And due to integration, I can't really implement the Assembly redirects.

2019-04-04 14:48:55.8998 Info Message Template Auto Format enabled
2019-04-04 14:48:55.8998 Info Loading assembly: NLog.Targets.ElasticSearch
2019-04-04 14:48:55.8998 Error Error loading extensions. Exception: System.IO.FileNotFoundException: Could not load file or assembly 'NLog.Targets.ElasticSearch' or one of its dependencies. The system cannot find the file specified.
File name: 'NLog.Targets.ElasticSearch'
   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.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)

=== Pre-bind state information ===
LOG: DisplayName = NLog.Targets.ElasticSearch
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: NLog.Targets.ElasticSearch | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///c:/Windows/SysWOW64/
LOG: Initial PrivatePath = NULL
Calling assembly : NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///c:/Windows/SysWOW64/NLog.Targets.ElasticSearch.DLL.
LOG: Attempting download of new URL file:///c:/Windows/SysWOW64/NLog.Targets.ElasticSearch/NLog.Targets.ElasticSearch.DLL.
LOG: Attempting download of new URL file:///c:/Windows/SysWOW64/NLog.Targets.ElasticSearch.EXE.
LOG: Attempting download of new URL file:///c:/Windows/SysWOW64/NLog.Targets.ElasticSearch/NLog.Targets.ElasticSearch.EXE.

2019-04-04 14:48:55.9310 Warn Error has been raised. Exception: NLog.NLogConfigurationException: Error loading extensions: NLog.Targets.ElasticSearch ---> System.IO.FileNotFoundException: Could not load file or assembly 'NLog.Targets.ElasticSearch' 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.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)

There is a workaround as the error output suggests--I added the assembly to ..\SysWOW64 and it works.

But to fix, and I may be incorrect as I'm still learning, I think all that needs to be done is add <Version>6.1.0</Version> in section: https://github.com/markmcdowell/NLog.Targets.ElasticSearch/blob/0318815b08e6ac25c3bc29152aa7d9fb0542633c/src/NLog.Targets.ElasticSearch/NLog.Targets.ElasticSearch.csproj#L14

[Edit: backticks, not single quotes]

markmcdowell commented 5 years ago

Hey, the ci build “should” be automatically adding all the version numbers. I’ll have to check this wasn’t broken when i changed to using the tag version.

304NotModified commented 5 years ago

The signing (version number) looks good to me: image

strange ...

@madisonleavo assembly version 1.0.0.0 is OK for this library IMO

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.