You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
5 xUnit cases failed with "System.InvalidOperationException : Binding model is already locked for the AppDomain and cannot be reset." #676
xUnit.net DNX Runner (64-bit ubuntu.14.04-x64)
Discovering: powershell-tests
Discovered: powershell-tests
Starting: powershell-tests
PSTests.RunspaceTests.TestRunspaceWithPowerShellAndHost [FAIL]
System.InvalidOperationException : Binding model is already locked for the AppDomain and cannot be reset.
Stack Trace:
at System.Runtime.Loader.AssemblyLoadContext.InitializeDefaultContext(AssemblyLoadContext context)
at System.Management.Automation.PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(String basePaths)
at PSTests.RunspaceTests..ctor()
PSTests.RunspaceTests.TestRunspaceWithPipeline [FAIL]
System.InvalidOperationException : Binding model is already locked for the AppDomain and cannot be reset.
Stack Trace:
at System.Runtime.Loader.AssemblyLoadContext.InitializeDefaultContext(AssemblyLoadContext context)
at System.Management.Automation.PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(String basePaths)
at PSTests.RunspaceTests..ctor()
PSTests.RunspaceTests.TestRunspaceWithPowerShell [FAIL]
System.InvalidOperationException : Binding model is already locked for the AppDomain and cannot be reset.
Stack Trace:
at System.Runtime.Loader.AssemblyLoadContext.InitializeDefaultContext(AssemblyLoadContext context)
at System.Management.Automation.PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(String basePaths)
at PSTests.RunspaceTests..ctor()
PSTests.RunspaceTests.TestRunspaceWithFunction [FAIL]
System.InvalidOperationException : Binding model is already locked for the AppDomain and cannot be reset.
Stack Trace:
at System.Runtime.Loader.AssemblyLoadContext.InitializeDefaultContext(AssemblyLoadContext context)
at System.Management.Automation.PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(String basePaths)
at PSTests.RunspaceTests..ctor()
PSTests.RunspaceTests.TestRunspaceWithPowerShellAndInitialSessionState [FAIL]
System.InvalidOperationException : Binding model is already locked for the AppDomain and cannot be reset.
Stack Trace:
at System.Runtime.Loader.AssemblyLoadContext.InitializeDefaultContext(AssemblyLoadContext context)
at System.Management.Automation.PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(String basePaths)
at PSTests.RunspaceTests..ctor()
Finished: powershell-tests
=== TEST EXECUTION SUMMARY ===
powershell-tests Total: 41, Errors: 0, Failed: 5, Skipped: 0, Time: 1.908s
/workspace/PowerShell
That came in with the new package updates. We really need to get our xUnit tests running automatically, as I rushed #662 through to unblock another developer.
The root cause is that .NET enabled a safety check that is completely valid, and we were previously skirting it in these tests. The test setup function that initializes the AssemblyLoadContext should only be called once, but is being for each test it seems.
Andy Jordan (@andschwa) I use below code to fix calling once issue, but I meet another issue when fix it.
public static object setupObject;
// Initialize the Core PowerShell AssemblyLoadContext
public RunspaceTests()
{
if(setupObject==null)
{
setupObject=new object();
PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(AppContext.BaseDirectory);
}
}
New error:
xUnit.net DNX Runner (64-bit ubuntu.14.04-x64)
Discovering: powershell-tests
Discovered: powershell-tests
Starting: powershell-tests
PSTests.RunspaceTests.TestRunspaceWithPowerShellAndHost [FAIL]
System.InvalidOperationException : Binding model is already locked for the AppDomain and cannot be reset. Stack Trace:
at System.Runtime.Loader.AssemblyLoadContext.InitializeDefaultContext(AssemblyLoadContext context)
at System.Management.Automation.PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(String basePaths)
at PSTests.RunspaceTests..ctor()
PSTests.RunspaceTests.TestRunspaceWithPipeline [FAIL]
System.InvalidOperationException : The default AssemblyLoadContext in use is invalid. The default AssemblyLoadContext for PowerShell Core should be of type 'PowerShellAssemblyLoadContext'.
Stack Trace:
at System.Management.Automation.ClrFacade.GetAssemblyLoadContext()
at System.Management.Automation.ClrFacade.Load(AssemblyName assembly)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadMshSnapinAssembly(PSSnapInInfo mshsnapinInfo)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIn(PSSnapInInfo mshsnapinInfo)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIns(Collection1 mshsnapinInfos, PSConsoleLoadException& warning) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadConsole(PSConsoleLoadException& warning) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration() at System.Management.Automation.Runspaces.RunspaceConfiguration.Create() at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(PSHost host) at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace() at PSTests.RunspaceTests.TestRunspaceWithPipeline() PSTests.RunspaceTests.TestRunspaceWithPowerShell [FAIL] System.InvalidOperationException : The default AssemblyLoadContext in use is invalid. The default AssemblyLoadContext for PowerShell Core should be of type 'PowerShellAssemblyLoadContext'. Stack Trace: at System.Management.Automation.ClrFacade.GetAssemblyLoadContext() at System.Management.Automation.ClrFacade.Load(AssemblyName assembly) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadMshSnapinAssembly(PSSnapInInfo mshsnapinInfo) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIn(PSSnapInInfo mshsnapinInfo) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIns(Collection1 mshsnapinInfos, PSConsoleLoadException& warning)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadConsole(PSConsoleLoadException& warning)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration()
at System.Management.Automation.Runspaces.RunspaceConfiguration.Create()
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(PSHost host)
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace()
at PSTests.RunspaceTests.TestRunspaceWithPowerShell()
PSTests.RunspaceTests.TestRunspaceWithFunction [FAIL]
System.InvalidOperationException : The default AssemblyLoadContext in use is invalid. The default AssemblyLoadContext for PowerShell Core should be of type 'PowerShellAssemblyLoadContext'.
Stack Trace:
at System.Management.Automation.ClrFacade.GetAssemblyLoadContext()
at System.Management.Automation.ClrFacade.Load(AssemblyName assembly)
at System.Management.Automation.Runspaces.PSSnapInHelpers.LoadPSSnapInAssembly(PSSnapInInfo psSnapInInfo, Dictionary2& cmdlets, Dictionary2& providers)
at System.Management.Automation.Runspaces.InitialSessionState.ImportPSSnapIn(PSSnapInInfo psSnapInInfo, PSSnapInException& warning)
at System.Management.Automation.Runspaces.InitialSessionState.ImportCorePSSnapIn()
at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2()
at Microsoft.PowerShell.Linux.Host.Listener..ctor(String initialScript, Boolean loadProfiles)
at PSTests.RunspaceTests.TestRunspaceWithFunction()
PSTests.RunspaceTests.TestRunspaceWithPowerShellAndInitialSessionState [FAIL]
System.InvalidOperationException : The default AssemblyLoadContext in use is invalid. The default AssemblyLoadContext for PowerShell Core should be of type 'PowerShellAssemblyLoadContext'.
Stack Trace:
at System.Management.Automation.ClrFacade.GetAssemblyLoadContext()
at System.Management.Automation.ClrFacade.Load(AssemblyName assembly)
at System.Management.Automation.Runspaces.PSSnapInHelpers.LoadPSSnapInAssembly(PSSnapInInfo psSnapInInfo, Dictionary2& cmdlets, Dictionary2& providers)
at System.Management.Automation.Runspaces.InitialSessionState.ImportPSSnapIn(PSSnapInInfo psSnapInInfo, PSSnapInException& warning)
at System.Management.Automation.Runspaces.InitialSessionState.ImportCorePSSnapIn()
at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2()
at PSTests.RunspaceTests.TestRunspaceWithPowerShellAndInitialSessionState()
Finished: powershell-tests
Andy Jordan (@andschwa) We still repro this error, you can login ps64-ubun14-01 (IP: 10.231.73.77 ) user: root password:OpsMgr2007R2 to check the result under /root folder, thanks.
Activity
andyleejordan commentedon Mar 16, 2016
That came in with the new package updates. We really need to get our xUnit tests running automatically, as I rushed #662 through to unblock another developer.
The root cause is that .NET enabled a safety check that is completely valid, and we were previously skirting it in these tests. The test setup function that initializes the
AssemblyLoadContextshould only be called once, but is being for each test it seems.andyleejordan commentedon Mar 16, 2016
Sorry, I haven't even had time to get this filed to get fixed properly. Thanks for reporting.
JumpingYang001 commentedon Mar 16, 2016
Andy Jordan (@andschwa) I use below code to fix calling once issue, but I meet another issue when fix it.
New error:
xUnit.net DNX Runner (64-bit ubuntu.14.04-x64)
Discovering: powershell-tests
Discovered: powershell-tests
Starting: powershell-tests
PSTests.RunspaceTests.TestRunspaceWithPowerShellAndHost [FAIL]
System.InvalidOperationException : Binding model is already locked for the AppDomain and cannot be reset. Stack Trace:
at System.Runtime.Loader.AssemblyLoadContext.InitializeDefaultContext(AssemblyLoadContext context)
at System.Management.Automation.PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(String basePaths)
at PSTests.RunspaceTests..ctor()
PSTests.RunspaceTests.TestRunspaceWithPipeline [FAIL]
System.InvalidOperationException : The default AssemblyLoadContext in use is invalid. The default AssemblyLoadContext for PowerShell Core should be of type 'PowerShellAssemblyLoadContext'.
Stack Trace:
at System.Management.Automation.ClrFacade.GetAssemblyLoadContext()
at System.Management.Automation.ClrFacade.Load(AssemblyName assembly)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadMshSnapinAssembly(PSSnapInInfo mshsnapinInfo)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIn(PSSnapInInfo mshsnapinInfo)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIns(Collection
1 mshsnapinInfos, PSConsoleLoadException& warning) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadConsole(PSConsoleLoadException& warning) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration() at System.Management.Automation.Runspaces.RunspaceConfiguration.Create() at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(PSHost host) at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace() at PSTests.RunspaceTests.TestRunspaceWithPipeline() PSTests.RunspaceTests.TestRunspaceWithPowerShell [FAIL] System.InvalidOperationException : The default AssemblyLoadContext in use is invalid. The default AssemblyLoadContext for PowerShell Core should be of type 'PowerShellAssemblyLoadContext'. Stack Trace: at System.Management.Automation.ClrFacade.GetAssemblyLoadContext() at System.Management.Automation.ClrFacade.Load(AssemblyName assembly) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadMshSnapinAssembly(PSSnapInInfo mshsnapinInfo) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIn(PSSnapInInfo mshsnapinInfo) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIns(Collection1 mshsnapinInfos, PSConsoleLoadException& warning)at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadConsole(PSConsoleLoadException& warning)
at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration()
at System.Management.Automation.Runspaces.RunspaceConfiguration.Create()
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(PSHost host)
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace()
at PSTests.RunspaceTests.TestRunspaceWithPowerShell()
PSTests.RunspaceTests.TestRunspaceWithFunction [FAIL]
System.InvalidOperationException : The default AssemblyLoadContext in use is invalid. The default AssemblyLoadContext for PowerShell Core should be of type 'PowerShellAssemblyLoadContext'.
Stack Trace:
at System.Management.Automation.ClrFacade.GetAssemblyLoadContext()
at System.Management.Automation.ClrFacade.Load(AssemblyName assembly)
at System.Management.Automation.Runspaces.PSSnapInHelpers.LoadPSSnapInAssembly(PSSnapInInfo psSnapInInfo, Dictionary
2& cmdlets, Dictionary2& providers)at System.Management.Automation.Runspaces.InitialSessionState.ImportPSSnapIn(PSSnapInInfo psSnapInInfo, PSSnapInException& warning)
at System.Management.Automation.Runspaces.InitialSessionState.ImportCorePSSnapIn()
at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2()
at Microsoft.PowerShell.Linux.Host.Listener..ctor(String initialScript, Boolean loadProfiles)
at PSTests.RunspaceTests.TestRunspaceWithFunction()
PSTests.RunspaceTests.TestRunspaceWithPowerShellAndInitialSessionState [FAIL]
System.InvalidOperationException : The default AssemblyLoadContext in use is invalid. The default AssemblyLoadContext for PowerShell Core should be of type 'PowerShellAssemblyLoadContext'.
Stack Trace:
at System.Management.Automation.ClrFacade.GetAssemblyLoadContext()
at System.Management.Automation.ClrFacade.Load(AssemblyName assembly)
at System.Management.Automation.Runspaces.PSSnapInHelpers.LoadPSSnapInAssembly(PSSnapInInfo psSnapInInfo, Dictionary
2& cmdlets, Dictionary2& providers)at System.Management.Automation.Runspaces.InitialSessionState.ImportPSSnapIn(PSSnapInInfo psSnapInInfo, PSSnapInException& warning)
at System.Management.Automation.Runspaces.InitialSessionState.ImportCorePSSnapIn()
at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2()
at PSTests.RunspaceTests.TestRunspaceWithPowerShellAndInitialSessionState()
Finished: powershell-tests
andyleejordan commentedon Mar 16, 2016
Can you re-test on the latest
masterbranch? I know I saw the same errors in the last few days, but I can't reproduce it any more.andyleejordan commentedon Mar 16, 2016
Strange. It only reproduces intermittently. 1/3 runs just now.
JumpingYang001 commentedon Mar 17, 2016
Andy Jordan (@andschwa) We still repro this error, you can login ps64-ubun14-01 (IP: 10.231.73.77 ) user: root password:OpsMgr2007R2 to check the result under /root folder, thanks.
andyleejordan commentedon Mar 17, 2016
That's no problem, it reproed for me eventually, just not the first or second time. Which is strange. I'll look into this further.
Fix AssemblyLoadContext fixture
Fix AssemblyLoadContext fixture