DotNET.jl
DotNET.jl copied to clipboard
VSCode crashes with DotNET
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
Doing using DotNET; sleep(0)solve the issue.
Actually not always...seems a bit random 🤔
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?
I am using Julia 1.8 beta 1. I can try 1.7.2.
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.
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 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")
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
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.
Currently, DotNET.jl uses
coreclrhost.hto host the CLR (coreclr_initialize). I checked MSDN and Microsoft says this API is deprecated in favor ofnethostandhostfxr. 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 ;)
Currently, DotNET.jl uses
coreclrhost.hto host the CLR (coreclr_initialize). I checked MSDN and Microsoft says this API is deprecated in favor ofnethostandhostfxr. 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