-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ijwhost.dll loading not always working for C++/CLI assembly. #37972
Comments
I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @vitek-karas, @swaroop-sridhar |
Would you be able to point at an example host where loading the C++/CLI library fails? It might also be useful to run something like ProcMon and check that C++/CLI library is loaded, where it looks for |
Okay, I think I found a host (validator.exe) based on your project's documented issues. Looking through that loading code, it is simply doing a I suspect this is going to be an issue with any host that loads a C++/CLI library (from a directory not on the default search path) without specifying either If the above is correct, this would be a rather unfortunate, since ideally C++/CLI library authors should not need to deal directly with |
@obiwanjacobi Running ProcMon could still be useful to check that the above is the issue. Another thing to try (sorry, I know it is not nice / pretty):
That should make it so that when @jkoritzinsky I know you worked on |
I added ijwhost.dll as delay loaded in the linker options - confirmed Added the code: #include "pch.h"
#include <delayimp.h>
extern "C"
{
FARPROC WINAPI delayLoadFailureHook(unsigned dliNotify, PDelayLoadInfo pdli)
{
if (dliNotify != dliFailLoadLib ||
_strcmpi(pdli->szDll, "ijwhost.dll") != 0) {
return NULL;
}
::OutputDebugStringA("Loading Ijwhost.dll");
const char* path = "C:\\Users\\marc\\Documents\\MyProjects\\public\\Jacobi\\Public\\GitHub\\vst.net\\Source3\\Code\\x64\\Debug\\Ijwhost.dll";
return (FARPROC)::LoadLibraryA(path);
}
const PfnDliHook __pfnDliFailureHook2 = delayLoadFailureHook;
} I build everything in Debug-x64 and ran the validator.exe to test. This (debug) output indicates that Ijwhost.dll is loading, but now the C++/CLI assembly is a 'bad format'?
Interesting to note is that I don't see my I am out of my league here... Please advice. ;-) |
Try adding a |
#pragma unmanaged
extern "C"
{
... same code as before
}
#pragma managed Same result. |
Boo, it looks like linking with I tried another workaround using assembly manifests. This seems to work with my simple repro. Added an additional manifest for embedding (if going through VS, project properties > Manifest Tool > Input and Output > Additional Manifest Files) with the contents: <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<file name="ijwhost.dll"/>
</assembly> |
Filed #38231 for discussion of creating a long-term solution. |
Yep - works for me. |
Closing as dup of #38231 |
…workaround suggested @ dotnet/runtime#37972
Add assembly manifest for VC++ projects to prevent loading issues of ijwhost.dll dotnet/runtime#38231 dotnet/runtime#37972 (comment) Not sure exactly how to test this works as expected Reference https://docs.microsoft.com/en-us/windows/win32/sbscs/assembly-manifests #3197
I am working on a solution where managed plugins are loaded into (3rd party) native host applications. The managed plugins use a C++/CLI interop library (part of my project) to let the native host recognize it as an native plugin and load it. That interop library then loads the managed plugin and marshals the calls between host and plugin. All plugin files are deployed into a single directory (ala dotnet publish) - including ijwhost.dll. So far so good.
But some hosts fail to load the plugin. I am uncertain of the reason why but I think it has to do with where the current directory is pointing to? Anyway when I copy the ijwhost.dll into the host's .exe location, it works again. In this situation setting the environment variables to do a core-host trace does not produce any results - not even a trace file. Which seem to indicate that the whole ijwhost-mechanism is not starting up (I have no knowledge of how that works in detail).
I am looking for ideas and suggestions of how I could try to fix this problem because having to copy a dll into a 3rd parties install folder is very 'suboptimal' for me and all the people that will use products build with my library.
Here is the project source code and ask if you need more info or want me to try something.
The text was updated successfully, but these errors were encountered: