DotNET.jl icon indicating copy to clipboard operation
DotNET.jl copied to clipboard

VSCode crashes with DotNET

Open gitboy16 opened this issue 3 years ago • 11 comments

DotNET never crashes when I use it in the terminal but it does when I use it in VSCode. To reproduce the issue just type using DotNET in the julia REPL in VSCode (windows). Linked issue https://github.com/julia-vscode/julia-vscode/issues/1777 I am not sure whether the issue is coming from vscode or DotNET. Thank you

gitboy16 avatar Mar 15 '22 15:03 gitboy16

Doing using DotNET; sleep(0)solve the issue.

gitboy16 avatar Mar 15 '22 16:03 gitboy16

Actually not always...seems a bit random 🤔

gitboy16 avatar Mar 15 '22 16:03 gitboy16

I have no idea about this and #1, but it seems to be a Windows-specific problem. Recently I switched to Julia 1.7.2, and in VSCode REPL the package can not load at all because coreclr_initialize failed with code 0x80004005. Which Julia version are you using?

azurefx avatar Mar 16 '22 18:03 azurefx

I am using Julia 1.8 beta 1. I can try 1.7.2.

gitboy16 avatar Mar 16 '22 19:03 gitboy16

When I use Julia 1 7.2, the first time I ]add the package, then do using DotNET it fails. When I re-open the vscode REPL and do using again it works fine. (And I tried multiple times)

Now when I use Julia 1.8 beta 1, the first time i add the package and run using it works fine however if I close the REPL and re-open , run using then it crashs all the time.

Very strange.

gitboy16 avatar Mar 17 '22 10:03 gitboy16

Currently, DotNET.jl uses coreclrhost.h to host the CLR (coreclr_initialize). I checked MSDN and Microsoft says this API is deprecated in favor of nethost and hostfxr. I'll try these new APIs to see if it solves the problem.

azurefx avatar Mar 18 '22 13:03 azurefx

I am using Julia 1.8 beta 1. I can try 1.7.2.

Could you also provide your installed .NET versions?

julia> using DotNET

julia> DotNET.detect_runtime(DotNET.CoreCLR.CoreCLRHost)
5-element Vector{Any}:
 (type = "Microsoft.NETCore.App", version = v"3.1.23", path = "C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\3.1.23\\coreclr.dll")
 (type = "Microsoft.NETCore.App", version = v"3.0.1", path = "C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\3.0.1\\coreclr.dll")
 (type = "Microsoft.NETCore.App", version = v"2.0.9", path = "C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\2.0.9\\coreclr.dll")
 (type = "Microsoft.NETCore.App", version = v"2.0.7", path = "C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\2.0.7\\coreclr.dll")
 (type = "Microsoft.NETCore.App", version = v"2.0.6", path = "C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\2.0.6\\coreclr.dll")

azurefx avatar Mar 18 '22 13:03 azurefx

Here you go

julia> using DotNET

julia> DotNET.detect_runtime(DotNET.CoreCLR.CoreCLRHost)
4-element Vector{Any}:
 (type = "Microsoft.NETCore.App", version = v"3.1.22", path = "C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\3.1.22\\coreclr.dll")
 (type = "Microsoft.NETCore.App", version = v"3.0.0", path = "C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\3.0.0\\coreclr.dll")
 (type = "Microsoft.NETCore.App", version = v"2.1.30", path = "C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\2.1.30\\coreclr.dll")
 (type = "Microsoft.NETCore.App", version = v"2.1.13", path = "C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\2.1.13\\coreclr.dll")

Let me know if you need anything else. Thank you

gitboy16 avatar Mar 18 '22 17:03 gitboy16

FWIW, I can't repro this issue on Linux in VS Code. You might want to try to force Julia into single-threaded mode with the "julia.NumThreads": 0 setting.

pfitzseb avatar Mar 29 '22 13:03 pfitzseb

Currently, DotNET.jl uses coreclrhost.h to host the CLR (coreclr_initialize). I checked MSDN and Microsoft says this API is deprecated in favor of nethost and hostfxr. I'll try these new APIs to see if it solves the problem.

I implemented these api's in my .NET interop. Your welcome to push the .NET attachment to this project if you want: https://github.com/HyperSphereStudio/JULIAdotNET/blob/main/src/JULIAdotNET.jl

Let me know if you wanna trade some more ideas in the future! It seems like we are both working on the same issue but with very different methods ;)

HyperSphereStudio avatar Jul 28 '22 07:07 HyperSphereStudio

Currently, DotNET.jl uses coreclrhost.h to host the CLR (coreclr_initialize). I checked MSDN and Microsoft says this API is deprecated in favor of nethost and hostfxr. I'll try these new APIs to see if it solves the problem.

But I also encountered same issue as this thread. Using new API's doesnt fix REPL crash. I just disabled the Julia -> C# Interface in interactive mode for now

HyperSphereStudio avatar Jul 28 '22 07:07 HyperSphereStudio