-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
API Set Usage Question #5075
Comments
Update: If I reference The problem with the |
And now I am getting the error code 0x80131022 ("Invalid operation" according to Visual Studio). I really have a hard time wrapping my head around CoreCLR's inner workings, so I cannot diagnose it any further. |
We recently ran into a similar problem with For debugging, first used DependencyWalker and WinDBG to find out which modules the consumer console app is trying to load. DepnedencyWalker did not helped much as it resulted In some module load failures. WinDBG was also not very clear on mapping managed<->native libs. Finally got an exact path of dll it was loaded using ProcessExplorer:
At this point ProcessExplorer will reveal the native library the process has just loaded (by highlighting/flashing it in the expanded list). We came to conclusion that this is a Windows bug, although it is very hard to determine when there are so many precedence rules involved. So as a workaround, we ended up having two MSBuild tasks in .csproj file to emit x86/x64 versions from external .sln (residing in submodule directory). It is still work in progress but for packaging, we have decided to have NuGet package DLLs for x64 and x86 such that it would lay down the correct package on install target (https://docs.nuget.org/consume/projectjson-format#runtimes). For local testing, we have a copy task to get x64 version from This is not the ideal solution. As the consumer of lib may change their the target architecture of their project after restoring the package and NuGet will not detect that the restored package is invalidated. We may also try unloading the library that is loaded in the memory before engaging HIH in some way. :) |
@am11 I actually switched back to using SxS modules due to the reason you specified. I thought that I have also copied The current problem is that CoreCLR is being loaded correctly, but |
As it turns out, I am now suspecting that the SxS modules have nothing to do with what is going on here. Having commented-out the SxS |
Closing in favor of dotnet/coreclr#3047, which illustrates the problem I am currently having in a clearer way. |
I am trying to write a complex application (private repo) that uses CoreCLR. Since I want compatibility back to Windows 7, I must use the Microsoft.NETCore.Windows.APISets NuGet package to ensure that the application will run. However, I am running into a problem.
Having 120+ DLLs in the same directory from this one package alone (not counting my app itself, as well as the CoreFX packages I use) doesn't quite work for me, though. Therefore, I have chosen to place the CoreCLR DLLs, as well as the API Set stub DLLs, in a subdirectory. Unfortunately, once I do so they then are not found at runtime, and therefore my app won't launch.
I have tried using SxS modules, only to find that
LoadLibraryEx()
isn't aware of them AFAIK. I have then tried usingAddDllDirectory()
(with a fallback to manual%PATH%
modification if that routine isn't available), only to find that neither of them will get my app to findcoreclr.dll
. Is there any reason why callingAddDllDirectory()
is not having any effect upon DLL loading, contrary to what MSDN says? (I am loadingcoreclr.dll
using just its base file name, callingSetDllDirectories()
, as well as using theLOAD_LIBRARY_SEARCH_USER_DIRS
flag toLoadLibraryEx()
, if it helps.) Is there another technique that will allow me to put the DLLs in a subdirectory, I want to be sure that P/Invoke will be able to find the DLLs, as I use a lot of P/Invoke in my application.Apologies if this isn't the correct place to ask this.
The text was updated successfully, but these errors were encountered: