-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Implement LoadLibraryErrorTracker #69842
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
Conversation
|
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsFinishes the LoadLibraryErrorTracker port from CoreCLR VM to C#. This allows us to report more details about the reason of The logic matches CoreCLR. There might be a slight behavior difference for empty string literal Instead of: We can now do: Contributes to #69743. Cc @dotnet/ilc-contrib
|
Finishes the LoadLibraryErrorTracker port from CoreCLR VM to C#. This allows us to report more details about the reason of `DllImport` resolution failures at runtime. The logic matches CoreCLR. There might be a slight behavior difference for empty string literal `DllImport`/`NativeLibrary.Load`. Not sure we care enough (I couldn't discern what the CoreCLR behavior is - I think we report an arbitrary old message from the last load attempt since we never even try to `dlopen` the empty string). Instead of: ``` System.DllNotFoundException: Unable to load native library 'bruh' or one of its dependencies. ``` We can now do: ``` System.DllNotFoundException: Unable to load DLL 'bruh' or one of its dependencies: The process cannot access the file because it is being used by another process. ```
7902abc to
634e68b
Compare
...tiveaot/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.cs
Outdated
Show resolved
Hide resolved
...tiveaot/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.cs
Outdated
Show resolved
Hide resolved
...tiveaot/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.cs
Show resolved
Hide resolved
...System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.Windows.cs
Outdated
Show resolved
Hide resolved
...System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.Windows.cs
Outdated
Show resolved
Hide resolved
jkotas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise. Thank you!
| <data name="Arg_DllNotFoundExceptionParameterized" xml:space="preserve"> | ||
| <value>Unable to load native library '{0}' or one of its dependencies.</value> | ||
| <data name="DllNotFound_Windows" xml:space="preserve"> | ||
| <value>Unable to load DLL '{0}' or one of its dependencies: {1}</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since {1} seems likely to be a sentence, I think it reads better (and perhaps it's more conventional) to separate with a period instead of a colon. For example we do this in the console output for FailFast. Etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the existing string from mscorrc:
runtime/src/coreclr/dlls/mscorrc/mscorrc.rc
Line 165 in abca8a1
| IDS_EE_NDIRECT_LOADLIB_WIN "Unable to load DLL '%1' or one of its dependencies: %2" |
Finishes the LoadLibraryErrorTracker port from CoreCLR VM to C#.
This allows us to report more details about the reason of
DllImportresolution failures at runtime.The logic matches CoreCLR. There might be a slight behavior difference for empty string literal
DllImport/NativeLibrary.Loadon Unix-like systems. Not sure we care enough (I couldn't discern what the CoreCLR behavior is - I think we report an arbitrary old message from the last load attempt since we never even try todlopenthe empty string).Instead of:
We can now do:
Contributes to #69743.
Cc @dotnet/ilc-contrib