Coder Social home page Coder Social logo

NullReferenceException about csharprepl HOT 14 CLOSED

waf avatar waf commented on August 19, 2024 1
NullReferenceException

from csharprepl.

Comments (14)

Drabenstein avatar Drabenstein commented on August 19, 2024 1

I have installed again the newest SDK and it worked so I cannot check for sure if the fix works but maybe @Jamaxack could test it.

from csharprepl.

waf avatar waf commented on August 19, 2024 1

Great! Thanks for raising the issue and confirming the fix.

from csharprepl.

waf avatar waf commented on August 19, 2024

Oof, thanks for reporting! Is this reproducible every time you start csharprepl?

I have the exact same Windows specifications that you have (down to the exact same point number), and I'm unable to reproduce it. If you press "Enter" as the first key, do you get a different stack trace?

EDIT: Could you please also share the output of dotnet --info ?

from csharprepl.

Jamaxack avatar Jamaxack commented on August 19, 2024

Thanks for the prompt response. Yes pressing the "Enter" as a first key also gives an error:
132987106-f133b8a3-e8c4-4834-84cd-472b45d5c80d

from csharprepl.

waf avatar waf commented on August 19, 2024

I just set up my computer's .NET SDK installation to match yours, and still can't reproduce the issue. From the stack traces, it's pretty clear that the Roslyn Workspace is failing to get built correctly, but it's odd that it's silently failing and we then get a NullReferenceException.

I'll set up some more logging to better understand the issue; it should be ready in a few days.

In the meantime, could you please verify if installing .NET 5 resolves the issue? CSharpRepl should run just fine on the .NET 6 previews, but it'd help to rule out the possibility of something unexpected in the previews.

from csharprepl.

waf avatar waf commented on August 19, 2024

@Jamaxack when you have a chance, could you please update to the prerelease version of CSharpRepl? The only thing different in the prerelease is that it now has a --trace option that will help troubleshoot this.

You can update by running dotnet tool update -g csharprepl --version 0.3.4-rc

Then, please start csharprepl with the trace flag: csharprepl --trace

After you recreate the NullReferenceException, please share the csharprepl-tracelog-*.txt file. It's written to the current working directory.

image

Thanks! I appreciate you helping out with this.

from csharprepl.

Jamaxack avatar Jamaxack commented on August 19, 2024

Thanks for the detailed steps. I updated to the 0.3.4-rc version and started with the trace flag.

Here is the logs for pressing 'enter' first and then restarting again and pressing 'c'.

2021-09-15T14:12:06 - Trace session starting
2021-09-15T14:12:06 - Starting background initialization
2021-09-15T14:12:07 - Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at CSharpRepl.Services.Roslyn.RoslynServices.IsTextCompleteStatementAsync(String text) in C:\Users\will.fuqua\source\repos\CSharpRepl\CSharpRepl.Services\Roslyn\RoslynServices.cs:line 143
   at CSharpRepl.PrettyPromptConfig.PromptConfiguration.<>c__DisplayClass0_0.<<Configure>g__forceSoftEnterHandler|2>d.MoveNext() in C:\Users\will.fuqua\source\repos\CSharpRepl\CSharpRepl\PrettyPromptConfig\PromptConfiguration.cs:line 51
--- End of stack trace from previous location ---
   at PrettyPrompt.Panes.CodePane.OnKeyDown(KeyPress key)
   at PrettyPrompt.Prompt.InterpretKeyPress(KeyPress key, CodePane codePane, CompletionPane completionPane)
   at PrettyPrompt.Prompt.ReadLineAsync(String prompt)
   at CSharpRepl.ReadEvalPrintLoop.RunAsync(Configuration config) in C:\Users\will.fuqua\source\repos\CSharpRepl\CSharpRepl\ReadEvalPrintLoop.cs:line 41
   at CSharpRepl.Program.Main(String[] args) in C:\Users\will.fuqua\source\repos\CSharpRepl\CSharpRepl\Program.cs:line 47
   at CSharpRepl.Program.<Main>(String[] args)
