AutoRebuild: System.ComponentModel.Win32Exception : 'Access denied'
Current AutoRebuild implementation crash if trying to launch the app hosted in IIS.
Current found hierarchy:
- svchost
|
-- w3wp
|
-- VSIISExeLauncher
|
-- dotnet
devenv is not found of course in this scenario.
Even if the try catch seem to be good, when accessing the root process svchost, this exception is thrown:
System.ComponentModel.Win32Exception : 'Access denied'
in the 'while' statement
Due to this behavior, the try/catch need to be bubbled on the top of the while loop in order to have the correct behavior in case of fatal failure.
This commit is contained in:
parent
03b8f2c99f
commit
5112f9b310
|
|
@ -76,29 +76,28 @@ namespace Microsoft.AspNetCore.Blazor.Server.AutoRebuild
|
||||||
}
|
}
|
||||||
|
|
||||||
var candidateProcess = Process.GetCurrentProcess();
|
var candidateProcess = Process.GetCurrentProcess();
|
||||||
while (candidateProcess != null && !candidateProcess.HasExited)
|
try
|
||||||
{
|
{
|
||||||
// It's unlikely that anyone's going to have a non-VS process in the process
|
while (candidateProcess != null && !candidateProcess.HasExited)
|
||||||
// hierarchy called 'devenv', but if that turns out to be a scenario, we could
|
|
||||||
// (for example) write the VS PID to the obj directory during build, and then
|
|
||||||
// only consider processes with that ID. We still want to be sure there really
|
|
||||||
// is such a process in our ancestor chain, otherwise if you did "dotnet run"
|
|
||||||
// in a command prompt, we'd be confused and think it was launched from VS.
|
|
||||||
if (candidateProcess.ProcessName.Equals("devenv", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
{
|
||||||
return candidateProcess;
|
// It's unlikely that anyone's going to have a non-VS process in the process
|
||||||
}
|
// hierarchy called 'devenv', but if that turns out to be a scenario, we could
|
||||||
|
// (for example) write the VS PID to the obj directory during build, and then
|
||||||
|
// only consider processes with that ID. We still want to be sure there really
|
||||||
|
// is such a process in our ancestor chain, otherwise if you did "dotnet run"
|
||||||
|
// in a command prompt, we'd be confused and think it was launched from VS.
|
||||||
|
if (candidateProcess.ProcessName.Equals("devenv", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return candidateProcess;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
candidateProcess = ProcessUtils.GetParent(candidateProcess);
|
candidateProcess = ProcessUtils.GetParent(candidateProcess);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
}
|
||||||
{
|
catch (Exception)
|
||||||
// There's probably some permissions issue that prevents us from seeing
|
{
|
||||||
// further up the ancestor list, so we have to stop looking here.
|
// There's probably some permissions issue that prevents us from seeing
|
||||||
break;
|
// further up the ancestor list, so we have to stop looking here.
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue