Application stopped registering after using ILMerge

I have a very modest application with one external assembly (log4net.dll) in which I wanted to use ILMerge. I combine App.exe and log4net.dll, and the resulting executable (New.exe) seems to work correctly. However, New.exe is no longer registered, and it was logged before the merge. Remember, I copied the file App.exe.config before testing New.exe.

I'm not sure what to do with this. Does anyone know why this will happen? Am I somehow using ILMerge.exe incorrectly? The reflector seems to indicate that New.exe is "integer"; I see the Log4net assembly and all that.

+4
source share
3 answers

I do not know the internal components of log4net, but I suspect that it is looking for the assembly of log4net and cannot find it since it was merged into new.exe. The solution to this is to provide the AssemblyResolve event in the AppDomain with a function that reassigns log4net.dll to new.exe.

+5
source

My immediate suggestion would be that by changing the assembly name of the log4net assembly, you somehow broke its type resolution, possibly for a logging configuration.

Keep in mind that your type names are now different.

This means that the type name, for example

log4net.Appender.RollingFileAppender, log4net 

now will be

 log4net.Appender.RollingFileAppender, new 

(or something similar)

Check the logging configuration, fully qualify any applications, layout templates, etc. (basically the names of the log types in the list) to indicate a new assembly.

Also, if your logging configuration is in your web.config or app.config file (as opposed to a separate file), then the section definition will also need to be changed:

 <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> 

will become something like

 <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, new" /> 
+4
source

trying to register log4net in the GAC and see if it helps

0
source

Source: https://habr.com/ru/post/1347113/


All Articles