英文:
DLL is not loaded if a certain other DLL is referenced
问题
I'm in the seventh circle of DLL hell.
Here's my situation:
- Class library project needs to use some DLLs, call them A.dll and B.dll.
- A.dll depends on log4net.dll, so I have to include that one too.
- If B.dll is not referenced, or if all uses of it are commented, log4net.dll is loaded (I can see it in the Modules window at runtime) and everything works correctly.
- The moment I add and use B.dll I get an exception. A.dll says it can't find log4net.dll, and if I look in the Modules window I can see that log4net.dll is indeed not there.
Things I've tried:
- Placing A.dll in a dedicated folder along with its log4net.dll does not help.
- Installing the log4net NuGet package instead of using the log4net.dll does not work.
- However installing the log4net NuGet package in the projects that use my Class Library solves the problem (but I can't require users of my library to install the log4net NuGet).
It looks like if I use B.dll the log4net.dll stops being loaded, and I don't understand why. My best guess is that B.dll includes a version of log4net itself which conflicts with the one I load for A.dll, but then why doesn't it show up in the Modules window?
Additional information:
- A is Modbus.dll, and B is Regatron.G5.dll. I use them to control some machines.
- Modbus.dll requires 1.2.10.0.
- My class library uses NET 4.7.2. I also have a console project that I use to test my library, which uses 4.7.2 as well.
英文:
I'm in the seventh circle of DLL hell.
Here's my situation:
- Class library project needs to use some DLLs, call them A.dll and B.dll.
- A.dll depends on log4net.dll, so I have to include that one too.
- If B.dll is not referenced, or if all uses of it are commented, log4net.dll is loaded (I can see it in the Modules window at runtime) and everything works correctly.
- The moment I add and use B.dll I get an exception. A.dll says it can't find log4net.dll, and if I look in the Modules window I can see that log4net.dll is indeed not there.
Things I've tried:
- Placing A.dll in a dedicated folder along with its log4net.dll does not help.
- Installing the log4net NuGet package instead of using the log4net.dll does not work.
- However installing the log4net NuGet package in the projects that use myClass Library solves the problem (but I can't require users of my library to install the log4net NuGet).
It looks like if I use B.dll the log4net.dll stops being loaded, and I don't understand why. My best guess is that B.dll includes a version of log4net itself which conflicts with the one I load for A.dll, but then why doesn't it show up in the Modules window?
Additional information:
- A is Modbus.dll, and B is Regatron.G5.dll. I use them to control some machines.
- Modbus.dll requires 1.2.10.0.
- My class library uses NET 4.7.2. I also have a console project that I use to test my library, which uses 4.7.2 as well.
答案1
得分: 2
你可以使用ILMerge来合并A.dll和log4net.dll。这样,您就不需要在项目中引入额外的log4net.dll。减少了DLL冲突的可能性。
英文:
I have a method here that used to save the project in a dll conflict:
You can use ILMerge to merge A.dll and log4net.dll. In this way, you do not need to introduce additional log4net.dll in the project. Reduced chance of dll conflicts
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论