question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.Management.Automation not found

See original GitHub issue

Describe the bug

Setting up a docker container from scratch using alpine image. Everything builds as shown in the screenshot but whenever I create a new C#/PS notebook, it begins throwing exceptions and whatever is entered in the notebook and ran hangs forever.

File name: 'System.Management.Automation, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at Microsoft.DotNet.Interactive.PowerShell.PowerShellKernel..ctor()
   at Microsoft.DotNet.Interactive.App.CommandLine.CommandLineParser.CreateKernel(String defaultKernelName, FrontendEnvironment frontendEnvironment, StartupOptions startupOptions) in D:\a\_work\1\s\src\dotnet-interactive\CommandLine\CommandLineParser.cs:line 588
   at Microsoft.DotNet.Interactive.App.CommandLine.CommandLineParser.<>c__DisplayClass5_0.<<Create>g__JupyterHandler|11>d.MoveNext() in D:\a\_work\1\s\src\dotnet-interactive\CommandLine\CommandLineParser.cs:line 272
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.CommandHandler.GetExitCodeAsync(Object value, InvocationContext context)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.DotNet.Interactive.App.CommandLine.CommandLineParser.<>c__DisplayClass5_0.<<Create>b__3>d.MoveNext() in D:\a\_work\1\s\src\dotnet-interactive\CommandLine\CommandLineParser.cs:line 218
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass27_0.<<UseVersionOption>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__24_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseDebugDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseExceptionHandler>b__0>d.MoveNext()
[I 2021-11-24 22:54:42.749 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), new random ports

Unhandled exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Management.Automation, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

.NET 6 SDK and Runtime is installed. PWSH 7.2.0 is also installed. Both are in path as well.

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ): The preview version (1.0.257301) since the one on nuget requires .net 5.

RUN dotnet tool install -g --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" Microsoft.dotnet-interactive && \
    dotnet interactive jupyter install && \
    mkdir ${NOTEBOOKS_DIR} && \
    ln -s ${PS_LOC}/pwsh /usr/bin/pwsh && \
    ln -s ${DOTNET_ROOT}/dotnet /usr/bin/dotnet
  • OS
    • Windows 11
    • Windows 10
    • macOS
    • Linux (Please specify distro) Alpine:edge
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Firefox
    • Safari
  • Frontend
    • Jupyter Notebook
    • Jupyter Lab
    • nteract
    • Visual Studio Code
    • Visual Studio Code Insiders
    • Visual Studio
    • Other (please specify)

Screenshots

If applicable, add screenshots to help explain your problem. image image image

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

8reactions
tunbk1002commented, Aug 3, 2022

For Arch user, use the sdk build from AUR, it’s newer than the community version. I don’t know why but this do the trick.

2reactions
rayhernandezcommented, Oct 12, 2022

I had the same error:

Failed to start the Kernel.

Unhandled exception: System.IO.FileNotFoundException: Could not load file or assembly ‘System.Management.Automation, Version=7.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’. The system cannot find the file specified.

File name: ‘System.Management.Automation, Version=7.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’

Thanks for the tip @tunbk1002. I was finally able to fix this on Manjaro. I downloaded these from the AUR:

aur/dotnet-host-bin                 6.0.3.sdk201-1         6.0.4.sdk202-1
aur/dotnet-runtime-bin              6.0.3.sdk201-1         6.0.4.sdk202-1
aur/netstandard-targeting-pack-bin  6.0.3.sdk201-1         6.0.4.sdk202-1
aur/dotnet-targeting-pack-bin       6.0.3.sdk201-1         6.0.4.sdk202-1
aur/dotnet-sdk-bin                  6.0.3.sdk201-1         6.0.4.sdk202-1 
Read more comments on GitHub >

github_iconTop Results From Across the Web

Referencing system.management.automation.dll in Visual ...
I've installed the SDK on 2 different 64-bit machines (with difficulty) and found the version 6.2.8229.0, 4.66MB dll on only 1, and only...
Read more >
Import-Module : Could not load file or assembly 'System. ...
I'm unable to run PnP PowerShell commands using PowerShell ISE in administrative mode. Getting following error PS C:\WINDOWS\system32> ...
Read more >
No support of System.Management.Automation for .net ...
In my project, we are using .net framework 4.6,2 and want to call powershell from our c# code. When i went to nuget...
Read more >
System.Management.Automation.dll missing?
Previously System.Management.Automation.dll was located in the PowerShell install folder. This made it easy to reference, but now it's gone, although file
Read more >
System.Management.Automation 7.3.6
Version Downloads Last updated 7.4.0‑preview.4 1,888 2 months ago 7.4.0‑preview.3 7,265 4 months ago 7.4.0‑preview.2 12,049 5 months ago
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found