2021-09-15T14:13:00 - Trace session starting
2021-09-15T14:13:00 - Starting background initialization
2021-09-15T14:13:01 - Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at CSharpRepl.Services.Roslyn.RoslynServices.CompleteAsync(String text, Int32 caret) in C:\Users\will.fuqua\source\repos\CSharpRepl\CSharpRepl.Services\Roslyn\RoslynServices.cs:line 114
   at CSharpRepl.PrettyPromptConfig.PromptConfiguration.<>c__DisplayClass0_0.<<Configure>g__completionHandler|0>d.MoveNext() in C:\Users\will.fuqua\source\repos\CSharpRepl\CSharpRepl\PrettyPromptConfig\PromptConfiguration.cs:line 45
--- End of stack trace from previous location ---
   at PrettyPrompt.Panes.CompletionPane.PrettyPrompt.Consoles.IKeyPressHandler.OnKeyUp(KeyPress key)
   at PrettyPrompt.Prompt.InterpretKeyPress(KeyPress key, CodePane codePane, CompletionPane completionPane)
   at PrettyPrompt.Prompt.ReadLineAsync(String prompt)
   at CSharpRepl.ReadEvalPrintLoop.RunAsync(Configuration config) in C:\Users\will.fuqua\source\repos\CSharpRepl\CSharpRepl\ReadEvalPrintLoop.cs:line 41
   at CSharpRepl.Program.Main(String[] args) in C:\Users\will.fuqua\source\repos\CSharpRepl\CSharpRepl\Program.cs:line 47
   at CSharpRepl.Program.<Main>(String[] args)
```

Hope it will help.

from csharprepl.

Jamaxack avatar Jamaxack commented on August 19, 2024

There is an error: "One or more errors occurred. (Could not find Microsoft.NETCore.App 5.0.7 installation in C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref -- is it installed?)"

But in my machine it is installed in different path: Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

from csharprepl.

waf avatar waf commented on August 19, 2024

Thanks! That's useful. Just to make sure I fully understand the .NET installation setup, could you please share the output of the powershell command gci "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref", "C:\Program Files\dotnet\shared\Microsoft.NETCore.App"

I think that your computer should have a "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref" directory (I think is a standard disk layout in .NET), but if that's not the case then it's something I'll definitely need to handle in csharprepl. Thanks again.

from csharprepl.

Jamaxack avatar Jamaxack commented on August 19, 2024

Sure, please check it:
image

from csharprepl.

Drabenstein avatar Drabenstein commented on August 19, 2024

Hello, I've just bumped into this project today and I have the same issue. It just exits after start. I get corresponding error in my case:

obraz

gci "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref", "C:\Program Files\dotnet\shared\Microsoft.NETCore.App"

    Directory: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          26.12.2020    00:06                3.1.0

    Directory: C:\Program Files\dotnet\shared\Microsoft.NETCore.App

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          20.03.2021    17:01                3.1.13
d----          28.06.2021    23:05                3.1.15
d----          20.03.2021    16:59                5.0.4

from csharprepl.

waf avatar waf commented on August 19, 2024

Thank you both @Jamaxack and @Drabenstein! It's because of the mismatch between those two folders. In both of your cases, the .NET 5 implementation assemblies are in "Microsoft.NETCore.App", but the .NET 5 reference assemblies are not in "Microsoft.NETCore.App.Ref".

While I work on a fix for csharprepl to handle this mismatch, I believe that both of you can solve it by installing the .NET SDK package from this link (the below screenshot shows the specific download). After installing this package, you should have .NET 5 subdirectories in both those directories.

image

from csharprepl.

waf avatar waf commented on August 19, 2024

I've just released csharprepl 0.3.4 that has a fix for this issue. I'm not sure if it handles all variations of .NET installations, but it should handle these. I'm assuming that the missing Microsoft.NETCore.App.Ref installation is installed to ~/.nuget/packages/microsoft.netcore.app.ref as mentioned in this design document.

Please try updating (dotnet tool update -g csharprepl) and let me know! Thanks.

from csharprepl.

Jamaxack avatar Jamaxack commented on August 19, 2024

Yay, after updating to version 0.3.4 it works. Thanks for the quick fix.

from csharprepl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.