My app instantiates a COM component (global registration).
This COM component instantiates registration free components.
One of those sub-component is implementetd in C#.
If my app is not located in the same folder as the main COM component, it failed to instantatiate the C# COM component (but succeed for the other COM components).
WARNING: detailed explanations below ...
I have an application (Loader1) which loads a COM component (COM1, which is registration free) and this COM component loads as well several other COM components (which are themselves registration free).
But I must support the scenario where the loader use the COM1 component as a regular & registered COM component.
This has been working for several years without issues (just needed to sort out the manifest hell).
Now, we developped a new COM component in C# (COM interop). This component was made registration free as well (slightly different assembly dependency but works ok).
So we got:
Loader1 got a manifest specifying it uses COM1.
COM1 got a manifest specifying it uses COM2 and COM#.
Everything is in the same directory and it works flawlessly.
NOW, when i try to use another loader (Loader2) which uses COM1 as a REGULAR COM component (COM1 is registered on the system and located in another directory), it fails to instatiate COM#.
To be more specific, COM1 is registered on the system, but COM2 and COM# are not (they are private assemblies only used by COM1).
To summarise the issue:
Loader2 in his own folder, instantiates COM1 as a regular COM component.
COM1 in his own folder got private assemblies, COM2, COM#. Those private assemblies are in the COM1 folder.
COM1 instantatiates COM2 successfully.
COM1 failed to instantiate COM#.
The HRESULT returned if 0x80070002, HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND).
When i use FUSLOGVW.exe to see what the .net loader is doing, it seems .net is searching COM# in the application folder (Loader2 folder) and not the COM1 folder.
Somehow COM1 manifest is not used when searching for COM#.
But it is used when searching for COM2 ...
Well it is different systems.
Now, if I copy the Loader2 files to the folder where is located COM1 and its dependencies. Everything works fine.
So any idea, how to help the .net assembly loader to find the private assembly COM# from the COM1 folder and not the application folder ?
User contributions licensed under CC BY-SA 3.0