Is it possible for a process to load two dll with different versions?

燕鹏 李 301 Reputation points
2022-05-24T07:18:39.42+00:00

Let me explain it further. I am facing a tough problem for me. I developed an add-in project which is a dll that can be loaded by word and word-compatible application (in this question, I call it word-like app) (they use the same ooxml standard). My add-in uses CEF (chromium embedding framework) to present some web content. Here are some details in my add-in project.

This add-in's platform target is any cpu, loaded by this word-like app. When starting up, I check if this add-in is loaded in a 32-bit environment or 64-bit environment by the size of IntPtr. After that, I decide to use a 32-bit cef library or 64-bit cef library. it makes sense. Now I know which path I should use to load the cef library. pseudocode:

private _cefPath;  
  
void FindLibraryPath() {  
  string arch = IntPtr.Size == 4 ? "x86" : "x64";  
  SetLibraryAndResourcePath(arch); // set _cefPath and other path here  
}  
  
void InitializeCef() {  
  // Load cef library  
  // this method use LoadLibraryEx with the flag  
  // LOAD_WITH_ALTERED_SEARCH_PATH to load libcef.dll  
  CefRuntime.Load(_cefPath);  
    // other init statements for cef  
}  
  
private void ThisAddIn_Startup(object sender, System.EventArgs e) {  
  FindLibraryPath();  
  InitializeCef();  
}  

But the problem is that the word-like app also use cef to load its web content, we both use the same library only with different versions. It seems that once I have loaded my libcef.dll, when I clicked the button that causes the work-like app to load its web content (it tried to load its own libcef.dll at that time, I think), the word-like app crashed. I don't know the exact cause why it crashed.

I conceive if there exsits a method that my add-in and the word-like app can load their own libcef.dll and refer to their own libcef.dll in this situation to avoid crashing the word-like app.

---

  • I tried to rename libcef.dll to libcef1.dll, but in vain. That word like application still crashed as usually if I use its web content.

205113-a-typical-cef-folder.png

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,820 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,411 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,459 questions
{count} votes