-
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
infinite recursion during resource lookup with system.private.corelib #23938
Comments
Same problem. This code throws similar exception: System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru-ru");
var appPath = AppDomain.CurrentDomain.BaseDirectory;
Assembly.LoadFrom(Path.Combine(appPath, "SomeProject.dll"));
Task.Run(() => Console.WriteLine("something")).Wait(); And this code works System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");
var appPath = AppDomain.CurrentDomain.BaseDirectory;
Assembly.LoadFrom(Path.Combine(appPath, "SomeProject.dll"));
Task.Run(() => Console.WriteLine("something")).Wait(); |
@chenhuiguo @xneg this is https://github.com/dotnet/corefx/issues/22586. It is fixed in master and we expect the fix to go out in servicing next month. |
@danmosemsft Microsoft.Orleans.OrleansCodeGenerator.Build on build |
Duplicate of #22909 |
@danmosemsft @karelz Is the servicing release 2.0.2? Even using .NET Core 2.0.2 I still hit this issue in one ASP.Net Core project, but only when the site is hosted in IIS. If it is hosted in IIS Express, or launched using dotnet CLI I have no issues. |
@BladeWise 2.0.3 due out in a few days. We expect servicing releases to move more smoothly in future. |
Fix released https://github.com/dotnet/corefx/releases/tag/v2.0.3 |
@danmosemsft How do we get a project to actually use 2.0.3? I have 2.0.3 installed (and newer releases), but I'm not sure it is actually being used. When I go into NuGet, it lists the package as 2.0.0 and shows 2.0.3 and 2.0.4 in the list, but they cannot be selected as they're "Blocked by project". I'm getting the So either the issue is not fixed or I'm not actually using 2.0.3 or newer. |
@joperezr can you help? |
@danielcrabtree how are you running your code? Are you using Visual Studio or are you using the dotnet command line? |
In this particular case, it's a console program and I'm compiling it to an exe, so it can be run directly on Windows. The error occurs when running it via this exe or via Visual Studio. I have not tried running via the dotnet command line. The thing I'm unsure about is whether it is actually using the newer point releases or not. Is there some way to confirm which version it is using or to specify it when compiling? |
Could you start your app (make it pause of necessary) then use process explorer to find the path to and certain of the system.private.corelib.dll that is loaded into your app? |
It's using For reference, the csproj is using:
|
If you build (and run it) using Visual studio it won't actually use the 2.0.3 runtime yet since we use MSBuild directly to compile it and depending on which TFM you are targeting we will use assets coming from packages(like you are seeing above). In order to use the 2.0.3 runtime from the command line, you can try running
That should run on the 2.0.3 runtime so you shouldn't see the bug. If you want to fix it on VS side, then you need to update VisualStudio to latest version so that it will contain a newer version of the CLI inserted. |
On executing those 4 commands, they all work, but the program crashes with the same error when using dotnet run. Using process explorer, it still seems to be using the same incorrect dll: I'm using Visual Studio 2017 15.5.2. I think this is the latest release version. By latest version, do you mean the latest preview version? |
I don't understand why execution of the app would load anything from |
I found that if I remove However, without I expected that I should be able to build / target any particular version of .NET Core from either the dotnet command line or Visual Studio and even have different programs running on different versions. But this doesn't seem to be the case, at least not with the point releases. I was expecting to be able to set |
AFAIK, the EXE is generated only for self-contained apps. Not sure how that looks in CSPROJ files. I don't think the behavior above is any special for point releases - at least I am pretty sure we didn't implement intentionally anything special. @steveharter do you know who to loop in to shed some light here? |
When you compile\run with a RID (win-x64) the app is considered self-contained meaning it should not look in the shared location |
That is by design - the patch version is not included in the runtimeconfig.json because the host by default will "roll-forward" to the latest patch, so specifying 2.0 will roll forward to the latest patch version available (e.g. 2.0.3). If you want to use a specific patch version (with no roll-forward), you can use |
@danielcrabtree, if you're running with a RID and standalone app \ exe, try running from the publish folder (e.g. Also to debug, set |
Just tested publish and it does copy all the required framework/runtime files. Unfortunately, it copies in the older / wrong libraries, presumably from The behavior is the same whether you publish in Visual Studio or via
If I execute the published exe with
|
So in summary this is an issue with CLI build\publish of standalone apps where the newer runtime files are not used when running a non-published build or when publishing.
This returns the version of the SDK\CLI which in turn depends on 2.0.3 of the runtime. @joperezr so dotnet build\publish is tied to the TFM (netcoreapp2.0 I presume), and not the version of the runtime the SDK\CLI depends on? Is there a way to control that, other than perhaps manually removing older copies of the nuget cache? |
Deleting the version in the nuget cache does not work. When you build, the nuget cache is repopulated with the wrong version and that is what gets used. Here's what I think needs resolving:
I think (1) is the status quo, so should be fixed. I think (2) is important, because in the event a bug is introduced in a point release that breaks your application, you need some way to revert back to the earlier working version until a fix is released. There does seem to be a general issue with different build technologies introducing different and incompatible versions of libraries and sourcing them from different places in different situations. I ran into this issue where the libraries in |
Same issue with SLES 12.2 x86_64. I am attaching the out file with the exception. /usr/share/dotnet/sdk/2.0.3/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.TargetFrameworkInference.targets(135,5): error : The current .NET SDK does not support targeting .NET Core 2.0.3. Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 2.0.3. [/home/tony/sandbox/tsm/tdp/agents/sqlonlinux/mssqlsmoapp/mssqlsmoapp.csproj] . |
anyway how do you target app for 2.0.3 since dotnet new accepts only 2.0 classlib -f|--framework - Specifies the framework to target. |
@iga1976 please check response above: https://github.com/dotnet/corefx/issues/24832#issuecomment-353442401 |
@karelz, Thanks for clarifying the targeting question. I posted "dotnet --info --version" out in dotnet/corefx#30208 |
OK, let's keep the main discussion in dotnet/corefx#30208 - the right experts are involved there. |
Incidentally @iga1976 you might want to upgrade to 2.1 as it is released and 2.0 will go out of support in the fall. |
@danmosemsft this is not related to dotnet/corefx#30593 |
my program ran on ubuntu 16.04.3 buildied with dotnet2.0.0,but it failed on one machine.
stack trace:
Assert Failure
Expression: [Recursive resource lookup bug]
Description: Infinite recursion during resource lookup within System.Private.CoreLib. This may be a bug in System.Private.CoreLib, or potentially in certain extensibility points such as assembly resolve events or CultureInfo names. Resource name: ArgumentNull_Generic
Stack Trace:
at System.SR.InternalGetResourceString(String key)
at System.SR.GetResourceString(String resourceKey, String defaultString)
at System.ArgumentNullException..ctor(String paramName)
at System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(Assembly assembly)
at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary
2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) at System.Resources.ResourceManager.GetString(String name, CultureInfo culture) at System.SR.InternalGetResourceString(String key) at System.SR.GetResourceString(String resourceKey, String defaultString) at System.ArgumentNullException..ctor(String paramName) at System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(Assembly assembly) at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args) at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName) at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder) at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark) at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark) at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary
2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
at System.SR.InternalGetResourceString(String key)
at System.SR.GetResourceString(String resourceKey, String defaultString)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive)
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Reflection.Assembly.CreateInstance(String typeName)
The text was updated successfully, but these errors were encountered: