-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[.NET Core 2.0.0-preview2-25407-01][Regression] ResourceManager.GetString(string) throw System.IO.FileNotFoundException #22308
Comments
CC @danmosemsft |
@gkhanna79 @atsushikan could you please help with this regression? Please treat this as high priority as it is blocking PS. What is happening is we are trying to load a resource string and the call eventually get to ManifestBasedResourceGroveler.GetSatelliteAssembly which is calling RuntimeAssembly.InternalGetSatelliteAssembly and passing throwOnFileNotFound=false so we shouldn’t throw any exceptions. InternalGetSatelliteAssembly will call RuntimeAssembly retAssembly = nLoad(an, null, this, ref stackMark,
IntPtr.Zero,
throwOnFileNotFound); which is eventually callback the managed side Loader.AssemblyLoadContext.ResolveUsingResolvingEvent that calls AssemblyLoadContext.ResolveUsingEvent which will throw the exception while we shouldn’t do that. // Since attempt to resolve the assembly via Resolving event is the last option,
// throw an exception if we do not find any assembly.
if (assembly == null)
{
throw new FileNotFoundException(SR.IO_FileLoad, simpleName);
}
|
When the Resolving event of ALC does not find any assembly resolved by the callback, it has always thrown an exception. This is not new in 2.0 but has been there since 1.0 (see https://github.com/dotnet/coreclr/blob/release/1.1.0/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs#L266 for 1.1.0 and https://github.com/dotnet/coreclr/blob/release/1.0.0/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs#L262 for 1.0.0) and is the expected behavior by design. I suspect the problem is somewhere else. |
cc @zamont |
@tarekgh What is the calltack in Windbg corresponding to the managed/VS captured one you shared above? |
@daxian-dbw .NET Core 2.0 Preview1 SDK is actually 5977 (you are using 5952, which is 25 builds old) and can be downloaded from https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.0.0-preview1-download.md. Can you confirm the issue does not repro with it? |
@gkhanna79 I am using the latest coreclr from the master branch and the problem repro there |
Yes, I would have expected it there. |
https://github.com/dotnet/corefx/issues/18791 was filed since LoadFrom implementation for NS 2.0 was not accounting to look for dependency assemblies in the same folder as assembly for which LoadFrom was being attempted for. This was fixed in dotnet/coreclr#11333 - however, the LoadFromResolve event handler should have returned null incase it could not load the dependency for some reason. Since it did not, it would propagate exceptions associated with the dependent assembly loads, which is what is happening in this issue. Assembly lib.dll is loaded using LoadFrom and ResourceManager requests to load its "Lib.Resources" dependent assembly. Since that is not found (as it is not available since resources are embedded), the LoadFromResolve event handler is invoked to attempt to load the dependency. Since the dependent assembly is not available, an exception is thrown from the event handler that gets propagated out. The fix is to return null from the event handler incase the assembly cannot be loaded for any reason. |
The issue does not repro in Preview1 since Preview1 had the original LoadFrom bug https://github.com/dotnet/corefx/issues/18791 and the fix (LoadFromResolve event handler) was introduced in Preview2 only. Also, note that this issue only affects assemblies that are loaded via LoadFrom explicitly. |
Thanks for the fix! |
The fix is in the runtime, so you should be able to use preview2 sdk and ask it to target the preview3 sharedFX (or update the runtimeconfig.json for the app). However, soon enough, there will be a preview3 SDK as well. |
Summary
PowerShell Core recently moved to .NET Core
2.0.0-preview2-25407-01
with .NET Core SDK2.0.0-preview2-006388
. Then we found a regression in this .NET Core version -- the call toResourceManager.GetString(string)
, which worked fine on .NET Core2.0.0-preview1-002106-00
, starts to throwSystem.IO.FileNotFoundException
.Impact
This is a blocking issue for us. It basically breaks PowerShell core.
Repro
An application that reads a resource string from a DLL
Lib.dll
is an example assembly that is built against .NET Core2.0
. We can see the embedded resource files inildasm
as follows:The project to build
Lib.dll
is also attached for your reference: Lib.zipRun the application to get a resource string:
Expected Behavior
With .NET Core
2.0.0-preview1-002106-00
(using .NET Core SDK2.0.0-preview1-005952
), the resource string corresponding to the keyCannotSpecifyPathAndLiteralPath
is retrieved back:Actual Behavior
With .NET Core
2.0.0-preview2-25407-01
,System.IO.FileNotFoundException
is thrown byResourceManager.GetString(string)
:The text was updated successfully, but these errors were encountered: