Is it possible for a process to load two dll with different versions?
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
tolibcef1.dll
, but in vain. That word like application still crashed as usually if I use its web content.