I am integrating several .NET assemblies using ILMerge, including some third-party assemblies. Since this happened, I experienced several errors, which all boil down to the fact that type definitions are tied to the assembly in which they are defined.
A simple example is to define the log4net configuration section in my App.config application. It uses type = "log4net.Config.Log4NetConfigurationSectionHandler, log4net", which will not work because the log4net assembly does not exist once it has been merged with my combined assembly. However, not a big deal, I change the assembly name to my combined assembly, and it works fine.
A slightly more complex example is binary serialized types. My system uses binary serialization to send specific objects between processes. All serializable objects are defined in the general assembly, which are all other references to projects. I used the default binary serialization, but it started crashing when deserializing objects with an error, stating that it could not find the merged assembly that serialized the object. Again, it doesnβt matter, I implemented a custom SerializationBinder that looks for a type in any loaded assembly, not just one.
The previous example got more complicated when the serialized type referred to other serializable types. I continued to face more and more problems that were becoming increasingly difficult to cope with.
What I'm trying to understand is that a system like .NET and ILMerge do not work well together. Does anyone have any experience with how they solved this problem? Is it possible to tell .NET runtime that I don't care what assembly says it should be, just find it somewhere?
NOTE. Please do not answer the question why I am assembling assemblies, this is not a question of this question.
Stefan moser
source share