Closed ppekrol closed 3 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
Has it worked on .NET 5? If not you should try. Also why did you removed the extra information from the exception? https://github.com/ravendb/ravendb/blob/e96640ba52d81b86842abedfa6ec7a9db30eb24b/src/Raven.Embedded/RavenServerRunner.cs#L100-L102 and why didn't you contacted the authors of RavenDB first because it fails in their code?
It works fine in VS2019 and I am one of the authors of RavenDB.
I just do not understand why starting a process that does not depend on .NET 6 yields that exception, but only if compiled from inside VS2022. When compiled from VS2019 or CLI, works fine. From me it looks like VS2022 is injecting sth there.
Simpler repro. No dependencies. No RavenDB.
From CLI:
dotnet build -c Release
cd .\ConsoleToSchedule
dotnet run -c Release
Output:
Starting 'D:\workspaces\Temp\ConsoleApp4\ConsoleToStart\bin\Release\net5.0\ConsoleToStart.exe'.
OK
From VS2022:
Open SLN
Rebuild in Release
Set as Startup: ConsoleToSchedule
Run
Output:
Starting 'D:\workspaces\Temp\ConsoleApp4\ConsoleToStart\bin\Release\net5.0\ConsoleToStart.exe'.
OK
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath startupHook)
at System.StartupHookProvider.ProcessStartupHooks()
D:\workspaces\Temp\ConsoleApp4\ConsoleToSchedule\bin\Release\net6.0\ConsoleToSchedule.exe (process 21916) exited with code -532462766.
Press any key to close this window . . .
Attached the repro. ProcessStartRepro.zip
You need to set the working directory for the process.
Changed code to:
using System.Diagnostics;
var path = Path.GetFullPath($"{AppContext.BaseDirectory}/../../../../ConsoleToStart/bin/Release/net5.0/ConsoleToStart.exe");
var workingDir = Path.GetDirectoryName(path);
Console.WriteLine($"Starting '{path}' with working directory '{workingDir}'.");
Process.Start(new ProcessStartInfo
{
FileName = path,
WorkingDirectory = workingDir
});
Console.WriteLine("OK");
Still does not work.
Attached the repro. ProcessStartRepro.zip
I cannot reproduce it, works fine for me using VS 2022. Must be something on your end.
VS2022 is setting DOTNET_STARTUP_HOOKS
environment variable to "c:\program files\microsoft visual studio\2022\preview\common7\ide\commonextensions\microsoft\hotreload\Microsoft.Extensions.DotNetDeltaApplier.dll"
that is .NET 6 targeting assembly. DOTNET_STARTUP_HOOKS
gets inherited by the child processes. If the child process targets older .NET versions, the startup hook loading will fail with the error above.
This is a bug in hot reload.
Tagging subscribers to this area: @tommcdon See info in area-owners.md if you want to be subscribed.
Author: | ppekrol |
---|---|
Assignees: | - |
Labels: | `area-Diagnostics-coreclr`, `untriaged` |
Milestone: | - |
cc @mikem8361
I'm not sure how the runtime itself can fix this?
Agree. This issue should be transfer to its proper home. The hot reload helper .dll needs to target least common denominator TFM; or reload needs to clear the env variable; or the reload helper .dll needs to be loaded using funceval without setting the startup hook env variables.
Adding @pranavkm
The reload helper is gated on a TFM, but it doesn't stop from leaking into child processes. We can definitely clear the environment variable that would be a fairly targeted / self-contained change.
Hi all,
I'm using .NET SDK '6.0.100-preview.7.21379.14' on Windows 10 x64 with following code:
and CSPROJ as follows:
It works fine when I do
dotnet build
ordotnet run
via the CLI, but I'm having issues starting this via VS2022 (prev 3.1).Getting following error:
Please note that RavenDB Embedded issues Process.Start underneath and has no dependency on .NET 6 (requires .NET 5.0.7). Code here: https://github.com/ravendb/ravendb/blob/e96640ba52d81b86842abedfa6ec7a9db30eb24b/src/Raven.Embedded/RavenServerRunner.cs#L77
We already submitted that issue to VS team (https://developercommunity.visualstudio.com/t/Project-Execution-Issue-with-VS-2022/1496825), but they say that this is RavenDB problem hence I'm writing here. I do not believe that it is and I'm not sure how to solve this.
Would appreciate your help.